FSM Lecture 12- Events and Signals

  • Post author:
  • Post category:Blog

 

Events and Signals

 

 

Events:

Events are incidents or a stimulus by which a state machine can be triggered; Incidents are abstracted as events.

In state machine events cause transitions( external or internal )

Incidents in the operation of a microwave oven

  1. Opening door; Heater off , lights on
  2. Closing door; lights off
  3. Set timer; manage time
  4. Start ; heater ON 

In this example, you open the door. Opening of the door is an incident; And when that incident happens, an event will be generated, and it will be transported to the firmware inside the oven and the firmware as per its current state may take some actions, such as, it may turn the Heater off, turn the lights on, etc. 

And the closing of the door is another incident, and it may have its associated set of actions. 

Set the timer; You use the buttons given in the oven’s control panel to set the timer, start the oven operation, etc.

All these are events and events may cause transitions of the state machine diagram and its associated set of actions.

 

An event usually has 2 components

  1. Signal
  2. One or more associated values or parameters (optional)

 

Events
Figure 1. Example of event and signals

 

Examples

You can see Figure 1, we have got three buttons. ‘Plus,’ ‘minus,’ and the third button is ‘start’ or ‘pause.’

Pressing these buttons generates events. When you press the plus button, it generates one event.

And that event has two components. One is a signal component. So, pressing the plus button generates the event whose signal is INC_TIME. It’s just a name—the name you have chosen as per your convenience. This event signifies by its signal attribute that the user has pressed a button which increases the time. And the signal doesn’t have any associated signal values or parameters. That’s fine because that is an optional one.

And similarly, if you press the minus button, it generates another event whose signal name is ‘DEC_TIME.’ In this case, this event also doesn’t require any parameters.

 

Events
Figure 2. Example of event and signals

 

Or you can write the events like this(Figure 2). It doesn’t matter which button the user presses, either the plus button or minus button;  You generate the event whose signal name is ‘TIME_CHANGE.’

And then use the parameter, ‘direction,’ to indicate which button really has been pressed by the user. So, you can create an enumeration, and you can distinguish by using the values UP or DOWN. 

This event signifies by its signal attribute that the user has pressed a button that changes the time. 

The signal has an associated parameter that encodes whether the user has pressed a button that increases time(UP) or decreases time(DOWN). 

 

 Calculator example
Figure 3. Calculator example

 

Let’s take another example of a Calculator.

The calculator has got its number pad, and on the number pad, it has got ten digits (0 to 9), a couple of operators, and the result button, etc. 

How do you encode the pressing of any digit? 

You can generate only one event, whose signal name is DIGI_0_9, and the parameter signifies which digit has been pressed by the user.

Instead of creating one event for each digit, you can collectively generate one event and use the parameter component of the event to distinguish between which digit has been pressed by the user, as you can see Figure 3.

 

Calculator example
Figure 4. Calculator example

 

Similarly, you can keep one event to signal the pressing of the operator’s button(Figure 4). Like this in programming, you can use ‘structures’ or ‘enums’ to model your application’s events. 

 

FastBit Embedded Brain Academy Courses

 Click here: https://fastbitlab.com/course1

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.