R_TRIG
Function Block Name |
R_TRIG |
---|---|
Description |
R_TRIG is an edge detection function block. It detects a change in the state of a Boolean input. The output from an R_TRIG function block produces a pulse when True. |
Arguments |
CLK {BOOL} When the CLK input changes from False to True, the Q output changes to True for one execution of the function block. The Q output then returns to being False until the CLK input changes from False to True again. |
Returns |
Q {BOOL} The Q output changes state according to the CLK input. When the CLK input changes from False to True, the Q output becomes True. It remains True for one execution of the R_TRIG function block and then returns to being False. |
Example - R_TRIG Function Block Diagram:
In this example, the CLK input comes from a digital point named 'PressureAlert'. The CLK input changes from False to True causing the Q output to change from False to True. The Q output remains True for one execution of the function block and then returns to being False.
Example - R_TRIG ST Program:
The syntax for entering an R_TRIG function block in an ST program is:
- VAR
- CLK_IN AT %M(.Digital Point1): BOOL;
- END_VAR
- VAR
- Q_OUT: BOOL;
- FB : R_TRIG;
- END_VAR
- FB( CLK := CLK_IN, Q => Q_OUT);
The direct variable is declared in a separate VAR block to the indirect variables. The input and output variables for the R_TRIG function block are also allocated names that are different to the names of the inputs and outputs in the function block as this makes it easier to understand the ST program (for example, the CLK input variable is named CLK_IN). In this example, the direct variable for the CLK input (CLK_IN) references a digital point (the Boolean value for the input is taken from a digital point in the database).
In the second VAR block, the internal variables are declared, including an FB variable that defines the type of function block.
The ST Program can then reference the variables as inputs and outputs for the function block:
- FB( CLK := CLK_IN, Q => Q_OUT);
So, the ST Program uses the CLK_IN input as the CLK input for the FB function block (which has already been declared as an R_TRIG type). For the Q output, it uses the Q_OUT variable.