OBIOFreqOut (FB)

FUNCTION_BLOCK OBIOFreqOut EXTENDS AbbLConCA

Access the PWM functionality for AC500 eco CPU and issue an adjustable frequency

precondition

the respective channel is configured as PWM channel.

Up to 8 PWM channel are possible. The max possible frequency is determined by hardware delay times.
Maximum possible frequency for channel 0..3 is 5kHz.
Maximum possible frequency for channel 4..7 is 100 kHz. Recommended is to use <50kHz
  • The block accepts Frequency in Hz. The frequency will be measured and adjusted, so that the average value meets the correct frequency, but single pulses can be longer or shorter.

  • The block counts the issued pulses. (rising edges are counted)

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, 0,1,2,3,4,5,6,7

Frequency

LREAL

[Hz] 0,05Hz..100kHz to switch the binary output on/off

Output

ErrorID

Error_ID

0

Error code

Counter

UDINT

number of pulses which were already issued, 32bit value counting modulo 2EXP32