Name :PWM output

Symbol:PWM

Illustrate:

    With this function block, you can control the pulse to output continuously at a certain frequency and a certain station-control ratio, and this function block does not realize the acceleration and deceleration of the frequency, nor does it have an emergency stop, and only outputs at the specified frequency. 

Image:

Parameter:

Parameter Statement IN/OUT Parameter role Illustrate Default value
OUTPORT UDINT IN PWM output port 0-7
not
ENABLE BOOL IN The function block is enabled TRUE If it is enabled, the function block will start running (the cycle time and duty cycle can be dynamically adjusted during operation), and if FALSE is disabled, the function block will stop running
not
CYCLE UDINT IN PWM cycles:Unit us 5-1000000 (200KHz - 1Hz);0--Use the default value
Yes/10000
DUTYCYCLE UINT IN Duty cycle parameter 0-65535:Duty cycle = Duty cycle parameter/65535*100%
not
DONE BOOL OUT Execution success flag TRUE:The function block is executed successfully;FALSE:The function block is not executed
Yes/FALSE
BUSY BOOL OUT PWM output flag TRUE:PWM output
Yes/FALSE
ERROR BOOL OUT Error flags TRUE:There was an error with the function block call
Yes/FALSE
ERRORID DINT OUT Error codes 0:normal;other:Error code value
Yes/0

Error codes:

Error codes Illustrate
0
inerrancy
1
Invalid pulse port
2
The pulse port is busy/pre>
12
PWM cycle error

Example:

LD:

ST:



Interpretation:

   OUTPORT IS 0, WHICH MEANS THAT PORT 0 IS USED FOR OUTPUT.
   IF ENABLE IS TRUE, PWM IS ENABLED, AND THE FUNCTION BLOCK STARTS TO OUTPUT PWM WAVEFORMS.
   CYCLE is 100, which means that the cycle time of the PWM waveform to be output is 100us (10KHz);
   DUTYCYCLE IS 32768, WHICH MEANS THAT THE DUTY CYCLE IS 32768/65535*100%, WHICH IS ABOUT 50%;
   If DoneOut is TRUE, the PWM output is executed.
   If BusyOut is TRUE, port 0 is outputting PWM.
   If ErrorOut is set to TRUE, the function block is faulty and the error code is ErrorIDOut.