OBIOPwm (FB)ļ
FUNCTION_BLOCK OBIOPwm EXTENDS AbbLConC3
Access the PWM functionality for AC500 eco CPU.
- precondition
the respective channel is configured as PWM channel.
Note
the onboard ā12DI/6DO-R/2DCā (e.g. PM5052-R) will allow 2 PWM configuration with the 2DC. They are channel 6/7. This configuration will support OBIOPwm
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, or combine the OnTime/Offtime calculation with a feedback like closed-loop control.
the max allowed time for OnTime or OffTime is 10sec = 10*1000*1000 microseconds
The block accepts OnTime and OffTime in microseconds. The accuracy will be 2.5 us. Pulses will not be shorter, but can be 2.5 us longer.
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
EnableBOOLFALSE
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
BusyBOOLFALSE
Operation is running (while output Error is FALSE)
AbbLConC3
ErrorBOOLFALSE
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
ChannelBYTE0
Channel, 0,1,2,3,4,5,6,7
OnTimeUDINTtime in microseconds to switch the binary output on
OffTimeUDINTtime in microseconds to switch the binary output off
Output
ErrorID0
Error code
CounterUDINTnumber of pulses which were already issued, 32bit value counting modulo 2EXP32