Block that reads the value of pulses from an encoder according to a chosen type of reading, displaying to the user his current position in revolutions and the speed in RPM.
Ladder Representation

Block Structure
Variable Type |
Name |
Data Type |
Description |
VAR_INPUT |
EN |
BOOL |
Block enabling |
SOURCE# |
BYTE |
Counting source |
|
PPR |
WORD |
Number of pulses corresponding to a turn |
|
FILTER |
REAL |
Time constant of the input filter |
|
VAR_OUTPUT |
ENO |
BOOL |
Output enabling |
SPEED |
REAL |
Speed in RPM |
|
POSITION |
REAL |
Current position of the encoder, in revolutions |
|
VAR |
READENC4_INST_0 |
READENC4 |
Instance of access to block structure |
Operation
When this block has a TRUE value in EN, it gets the number of encoder pulses counted since energization of the PLC300 as selected on SOURCE #, and calculates the number of absolute revolutions through the PPR argument, inserting the result in POSITION. The value of SPEED is calculated by means of an internal time base of the block. Further, the block allows filtering of the signal with an output filter determined by FILTER.
When EN has FALSE value, POSITION and SPEED remain unchanged.
The ENO value forwards to the next Ladder block the EN value after the operation is completed.
Compatibility
Device |
Version |
PLC300 |
2.10 or higher |
Block Flowchart

Example in Ladder

The example above when identifying a leading edge on DI1, gets the number of pulses of the encoder connected in quadrature conformation in the fast inputs since energization equipment. PULSES_IN_TURN is the value of pulses to complete a turn. TURNS stores the value of the pulses interpreted as revolutions, according PULSES_IN_TURN, and SPEED stores the current speed of the encoder. 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 PULSES_IN_TURN : WORD; TAU_FILTER : REAL; SPEED : REAL; TURNS : REAL; READENC4_INST_0 : FB_READENC4; END_VAR
READENC4_INST_0.EN := DI1; READENC4_INST_0(Source:=1, PPR:=PULSES_IN_TURN, FILTER:=TAU_FILTER); SPEED := READENC4_INST_0.SPEED; TURNS := READENC4_INST_0.POSITION; DO1 := READENC4_INST_0.ENO;
|
|---|