Events Block - Package/Form
Description
The On Event block can be used to detect a condition and commence program activity.
When the condition changes from being false to being true then the list of blocks below the event will be performed. The event will not trigger again until the list has
completed and subsequently the signal has gone false before going to true again. Note that the event is edge triggered, not level triggered. The action occurs when
the expression changes from false to true but will not occur if the expression is initially true. All of the On Event Blocks expressions are in an internal list and are checked in sequence. If the expressions
do not contain any yields or other delays in their evaluation then the entire list is checked every controller sample period. If there are delays then the inspection frequency for all of the On Events is diminished.
Escapes
The On Event block does not generate any escapes.
Examples
This block list starts when a physical button is pushed. Motion is initiated and continues until the button is released.
Note that 25 millisecond "debounce" delays in the block list. Mechanical switches can physically bounce causing a connect, disconnect, connect sequence of electrical events.
The software runs much faster than that this mechanical effect so the debounce delays wait for the switch signal to become stable before further decisions about the signal are made.
The last delay block appears unnecessary since there is no block after. However this is important since switch bounce on the switch release might cause the list to start again.
Having a delay at the end insures the signal is stable before the On Event edge detector examines the signal again.
This block list provides an indication that motion is active.
The Move Is Finished expression contains an internal yield. Since there are two Move Is Finished expressions the inspection rate for detecting transitions will drop from 1 kHz (if the default sample rate is being used) to about 333 Hz.
This reduction could be avoided by using a non-yielding expression that provides the same information such as Profile Phase.
Related Topics
Named IO Is On
Autostart