Bailey O.H.Embedded systems.Desktop integration.2005
.pdf
170 |
Chapter 6 / Final Design |
|
|
Embedded System Flowcharts
The following flowcharts illustrate the functions of the embedded system.
System Boot / Reset
initialize
Main |
to Main |
Press any key to Reset
Error
Figure 6-9
The above sequence is initiated by the following conditions:
Applying power
Pressing the System Reset key
Pressing any key after a system error
Chapter 6 / Final Design |
171 |
|
|
From System Boot / Reset
Main_Module
Process_Key
Key Pressed
Update Timer
NO
Expired
YES
Upd_Display
Update Display
Display Timer
Reset
Error
Figure 6-10
Once the system is initialized the main program loop starts. The main program is a simple timer-based loop. First, the keyboard scan routine checks for any pending command keys. If a key is detected, the Process_Key function is called. Next, a check is made to determine if the update display timer has expired. If it has, the display data is updated and the update display timer is reset. If the timer hasn’t expired, the process starts over. If an error is encountered, the program terminates by displaying the error on the LCD and waiting for any key to be pressed to reset the unit.
Chapter 6
172 |
Chapter 6 / Final Design |
|
|
Process_Key
Start_Timer
Chg_Time
Time Key
Chg_Date
Date Key
Chg_Interface
Interface Key
Chg_High_Temp
High Alarm
Chg_Low_Temp
Low Alarm
NO
System Boot / Reset
System Reset
Reset_Sensors
Sensor Reset
Exit_Menu
NO
Timer
ERROR
Expired
YES
YES
Return
Figure 6-11
Chapter 6 / Final Design |
173 |
|
|
Upon entry a 30-second timer is set for reference. During that 30-second period the keyboard is scanned for a selected menu item. If a menu item is selected, the proper function is called. If the exit key is pressed, the timer is disabled and a return to Main_Module is made.
Upd_Display
Get_Time
Update Time
Get_Date
Check Date
Get_Temp
Check Temp
|
Check Temp |
|
Chk_Hi_Temp |
|
|
High |
|
|
|
|
|
|
|
Chk_Lo_Temp |
|
|
|
||
|
|
|
|
|
|
Check Low |
|
||
|
Temp |
|
|
|
|
|
|
|
Upd_LCD |
|
|
|
|
|
|
|
|
|
|
|
Upd_LCD |
|
||
|
|
|
||
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
Return |
|
||
Figure 6-12
The Upd_Display function reads current temperature, alarm, time, and date, and then updates the LCD display with the new data.
Chapter 6
174 |
Chapter 6 / Final Design |
|
|
Chg_Time
Chg_Hour
Update Hour
Chg_Minute
Update Minute
Chg_Second
Update Second
Chg_AmPm
Toggle AM/PM
Chg_12_24
Toggle 12/24
Store |
|
|
|
YES |
|
||||||
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
Save_Time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save Time |
|
||||
|
NO |
|
|
|
|
|
|||||
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return
Figure 6-13
The Chg_Time function allows editing of the hour, minute, seconds, AM/PM, and 12-/24-hour display format. The values are changed on the LCD immediately but are only made permanent when the Save key is pressed. If the Save key is not pressed, the old parameters are restored when returning to the main display.
Chapter 6 / Final Design |
175 |
|
|
Chg_Date
Chg_Month
Update Month
Chg_Day
Update Day
Chg_Year
Update Year
|
Short / Long |
|
|
Chg_Yr_Disp |
||||||||||
|
Display |
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
Store |
|
|
|
||||||||||
|
|
|
|
YES |
|
|||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save_Date |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save Date |
|
|
||||
|
|
NO |
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return 
Figure 6-14
This function allows the day, month, year, and long or short year display to be changed. Again, the new settings are displayed immediately but lost unless the Save key is pressed.
Chapter 6
176 |
Chapter 6 / Final Design |
|
|
Chg_Interface
Select_Serial
RS-232
Select_USB
USB
Select_Enet
Ethernet
Debug_Mode
Debug Mode
Store |
|
|
|
YES |
|
||||||
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
Save_Interface_Data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save Data |
|
||||
|
NO |
|
|
|
|
|
|||||
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return
Figure 6-15
Each type of interface has different variables and parameters associated with it. Debug mode can only be turned on if USB or Ethernet is selected as the interface type. As always, the data is not stored unless the Save key has been pressed.
Chapter 6 / Final Design |
177 |
|
|
Chg_High_Temp
|
|
Increase Temp |
|
|
Inc_Hi_Temp |
||||||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
Dec_Hi_Temp |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Decrease_Temp |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
Chg_Temp_Scale |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Toggle Scale |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
Inc_Zone_Number |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Increase Zone |
|
||||||||||||||
|
|
Number |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
Dec_Zone_Number |
||||||
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Decrease Zone |
|
||||||||||||||
|
|
Number |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
Store |
|
|
|
||||||||||||
|
|
|
|
|
|
YES |
|
||||||||||
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save_HiTemp_Data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
Save Data |
|
|||||
|
|
|
NO |
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
Return |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
||||||||
Figure 6-16 |
|
|
|
|
|
|
|
||||||||||
The Chg_High_Temp function allows the upper temperature limit to be increased, decreased, and displayed in Celsius or Fahrenheit, and multiple zones to be edited. While there is no requirement to support multiple zones in the prototype, the logic is being included to see how much additional RAM will be available in a completely implemented system.
Chapter 6
178 |
Chapter 6 / Final Design |
|
|
Chg_Low_Temp
|
|
Increase Temp |
|
|
Inc_Lo_Temp |
||||||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
Dec_Lo_Temp |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Decrease Temp |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
Chg_Temp_Scale |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Toggle Scale |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
Inc_Zone_Number |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Increase Zone |
|
||||||||||||||
|
|
Number |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
Dec_Zone_Number |
||||||
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
Decrease Zone |
|
||||||||||||||
|
|
Number |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
Store |
|
|
|
||||||||||||
|
|
|
|
|
|
YES |
|
||||||||||
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save_LoTemp_Data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
Save Data |
|
|||||
|
|
|
NO |
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
Return |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
||||||||
Figure 6-17 |
|
|
|
|
|
|
|
||||||||||
While the actual data stored and retrieved with the Chg_Low_ Temp function is different from the high temperature limit, much of the functionality is shared with the Chg_High_Temp function.
Chapter 6 / Final Design |
179 |
|
|
Reset_Sensors
|
Reset 1-Wire |
|
Reset_1Wire |
|
|
Bus |
|
|
|
|
|
|
|
Read_All-1Wire |
|
|
|
||
|
|
|
|
|
|
Read 1-Wire |
|
||
|
Devices |
|
|
|
|
|
|
|
Read_1W-Time |
|
|
|
|
|
|
|
|
|
|
|
Read Time |
|
||
|
|
|
||
|
|
Read_1W-Date |
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Read Date |
|
||
|
|
|
||
|
|
Read_Hi_Alm |
||
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
Read High |
|
||
|
Alarm |
|
|
|
|
|
|
|
Read_Lo_Alm |
|
|
|
|
|
|
|
|
|
|
|
Read Low Alarm |
|
||
|
|
|
||
|
Upd_Display |
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Update LCD |
|
||
|
|
|
||
|
|
|
||
|
|
|
|
|
|
|
|
|
|
Return
Figure 6-18
When the 1-Wire bus is reset, all 1-Wire devices are interrogated and accounted for. If a 1-Wire time and date chip is available, the time and date are read and stored. Next, the high temperature and low temperature sensor settings are read and stored. Before exiting the reset sensor function a call to Upd_Display is made. This displays the new readings on the LCD display.
This covers all the functions of the embedded system from a design point of view. Next we will cover the flowcharts for the host system.
Chapter 6
