OBIOForwardCounter (FB)

FUNCTION_BLOCK OBIOForwardCounter EXTENDS OBIOBaseCounter

Used for forward counter on eco V3 PLC

precondition

the respective hardware input channel is configured as forward counter.

Up to 4 counter are possible, FB input channel=0..3 for hardware inputs 4..7

Note

This block should just be called once per cycle otherwise inconsistent values could be send to PRU, if send twice in short time.

InOut:

Scope

Name

Type

Initial

Comment

Inherited from

Input

Enable

BOOL

FALSE

A rising edge (Enable = TRUE) starts the operation, the output Busy goes to TRUE. All other inputs are read and considered continuously. Execution will continue forever until a falling edge (Enable = FALSE) aborts the operation. During Aborting the Busy is still TRUE. Afterward all outputs are reset.

AbbLConC3

Output

Busy

BOOL

FALSE

Operation is running (while output Error is FALSE)

AbbLConC3

Error

BOOL

FALSE

Operation is stopped with error (while output Busy is FALSE). This output is TRUE for at least one cycle or until Enable is set to FALSE. The output ErrorID gives more details about the error.

AbbLConC3

Input

Channel

BYTE

0

Channel number, for encoder 0/1, for forward counter 0..3, for PulseTrainOutput 0/1

OBIOBaseCounter

Set

BOOL

Sets counter value to CounterValueSet on rising edge

OBIOBaseCounter

CounterValueSet

UDINT

Counter value to set

OBIOBaseCounter

EnableLimit

BOOL

Use limits, FALSE: counts ‘endless’, TRUE: counts from 0 to LimitValueMax, starts again with 0 on overflow. A new value will be used with rising edge on Enable

OBIOBaseCounter

LimitValueMax

UDINT

0

Upper limit, will count from 0 to < LimitValueMax-1 (with EnableLimit=TRUE), so the range for counting is LimitValueMax. The value has to be set while CounterValue < LimitValueMax. A new value will be used with rising edge on Enable

OBIOBaseCounter

Output

ErrorID

Error_ID

0

Error code

OBIOBaseCounter

CounterValue

UDINT

Actual counter value

OBIOBaseCounter