Block that continuously reads the pulse value of an encoder according to a type of reading chosen.
Ladder Representation
![]()
Block Structure
Variable Type |
Name |
Data Type |
Description |
VAR_INPUT |
EN |
BOOL |
Block enabling |
Source# |
BYTE |
Counting source |
|
VAR_OUTPUT |
ENO |
BOOL |
Output enabling |
Value |
DINT DWORD UDINT |
Counting value |
|
VAR |
READENC_INST_0 |
READENC |
Instance of access to block structure |
Operation
When this block has a TRUE value in EN, it gets the number of pulses counted in the encoder, as selected in Source #, and transfers them to Value. At each leading edge, Value is reset to zero.
When EN has FALSE value, Value remains unchanged.
The ENO value forwards to the next Ladder block the EN value after the operation is completed.
Block Flowchart

Example in Ladder

The above example, when identifying a leading edge on DI1, starts counting the number of pulses in the encoder connected in quadrature conformation AB, storing the value in VALUE. The block ends with success, ENO output is activated.
Example in ST
The example below displays the instructions for applying the example above in the ST language.
VAR VALUE : UDINT; READENC_INST_0 : FB_READENC; END_VAR
READENC_INST_0.EN := DI1; READENC_INST_0(Source:=0); VALUE := READENC_INST_0.Value; DO1 := READENC_INST_0.ENO;
|
|---|