OBIOPulseTrainOutput (FB)

FUNCTION_BLOCK OBIOPulseTrainOutput EXTENDS OBIOBaseCounter

Access the pulsetrain output functionality for AC500 eco CPU.

The PTO supports clockwise/counterclockwise or pulse/direction outputs with a maximum frequency of 200kHz.
precondition

the respective channel is configured as PTO channel.

2 binary outputs are used for 1 PTO channel, up to 2 PTO channels are possible.

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. A falling edge (Enable = FALSE) aborts the operation. During Aborting the Busy is still TRUE. Afterward all outputs are reset.

AbbLConCA

Output

Busy

BOOL

FALSE

Operation is running (while output Error is FALSE)

AbbLConCA

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.

AbbLConCA

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

Input

Start

BOOL

Start pulses and initialize counters on rising edge (if NumberOfPulses>0 is used)

Halt

BOOL

Halt pulses, counter be preserved

CwCCw

BOOL

if true, Clockwise/Counterclockwise, else Pulse/Direction mode, can be changed with Start=FALSE

Invert

BOOL

Invert the moving and counting direction

Direction

BOOL

direction to be used for the next movement, can be changed with Start=FALSE

EnableFinesteps

BOOL

in case the frequency value is changed, a 100us update to reach the target frequency is enabled

Frequency

LREAL

frequency min = (30 Hz or MaxFrequency/655) / max = 200 kHz. The input can be changed any time. With Frequency=0, the pulses will be stopped. Any value >0 will result in minimum value to be used.

NumberOfPulses

UDINT

number of pulses, just values >=0 allowed, >0 means: issue a certain NumberOfPulses after rising edge of Start, =0 means: issue a endless number of pulses

MaxFrequency

UDINT

200000

[Hz] max allowed value = 200kHz. Deviation with max frequency is 1%, slowest possible frequency is MaxFrequency/655, deviation for slowest frequency is 0.002%,, new value just used with Enable=FALSE

CycleTime

LREAL

1

Cycle of plc task time in ms, just used when EnableFinesteps=TRUE, , new value just used with Enable=FALSE