| Stateflow User's Guide | ![]() |
Adding a Sensor Event
To take advantage of sensors monitoring a physical plant, you need to check the sensor value at regular intervals. Proper control of a physical plant can be maintained only if a sensor measurement reports at regular intervals. For example, a controlling application might need to monitor the temperature or pressure of a device every second. If it waits for an hour before the next measurement is taken, undesired consequences can result.
You can simulate a sensor reading in Simulink with a regularly occurring sensor event and sensor data representing the value reported by the sensor. In Simulink, you use a regularly changing source to output a trigger event for determining times during which you read the sensor value.
Use a sine wave source in Simulink to add a sensor event to trigger a Stateflow block in the following procedure:
SFcontrol2 you save at the end of Modifying Output Data with Actions and save it as SFcontrol3.
temp_event on port 3 with the scope Input from Simulink, and a Rising trigger type.
temp_event does not appear in the Simulink model because all input events are grouped into the trigger port at the top of the Controller block.
2*pi.
temp_event is a rising edge trigger, it is triggered (broadcast) every time its input signal crosses zero while rising. Because the Sine Wave block now outputs a complete sine wave every second, temp_event is broadcast to the Stateflow diagram every second, as shown.
| Adding a Sensor to the Model | Adding Sensor Data | ![]() |
© 1994-2005 The MathWorks, Inc.