Back to all tutorials

vBuilder reference

Pulse-Width Modulation

Configure PWM period, output on-time, continuous operation, and single pulses in vBuilder.

Tutorial overview

Pulse-Width Modulation

Configure PWM period, output on-time, continuous operation, and single pulses in vBuilder.

PWM fundamentals

Control output on-time within a repeating period.

Pulse-width modulation is used for servo-valve positioning, laser pulses, motion control, light intensity, and other applications. A PWM signal has a period and an output ON time, or duty cycle, within that period. A single-pulse mode supports applications that need one timed output pulse.

For example, a servo valve might use a 20-millisecond period. Its manufacturer could specify a 1-millisecond pulse for fully closed and a 3-millisecond pulse for fully open. Intermediate positions use proportional ON times between those limits.

Pulse-width modulation period and on-time diagram
Velocio digital outputs are generally sinking transistor outputs, so an active output pulls the signal low.
Continuous and single-pulse PWM comparison
Continuous PWM repeats each period; single-pulse PWM runs once and must be started again by the program.

Where PWM can run

PWM can use a digital output physically located on the PLC module that contains the application program. Ace and Branch main-program outputs can generate PWM. A Branch Expansion unit can generate PWM from its own embedded program, but not when it is used only as expansion I/O. Each active output has its own ON time, while all PWM outputs on the PLC share one period.

Set the period

Choose Set Period in the PWM block and enter a ui16 value or variable from 100 through 65,535 microseconds. Below 1,000 microseconds, only the output with the shortest ON time is active. At 1,000 microseconds or above, all configured PWM outputs can be active.

vBuilder PWM Set Period dialog

Start PWM

Choose the physical digital output and a ui16 ON-time value from 0 through 65,535. A subroutine must use a reference to the PLC output. Continuous mode repeats until a Stop PWM block runs. Single Pulse produces one pulse during the next period, then returns the output to its program state. Re-running the block updates a changing ON time on the next period.

vBuilder PWM Start dialog

Stop PWM

Select Stop and choose the output tag. In a subroutine, use the reference associated with that physical output.

vBuilder PWM Stop dialog

Keep building

Continue with another practical example.

Browse the full tutorial library or download vBuilder to put the example to work.