PWM (pulse width modulation)

The PWM instruction turns the PWM output for a configured PWM channel ON or OFF.
This instruction block is used with L20E controllers and supports one PWM channel using the embedded output channel 6.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E controllers.
PWM
PWM
PWM
PWM
PWM parameters
Parameter
Parameter Type
Data Type
Description
Enable
Input
BOOL
Instruction block enable. This level is instruction block triggered.
  • TRUE: Update Sts. PWM is made active or inactive depending on the On input parameter and valid configuration.
  • FALSE: Sts is only updated. PWM state (active or inactive) is not affected.
On
Input
BOOL
Turns the PWM output ON/Active or OFF/Inactive.
  • TRUE: PWM output is active or continues to be active with latest valid configuration. Output LED is ON when PWM is active, even if duty cycle is set to 0%.
  • FALSE: PWM output is inactive if configuration is also valid.
Freq
Input
UDINT
Pulse Frequency.
  • 1–100000 Hz
DutyCycle
Input
UINT
Pulse Duty Cycle.
  • 0–1000 (0%–100%)
ChType
Input
UINT
Channel Type.
  • 0: Embedded
  • 1: Plug-in
  • 2: Expansion
ChSlot
Input
UINT
Channel Slot.
  • 0: Embedded
ChNum
Input
UINT
Channel Number.
  • 0: PWM CH0
ENO
Output
BOOL
Enable output.
Applies only to ladder diagram programs.
Sts
Output
UINT
PWM status codes:
  • 00: Function block not enabled (no operation.)
  • 01: PWM configuration successful
  • 02: Invalid duty cycle
  • 03: Invalid Frequency
  • 04: Invalid Channel Type
  • 05: Invalid Channel Slot
  • 06: Invalid Channel Number
  • 07: Invalid Catalog. PWM feature is not supported in the catalog being used

PWM examples

PWM function block diagram example
PWM function block diagram example
PWM ladder diagram example
PWM ladder diagram example
PWM structured text example
PWM structured text example
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal