SETPWM n, x, y
Purpose | To set channel #n of the PLC's Pulse-Width Modulation (PWM) output with duty cycle represented by (x/100 %) and at a frequency (in Hz) given by parameter y. n must range between 1 and 8. Once set, the PWM channel will latch the set value until the next SETPWM statement on the same channel is executed. x should range between 0 and 10000. If x is more than 10000, the duty cycle will be set to 100% |
Examples | SETPWM 1,4995,2000 |
Comments: | PWM channel #1 will be set to operate at 49.95% duty cycle for PWM that can resolve up to 0.01%. The actual resolution will depend on the PLC's PWM resolution. The PWM frequency is set to 2000 Hz or nearest.For a 10-bit PWM the best resolution is about 1/1024 = 0.1 %. This means that in the above example the PWM will be rounded to 50%. Please check the target PLC's manual for the actual resolution. |