Programming the Standard Encoder
A Standard Encoder is always managed by an Encoder_LMC058 function block.
Adding a StandardEncoder Function Block
Step |
Action |
---|---|
1 |
Select the Libraries tab in the Software Catalog and click Libraries. Select Controller > LMC058 > LMC058 Expert IO > ENCODER > ENCODER_LMC058 in the list, drag-and-drop the item onto the POU window. |
2 |
Type the Encoder_LMC058 instance name or select the function block instance by clicking on: ![]()
Using the input assistant, the Encoder_LMC058 instance can be selected at the following path: Global Variables > PLC Logic > IoConfig_Globals. |
The following table describes the input variables:
Inputs |
Type |
Comment |
---|---|---|
EN_Enable |
BOOL |
When EN input is configured authorizes the encoder enable via the input. |
EN_Preset |
BOOL |
When Z or REF input are configured authorizes the counter preset via the inputs. |
EN_Cap |
BOOL |
When at least one CAP input is configured authorizes the capture function via the inputs. |
EN_Compare |
BOOL |
TRUE = enables the comparator operation using Thresholds 0, 1, 2, 3: obasic comparison (TH0, TH1, TH2, TH3 output bits) oreflex (Reflex0, Reflex1 output bits) oevents (to trigger external tasks on threshold crossing) |
EN_Out0 |
BOOL |
TRUE = authorizes physical output Output0 to echo the Reflex0 value. |
EN_Out1 |
BOOL |
TRUE = authorizes physical output Output1 to echo the Reflex1 value. |
F_Enable |
BOOL |
Forces the Enable condition. |
F_Preset |
BOOL |
Forces the Preset condition. |
F_Out0 |
BOOL |
TRUE = forces physical output Output0 to 1 (if Reflex0 is configured). |
F_Out1 |
BOOL |
TRUE = forces physical output Output1 to 1 (if Reflex1 is configured). |
ACK_Overflow |
BOOL |
On rising edge, resets Overflow_Flag |
ACK_Preset |
BOOL |
On rising edge, resets Preset_Flag. |
ACK_Cap0 |
BOOL |
On rising edge, resets Cap0_Flag. |
ACK_Cap1 |
BOOL |
On rising edge, resets Cap1_Flag. |
SuspendCompare |
BOOL |
TRUE = the comparator operation results are frozen: oTH0, TH1, TH2, TH3, Reflex0, Reflex1 output bits maintain their last value. oPhysical outputs Output0 and Output1 maintain their last value. oEvents are masked. EN_Compare, EN_Reflex0, EN_Reflex1, F_Out0, F_Out1 remain operational while SupendCompare is set. |
The following table describes the output variables:
Outputs |
Type |
Comment |
---|---|---|
ENC_REF |
Reference to the Standard Encoder. To be used with the EXPERT_REF_IN input of Administrative Function block |
|
Encoder_Err |
BOOL |
TRUE = indicates that an error was detected. Use the EXPERTGetDiag function block to get more information about this detected error. |
Validity |
BOOL |
TRUE = indicates that the output values on the function block are valid. TRUE after the first preset |
TH0 |
BOOL |
Set to 1 when CurrentValue > Threshold 0 (if configured). |
TH1 |
BOOL |
Set to 1 when CurrentValue > Threshold 1 (if configured). |
TH2 |
BOOL |
Set to 1 when CurrentValue > Threshold 2 (if configured). |
TH3 |
BOOL |
Set to 1 when CurrentValue > Threshold 3 (if configured). |
Overflow_Flag |
BOOL |
Set to 1 when the encoder rolls over its limits. |
Preset_Flag |
BOOL |
Set to 1 after the encoder presets. |
Cap0_Flag |
BOOL |
Set to 1 when a new capture value is stored in the Capture register. This flag must be reset before a new capture is allowed. |
Cap1_Flag |
BOOL |
Set to 1 when a new capture value is stored in the Capture register. This flag must be reset before a new capture is allowed. |
Reflex0 |
BOOL |
|
Reflex1 |
BOOL |
|
Out0 |
BOOL |
|
Out1 |
BOOL |
|
Low_Limit |
BOOL |
Set to 1 when the encoder exceeds -2.147.483.648. Reset to 0 when encoder presets. |
High_Limit |
BOOL |
Set to 1 when the encoder exceeds +2.147.483.647. Reset to 0 when encoder presets |
EncoderValue |
DINT |
Current value of the encoder. |