Block that reads the value of pulses from an encoder according to a chosen type of reading, calculating differentials between calls to the block.
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 |
|
Delta |
DINT DWORD UDINT |
Difference between the previous counting and current counting |
Operation
When this block has a TRUE value in EN, it gets the number of pulses counted in the encoder since energizing of the PLC300, as selected in Source#, and transfers them to Value. The value of Delta is the difference between the pulses counted in this run and the previous run.
When EN has FALSE value, Value and Delta remain unchanged.
The ENO value forwards to the next Ladder block the EN value after the operation is completed.
Block Flowchart

Example in Ladder

The example above when identifying a leading edge on DI1, gets the number of pulses on input A since the energizing of the equipment, storing the value in VALUE. The difference between the current value and the value previously read is stored in DIFFERENCE. 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; DIFFERENCE : UDINT; END_VAR
DO1 := FB_READENC3( EN:=DI1, Source:=1, Value=>VALUE, Delta=>DIFFERENCE);
|
|---|