Embedded Real Time Software Development Week 10 Real
Embedded Real Time Software Development Week 10 Real Time System Design ENTC-489 Embedded Real Time Software Development
Today’s Agenda • Real Time Control Diagrams – Circular Queues – Message Queues – Health Monitor – Event Flags • Examples ENTC-489 Embedded Real Time Software Development
Control Diagrams ENTC-489 Embedded Real Time Software Development
Symbols • Semaphores & Mutexes • Mailboxes and Message Queues ENTC-489 Embedded Real Time Software Development
Symbols • Timers and Event Flags • Tasks and Functions ENTC-489 Embedded Real Time Software Development
Symbols • Hardware • Global Variables ENTC-489 Embedded Real Time Software Development
Example 1 – Serial Port ENTC-489 Embedded Real Time Software Development
Example 1 – Serial Port • Characteristics – Received characters • When a character is received it is placed in a circular queue • If the queue is full the incoming character is lost • Counting semaphore indicates a character has been added to the queue • Interface gets_with_pend(), getc_with_pend() – Transmitted characters • Characters to be transmitted are placed in a circular queue • If there is no room in the queue, the character is dropped • Interface functions check for space in buffer, use timer delay before checking again if inadequate space • Interface puts_with_pend(), putc_with_pend() ENTC-489 Embedded Real Time Software Development
Serial Port Control Diagram ENTC-489 Embedded Real Time Software Development
Circular Queues (put) Note: Always leaves on entry empty ENTC-489 Embedded Real Time Software Development
Circular Queues (get) ENTC-489 Embedded Real Time Software Development
Example 2 - Logger ENTC-489 Embedded Real Time Software Development
Example 2 - Logger • Logger Characteristics – Tasks send information to be logged via send_sensors_to_log() or send_error_to_log() – Task waits for data to log, then sends to both the serial port and the EEPROM – Messages may come more rapidly than they can be written to the serial port or EEPROM – Most of the time this task does nothing ENTC-489 Embedded Real Time Software Development
Logger Control Diagram ENTC-489 Embedded Real Time Software Development
Logger Message Queue Operation ENTC-489 Embedded Real Time Software Development
Logger Task Flow Chart ENTC-489 Embedded Real Time Software Development
EEPROM Operation • All Operations times or on the order of 1 m. S ENTC-489 Embedded Real Time Software Development
EEPROM Storage ENTC-489 Embedded Real Time Software Development
Example 2 - Health ENTC-489 Embedded Real Time Software Development
Health Task Warning/Cautions • If you plan to try and restart tasks (as shown today) – If a task allocated memory and you kill the task, that memory is lost forever – If a task created a resource (Semaphores, Message Queues, etc) these will need to be deleted and recreated – In general, it is generally best to do a hardware reset. ENTC-489 Embedded Real Time Software Development
Health Task Control Diagram Global Variable Check in • Advantages – Supports short watchdog timer values best – Allows tasks to set their own WDT times ENTC-489 Embedded Real Time Software Development
Global Variable Check In Flow Chart ENTC-489 Embedded Real Time Software Development
Health Task Control Diagram Event Flag Check in • Advantages – Health task uses less CPU time ENTC-489 Embedded Real Time Software Development
Event Flag Check in Flow Chart ENTC-489 Embedded Real Time Software Development
Capstone Example • Monitor critical information – Compass – Acceleration – Gyroscope • Monitor non-critical information – GPS Position – Battery information (current, voltage, power) • SPI Input from controlling device – PWM Values • SPI Output to controlling device – Monitored data • PWM – Motors – Camera gimble • SPI RTS/CTS Functionality ENTC-489 Embedded Real Time Software Development
UAV Example Program • Serial Port has two modes – SP 1 – Sends XY location to serial port every 5 seconds – SP 2 – (default) Can receive commands from serial port • “Dump” dumps the logged information • • RGB LED, solid red if Z axis deviates 5 degrees from vertical, otherwise, blinking green Accelerometer – Must be read often (100 Hz or faster) to compute current XY and tilt • EEPROM Logging – – – • xy position of darkest location and light level xy position of brightest location and light level Latest xy position, every 5 seconds Logging disabled in SP 2 Yellow LED on for 1 second when a higher or lower light level is logged. Switch montioring – Debounce switches – SW 1 Clears the XY location and log information and puts unit in SP 1 mode – SW 2 Puts unit in SP 2 mode, stops logging ENTC-489 Embedded Real Time Software Development
- Slides: 26