1 / 35

Course Project Self-Calibrating Prayers Clock

Course Project Self-Calibrating Prayers Clock. Khaled A. Al- Utaibi alutaibi@uoh.edu.sa. Agenda. Microprocessors Microcontrollers Embedded Systems. Introduction.

berg
Télécharger la présentation

Course Project Self-Calibrating Prayers Clock

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Course ProjectSelf-Calibrating Prayers Clock Khaled A. Al-Utaibi alutaibi@uoh.edu.sa

  2. Agenda • Microprocessors • Microcontrollers • Embedded Systems

  3. Introduction • To help Muslims everywhere to know the prayer times accurately, local and international companies have manufactured many models for prayer clock • Most of these can display the following information: • Current time and date. • Room temperature. • ATHAN times for the five prayers. • Time to the IQAMA.

  4. Introduction • The existing prayer clocks have the following features: • Preprogrammed prayer times for large set of cities around the world. • Ability to program prayer times for other cities by entering latitude and longitude coordinates. • Ability to program prayer times according to different Islamic calendars such as Umm Alqura, International Islamic University and University of Islamic Sciences. • Ability to alarm prayer time using sound alarm or by flashing the prayer time display.

  5. Introduction • The existing prayer clocks have the following limitations: • Require programming of date, time, location and calendar for the first time (auto –detect setting is not supported). • Some models require reprogramming of date, time, location and calendar each time the power is disconnected. • Require manual adjustment (calibration) of date and time at regular intervals to account of internal timer errors. • Do not provide any means of synchronization between individual devices.

  6. Project Objective • The objective of this project is to design a self-calibrating prayer clock based on Arduino board that overcomes the limitations of the existing models.

  7. Design Features • Specifically, the self-calibrating clock will have the following features: • Display date, time, temperature, prayer times and time to IQAMA. • Auto-detect settings (i.e., location, date, time and prayer times). • Automatic calibration of date and time at predefined regular intervals to account of internal timer errors. • Auto synchronization between individual devices at the same city.

  8. Design Interface • The interface of the self-calibrating prayer clock (Figure 1) consists of the following component: • 6 seven-segment display digits to display the current time. • 2 seven-segment display digits to display the room temperature as well as the time to IQAMA. • 4 seven-segment display digits to display the ATHAN time for FAJR prayer. • 4 seven-segment display digits to display the SUNRISE time. • 4 seven-segment display digits to display the ATHAN time for DHUHR prayer. • 4 seven-segment display digits to display the ATHAN time for ASR prayer. • 4 seven-segment display digits to display the ATHAN time for MAGHREB prayer. • 4 seven-segment display digits to display the ATHAN time for ISHA prayer. • 7 LEDs to display the current day of the week.

  9. Figure 1: Prayer clock interface.

  10. Design Component • The required component of the complete project can be grouped as follows: • Microcontroller board. • Location detection system. • Configuration and calibration system. • Display system.

  11. Design ComponentMicrocontroller Board • The self-calibrating prayer clock will be designed based on Arduino Uno board shown in Figure 2. Figure 2: Arduino Uno board.

  12. Design ComponentLocation Detection System • In order to configure /calibrate the self-calibrating clock, we need a mechanism to automatically determine the location where the clock is installed. • One option is to use a GPS shield (Figure 3). Figure 3: GPS shield form Sparkfun.

  13. Design Component Configuration/Calibration System • After determining the location of the self-calibrating prayer clock, it can be automatically configured/calibrated by accessing a dedicated server that will provide the clock with the required information (i.e., current date and time as well as prayer times). • In order to access the server, we need to use a WiFi shield shown in Figure 4. Figure 4: WiFi shield.

  14. Design ComponentDisplay System • The display system consists of two types of digital outputs: • Simple LEDs to indicate the current day of the week. • Seven-segment display digits to display date, time, temperature, ATHAN times, and time to IQAMA. • The display system requires a large number of display digits (40 seven-segment display digits). • Hence, we need to use an efficient implementation of display digits in order to minimize the required connections and simplify the display control. • One option is to use the MAX7219 based serial seven segment display module which allows you to add 8 digits of seven segment displays to your project using (Figures 5-6)

  15. Figure 5: SPI 7-Seg Display. Figure 6: Interfacing the SPI display with Arduino

  16. Design Phases • The project consists of three main phases: • Designing the clock interface and operation system. • Designing a tentative clock configuration/calibration system by reading required information from an SD card file. • Designing the final clock configuration/calibration system using GPS and WiFi shields. • In this semester, students will design and program the first and second phases. • The third phase will be designed and programmed by another group of students in the next semester.

  17. Design Requirements (Phase I & II) • The main design requirements of the first and second phases of the project are given below: • Designing the interface of the self-calibrating clock according. • Interfacing and programming the temperature sensor system. • Programming the tentative clock configuration and calibration logic. • Programming the time logic. • Programming the ATHAN times logic. • Programming the time to IQAMA logic.

  18. Design Requirements (Phase I & II)Interface Design • Design the interface of the self-calibrating clock according to Figure 1. • The MAX7219 based serial seven segment display modules can be interfaced to the Arduino board as shown in Figure 7. • The module has three control inputs: CLK, Din, and CS. • Each module requires a separate CS connection. • All modules will share the same CLK and Din connections. • It is recommended to consecutive pins starting from pin 0(i.e., 0, 1, 2, …, etc.) to control the CS lines of the modules.

  19. Figure 7: Interfacing two modules of the MAX7219 based serial 7-segment display. Module 0 Module 1 1 2 3 4 5 6 7 8 ------------------------------------- digits

  20. Design Requirements (Phase I & II)Interface Design • Programming The MAX7219 based modules is very simple: • The Maxim-Integrated company provided the necessary codes to initialize and control these modules as shown in Figure 8 (a-e). • The parameters that needs to be adjusted by the user are the first three global variables: • maxInUse • din • clk • In your program, you can use the following function to display the value 5 on the 3rd digit of the 1st module (module 0): maxSingle(0, 3, 5);

  21. Figure 8 (a): Global variables of the MAX7219 modules. // global variables for the MAX7219 modules intmaxInUse = 2; // number of MAX7219 modules to be used int din = 2; // Arduino pin connected to Din of the MAX7219 intclk = 3; // Arduino pin connected to CLK of the MAX7219 // define max7219 registers byte max7219_reg_noop = 0x00; byte max7219_reg_digit0 = 0x01; byte max7219_reg_digit1 = 0x02; byte max7219_reg_digit2 = 0x03; byte max7219_reg_digit3 = 0x04; byte max7219_reg_digit4 = 0x05; byte max7219_reg_digit5 = 0x06; byte max7219_reg_digit6 = 0x07; byte max7219_reg_digit7 = 0x08; byte max7219_reg_decodeMode = 0x09; byte max7219_reg_intensity = 0x0a; byte max7219_reg_scanLimit = 0x0b; byte max7219_reg_shutdown = 0x0c; byte max7219_reg_displayTest = 0x0f;

  22. Figure 8 (b): Function to send one byte serially to MAX7219 modules. // sends one byte serially through Din of the MAX7219 modules voidputByte(int data) { inti = 8; int mask; while(i > 0) { mask = 0x01 << (i - 1); digitalWrite(clk, LOW); if ( ( data & mask ) != 0 ){ digitalWrite(din, HIGH); } else{ digitalWrite(din, LOW); } VBBWait(); digitalWrite(clk, HIGH); VBBWait(); --i; } }

  23. Figure 8 (c): Function code to write to a single MAX7219 module. // writes to a single MAX7219 module voidmaxSingle(intcs, intreg, intcol) { digitalWrite(cs, LOW); putByte(reg); putByte(col); digitalWrite(cs, HIGH); VBBWait(); } Figure 8 (d): Function code to write to all MAX7219 modules. // writes to all MAX7219 modules in the system voidmaxAll (intreg, intcol) { for (intcs = 0; cs < maxInUse; cs++) { digitalWrite(cs, LOW); putByte(reg); putByte(col); digitalWrite(cs, HIGH); VBBWait(); } }

  24. Figure 8 (e): Function to initialize the MAX7219 modules. // initializes the MAX7219 modules void initMAX7219(){ VBBInit(6); maxAll(max7219_reg_scanLimit, 0x07); maxAll(max7219_reg_decodeMode, 0xFF); maxAll(max7219_reg_shutdown, 0x01); maxAll(max7219_reg_displayTest, 0x00); for (int e = 1; e <= 8; e++) { maxAll(e, 0); } maxAll(max7219_reg_intensity, 0x0f & 0x0f); }

  25. Design Requirements (Phase I & II)Display Room Temperature • Interface a temperature sensor (TMP36) to one of the analog pins of the Arduino board as done in Experiment 08. • Program the Arduino board to read the temperature sensor and display room temperature using two 7-segment display digits. • Note that the same two 7-segment display digits will be used to display the time to IQAM at each prayer time (i.e., ATHAN time). • After IQAMA, the two 7-segment display digits will be used again to display the room temperature until the next prayer time.

  26. Design Requirements (Phase I & II) Tentative Clock Configuration/Calibration • Program a tentative clock configuration and calibration system by reading the required information from a file on the SD card. • An example of the file format is given in Figure 9: • Line 1: current time • Line 2: FAJR prayer time • Line 3: SUNRISE time • Line 4: DHUHR prayer time • Line 5: ASR prayer time • Line 6: MAGHREB prayer time • Line 7: ISHA prayer time • Line 8: current day index (0-6: Sunday – Friday) • Line 9: current date

  27. Figure 9: Format of the prayers data file. 03:03:49 04:35 05:57 12:16 03:47 06:35 08:05 1 07/04/2014

  28. Design Requirements (Phase I & II) Tentative Clock Configuration/Calibration • The code required to read configuration and calibration information file is given in Figure 10 (a-e). • The self-calibrating prayer clock system needs to read the file at startup time as well as on some predefined interval (say every 24 hours). • After reading the file, the system will start running the time, ATHAN and IQAM logics (i.e., design requirements 4, 5, and 6). • The user needs only to call the calibration function, and then use the variables: time, date, day, and prayers.

  29. Figure 10 (a): Global variables for configuration/calibration. // global variables for configuration/calibration // current time variable int [] time = {0,0,0,0,0,0}; // prayer times variable int [][] prayers = { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }; // current date variable int [] date = {0,0,0,0,0,0,0,0}; // current day index variable int day; // file variable File f;

  30. Figure 10 (b): Function to initialize SD file. // initialize SD file booleaninitSDFile() { if( !SD.begin(4)) { returnfalse; } f = SD.open(“prayers.txt”); if( f == null) { returnfalse; } returntrue; } Figure 10 (c): Function to close SD file. // close SD file voidcloseSDFile() { f.close(); }

  31. Figure 10 (d): Function to convert character to integer. // converts character to integer inttoInt(char c) { int number = 0; switch(c) { case'0': number = 0; break; case'1': number = 1; break; case'2': number = 2; break; case'3': number = 3; break; case'4': number = 4; break; case'5': number = 5; break; case'6': number = 6; break; case'7': number = 7; break; case'8': number = 8; break; case'9': number = 9; break; default: number = 0; } return number; }

  32. Figure 10 (e): Function to read configuration/calibration information. // reads configuration/calibration information void calibrate(){ initSDFile(); // read time for (inti = 0; i < 6; i++) { time[i] = readInt(); } // read prayer times for (inti = 0; i < 6; i++) { for (int j = 0; j < 4; j++) { prayers[i][j] = readInt(); } } // read day day = readInt(); // read date for (inti = 0; i < 8; i++) { date[i] = readInt(); } closeSDFile(); }

  33. Design Requirements (Phase I & II) Time Logic • After calibration, the self-calibrating prayer clock system will display the time, date, temperature, and prayer times. • Then, the system will update and display the time every second.

  34. Design Requirements (Phase I & II) ATHAN and IQAMA Logics • After calibration, ATHAN logic will display the ATHAN time for every prayer. • When it is the ATHAN time for a particular prayer, ATHAN logic will start blinking the display of the particular prayer time (Figure 11). • At the same time, IQAMA logic will start by displaying time to IQAMA. • IQAMA logic will decrement time to IQAMA every minute and display the remaining time. • Once the time to IQAMA reaches 0, ATHAN logic will stop blinking the prayer time and IQAMA logic will display the temperature.

  35. Figure 11: ATHAN and IQAMA logics

More Related