710 likes | 938 Views
E N D
2. Real-Time Embedded Systems Design Process
3. Agenda Monitoring and control systems
Control systems
Data acquisition systems
State machines
4. Monitoring and control systems Important class of real-time systems
Continuously check sensors and take actions depending on sensor values
Monitoring systems examine sensors and report their results
Control systems take sensor values and control hardware actuators
5. Burglar alarm system A system is required to monitor sensors on doors and windows to detect the presence of intruders in a building
When a sensor indicates a break-in, the system switches on lights around the area and calls police automatically
The system should include provision for operation without a mains power supply
6. Burglar alarm system Sensors
Movement detectors, window sensors, door sensors.
50 window sensors, 30 door sensors and 200 movement detectors
Voltage drop sensor
Actions
When an intruder is detected, police are called automatically.
Lights are switched on in rooms with active sensors.
An audible alarm is switched on.
The system switches automatically to backup power when a voltage drop is detected.
7. The R-T system design process 1. Identify stimuli and associated responses
2. Define the timing constraints associated with each stimulus and response
3. Allocate system functions to concurrent processes
4. Design algorithms for stimulus processing and response generation
5. Design a scheduling system which ensures that processes will always be scheduled to meet their deadlines
8. Stimuli to be processed Power failure
Generated aperiodically by a circuit monitor. When received, the system must switch to backup power within 50 ms
Intruder alarm
Stimulus generated by system sensors. Response is to call the police, switch on building lights and the audible alarm
9. Timing requirements
10. Process architecture
11. Building_monitor proces1
12. Building_monitor process 2
13. Control systems A burglar alarm system is primarily a monitoring system
It collects data from sensors but no real-time actuator control
Control systems are similar but, in response to sensor values, the system sends control signals to actuators
An example of a monitoring and control system is a system which monitors temperature and switches heaters on and off
14. A temperature control system
15. Data acquisition systems Collect data from sensors for subsequent processing and analysis
Data collection processes and processing processes may have different periods and deadlines.
Data collection may be faster than processing e.g. collecting information about an explosion
Circular or ring buffers are a mechanism for smoothing speed differences
16. Reactor data collection A system collects data from a set of sensors monitoring the neutron flux from a nuclear reactor
Flux data is placed in a ring buffer for later processing
The ring buffer is itself implemented as a concurrent process so that the collection and processing processes may be synchronized
17. Reactor flux monitoring
18. A ring buffer
19. Mutual exclusion Producer processes collect data and add it to the buffer
Consumer processes take data from the buffer and make elements available
Producer and consumer processes must be mutually excluded from accessing the same element
The buffer must stop producer processes adding information to a full buffer and consumer processes trying to take information from an empty buffer
20. Java implementation of a ring buffer 1
21. Java implementation of a ring buffer 2
24. Finite state machines
25. Finite State Machines(FSMs) Widely used specification technique
Used to specify system behavior in response to events
Both output and next state can be determined solely on the basis of understanding the current state and the event that caused the transition
H/W engineers have been using FSM for years
31. State Machines Models how a system responds differently to events over time
33. States
35. Finite State Machines State
the memory of previous events
Events
inputs to a system
Actions
output in some form
mechanical, electrical or software event
36. Finite State Machines State
the memory of previous events
Events
inputs to a system
Actions
output in some form
mechanical, electrical or software event
37. Coke Machine Events
coin insertion
Actions
coke delivery
coins returned
State
the memory of how much money has been deposited
38. FSM Diagram
39. FSM
40. ScenarioQuarters Only, 75 cents Customer
enter quarter
Customer
enter quarter
Customer
enter quarter
Coke Machine
deliver coke
41. Enumerate Events & Actions
43. State Transition Table
48. Transition Table State E1 E2
A B
B C A/coin return
C A/coke A/coin return
51. Telephone System FSMLocal 4-digit exchange
55. From the article “Embedded State Machine Implementation” Martin Gomez
Embedded systems programming
56. Embedded state machines Many embedded software applications are natural candidates for mechanization as a state machine
Program that must sequence a series of actions, or handle inputs differently depending on what mode its in
Soft key interfaces to comm protocols
57. State machines An algorithm that can be in one of a small number of states
Mealey
Output a function of present state and output
Moore
Function only of state
58. Example state machine
59. State machine approach Learn what the user wants
Sketch the state transition diagram
Code the skeleton of the state machine, without filling in the details of the transition actions
Make sure the transitions work properly
Flesh out the transition details
Test
60. Another example Program that controls the retraction and extension of an airplane’s landing gear
Hardware
Nose gear
Left main gear
Right main gear
Hydraulically actuated
61. What does the user want? “don’t retract the landing gear if the airplane is on the ground”
Is it ok to retract the landing gear the instant the airplane leaves the ground?
Use a white board or sequence enumeration!
<event that caused transition>/<output as a result of the transition>
62. First implementation – only does what the user asked for
63. Some things to keep in mind Computers are very fast compared to mechanical hardware – you may have to wait
Mechanical engineer may not know as much about computers!
What happens if parts break?
64. A better implementation
65. Implementation
69. RaisingGear() function
70. Testing Test plan almost writes itself
Avoid hidden states
Number of transitions is measure of systems complexity
Use print statement to output current state
Be careful when connecting to actual hardware