Programming the Standard Encoder

Overview

A Standard Encoder is always managed by an Encoder_LMC058 function block.

Adding a Standard Encoder 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:

G-SE-0005277.1.gif-high.gif

 

 

Using the input assistant, the Encoder_LMC058 instance can be selected at the following path: Global Variables > PLC Logic > IoConfig_Globals.

G-SE-0006157.1.gif-high.gif

 

 

I/O Variables Usage

The following table describes the input variables:

Inputs

Type

Comment

EN_Enable

BOOL

Not used.

EN_Preset

BOOL

Not used.

EN_Cap

BOOL

When at least one CAP input is configured, it 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

Not used.

EN_Out1

BOOL

Not used.

F_Enable

BOOL

Forces the Enable condition.

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

F_Preset

BOOL

Forces the Preset condition.

F_Out0

BOOL

Not used.

F_Out1

BOOL

Not used.

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

Not used.

The following table describes the output variables:

Outputs

Type

Comment

ENC_REF

EXPERT_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

State of Reflex0.

Reflex1

BOOL

State of Reflex1.

Out0

BOOL

Not relevant

Out1

BOOL

Not relevant

Low_Limit

BOOL

Not relevant

High_Limit

BOOL

Not relevant

EncoderValue

DINT

Current value of the encoder.

The value is not valid if an error is detected.