Chapter VI The real time monitoring and control program (ST-RTOP)
6.5. Description of some of the main software components
6.5.2. The console user interface (the keyboard and the LCD)
Local Bus 2 resource through the above discussed architecture and protocol.
Second example: We observed, in data logs collected by the ST-RTOP, that in some sporadic lines, the local time was corrupted. We had no explanation for only some sporadic lines being corrupted, until we discovered that we missed placing a semaphore for accessing the RTC, by mistake, in a place where it was required.
The spurious error immediately disappeared once we placed a semaphore on the required position. See the partial data log on the Figure 79 below showing the mentioned spurious corrupt data, as a factual example of bus conflicts and their solution through bus arbitring.
In Figure 79, highligthed lines show corrupted local time. Note that there are some (non corrupted) lines that were hidden for showing more records.
6.5.2. The console user interface (the keyboard and the LCD)
command interface. While 11 commands are single stroke actions, the extended commands are triggered by pressing a combination of keys in the format *nn#, where the asterisk is the command prologue (when pressed it indicates that an extended command is beginning), “nn” is a number representing the command, and the hash is the command epilogue (command terminator). A list of extended commands and their description can be found in table 5.2 below.
Table 5.2 – List of menu options and the respective keyboard commands.
extended Cmd Nr
Single char equivalent
Command description Notes
(Cmd = Command)
* Begin an extended command
** ESC Abort extended command, set menu option to “1” A double star sequence
# If keyboard is in buffer (multichar) mode (including extended command) then terminate it;
Otherwise: adjust the RTC time;
Equivalent to CR (carriage return) 0 Reset LCD once; show Local time from RTC chip;
1 Show day,date,time, onboard temperature and system (it is the start up default option)
02 2 Show TES / Receiver's inlet and outlet temperatures 03 3 Show current set point / actual hour and decl. angles
04 4 Up arrow: show next command
05 5 Show TES / Receiver's inlet and outlet temperatures
06 6 Down arrow: execute next command
07 7 Charging pump manually adjusted PWM control for visual debugging
display charging pump actual and set point speeds.
08 8 Display discharging pump actual and set point speeds.
09 9 Heat utilization display (not implemented) set temporarily to tracker control monitoring 00 A Set tracker control to auto mode.
01 C Adjust the RTC time
11 d Download data logging configuration from RS232 (not implemented)
12 D Download data logging configuration from SD card (not implemented)
20 e Specify seekError (=tracking accuracy error) 21 E Specify StayError (=tracking step)
22 F Request fuzzy_FSM tracker control(not implemented).
23 g Show M2M info (not implemented).
24 G Datalog to M2M (not implemented).
25 L Specify the data logging interval in seconds 55 M Set tracker to manual mode.
99 p Set tracker to auto mode & set point to parking position
66 Q Request Fuzzy-PID pump control(not implemented).
70 R Request system reset (restart the system) (not implemented)
77 s Show SD card information (not implemented) 78 S Data log to SD card (not implemented)
It is worth noting that this table can be improved, by reassigning and or reordering the commands. Also, new commands can be added.
The basic functionality of the keyboard event handler, as briefly described in point (a) of this section, is represented on the flow chart of the Figure 80 below.
A more detailed flow chart could be represented. Though, a listing of the source code can be found in the appendix A. Both the keyboard interrupt handler and the auxiliary extended command processor can be found in page 142.
6.5.2.2. The LCD software interface implementation
The LCD is a common type, 2 lines x 16 dot matrix characters display (LMB162ABC).
It is interfaced with the MCU using 4 data bits mode, as described in section 5.7.1.
Based in its datasheet information a software interface was written. The protocol for writing/reading to/from the LCD is well documented in the datasheet, including the flowcharts for initializing the LCD for either 4 bits or 8 bits data mode. We used this to write the list of interfacing function described below.
As with the real time clock, the low level hardware interfacing functions were written in assembly language, aiming at fulfilling the time-critical requirements of the LCD initialization protocol (see the datasheet in appendix D). The LCD handling functions at low level, are:
• LCDreset - performs LCD module initialization for 4bits interface;
• LCDwriteCMD - sends a command byte to the LCD;
• LCDwriteDATA - this sends a data byte to the LCD;
Figure 80 - Generic functionality of the keyboard event handler and comand processor Keyboard ISR
begin
keyboard ISR Return from int
N
Y
Any interrupt running?
Are there any time critical interrupts running right now?
Is Keyb data available?
Read the key code and process it
N
• LCDaddress - sets the active address (line, column) at which the next character will be written;
• dly_1ms – generates a delay of about 1 millisecond;
• dly_10ms – generates a delay of 10 milliseconds;
• dly_100us – generates a delay of 100 microseconds.
The only high level function is LCDwriteMsg, which is written in C language. The source code for this function can be found in page 150, while the source code for the low level functions listed above, are found in page 171 of the appendix A.