Encoder_LMC058: Encoder Function Block

Function Description

This function block controls a Encoder type counter.

The function block instance name must match the name defined by the configuration.

Graphical Representation

G-SE-0002897.1.gif-high.gif

 

 

IL and ST Representation

To see the general representation in IL or ST language, refer to Function and Function Block Representation.

I/O Variables Description

This table describes the input variables:

Inputs

Type

Comment

EN_Enable

BOOL

TRUE = authorizes the encoder enable via the Enable input (if configured).

EN_Preset

BOOL

TRUE = authorizes the encoder synchronization and starts via the Sync input (if configured).

EN_Cap

BOOL

TRUE = enables the Capture input (if configured).

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 = enables Output0 to echo the Reflex0 value (if configured, on DM72F modules).

EN_Out1

BOOL

TRUE = enables Output1 to echo the Reflex1 value (if configured, on DM72F modules).

F_Enable

BOOL

Forces the Enable condition.

In case of a detected SSI error setting the F_Enable input to 0 acknowledges the error.

F_Preset

BOOL

Forces the Preset condition.

F_Out0

BOOL

TRUE = forces Output0 to 1 (if Reflex0 is configured).

F_Out1

BOOL

TRUE = forces Output1 to 1 (if Reflex1 is configured).

ACK_Overflow

BOOL

On rising edge, resets the 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.

oHardware Outputs 0, 1 maintain their last value.

oEvents are masked. EN_Compare, EN_Reflex0, EN_Reflex1, F_Out0, F_Out1 remain operational while SupendCompare is set.

This table describes the output variables:

Outputs

Type

Comment

ENC_REF

EXPERT_REF

Reference to the Encoder.

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.

TH0

BOOL

Set to 1 when CurrentValue > Threshold 0 (if configured).

Only active when EN_Compare is set.

TH1

BOOL

Set to 1 when CurrentValue > Threshold 1 (if configured).

Only active when EN_Compare is set.

TH2

BOOL

Set to 1 when CurrentValue > Threshold 2 (if configured).

Only active when EN_Compare is set.

TH3

BOOL

Set to 1 when CurrentValue > Threshold 3 (if configured).

Only active when EN_Compare is set.

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

State of Reflex0 (if configured).

Only active when EN_Compare is set.

Reflex1

BOOL

State of Reflex1 (if configured).

Only active when EN_Compare is set.

Out0

BOOL

Indicates the state of Output0.

Out1

BOOL

Indicates the state of Output1.

Low_Limit

BOOL

Only managed for incremental linear in Lock on limit. Set to 1 when the encoder exceeds - 2.147.483.648. Resets to 0 when encoder presets or resets.

High_Limit

BOOL

Only managed for incremental linear in Lock on limit. Set to 1 when the encoder exceeds + 2.147.483.648. Resets to 0 when encoder presets or resets.

EncoderValue

DINT

Current value of the Encoder.