Pulse Width Modulation

DCCWiki, a community DCC encyclopedia.
(Redirected from PWM)

Short Definition

Pulse width is modulated in a square wave for better control of energy (watts).

Pulse Width Modulation is a method used with microprocessors and microcontrollers for controlling an analog motor with digital circuits.

Pulse Width Modulation (PWM) allows better control of the motor. Rather than applying a pure direct current signal to the motor, a series of pulses is used instead. They can be at the maximum voltage, but are only on for a fraction of a second. Doing this repetitively will cause the motor be begin to turn, producing some torque. This will allow for slow speed operation in a more controlled manner. Simply applying a low voltage DC signal will not overcome the friction of the motor and gears, resulting in a jerky start, and very poor low speed operation.

By varying (or modulating) the pulse width and the frequency, slow speed operations are possible, and allow realistic operations in a yard.

The DCC decoder creates this signal to drive the motor. It is the same concept as the pulse power functions found on direct current power packs.

Technical Details

Waveforms representing low, medium and high speed outputs to the motor

Why Not Use Direct Current?

While Direct Current is the most efficient mode of driving a motor designed for it, this technique is not with suited for DCC decoder technology .

It is technically possible, but it would generate a lot of heat in the decoder, leading to a failure due to overheating. Provided the driver circuit doesn't shut down before it is damaged.

So, despite the advantages of direct current, the disadvantages are much greater.

Benefits of Pulse Width Modulation

  • Simplicity: The motor drive circuit is much simpler with PWM, with fewer parts needed to interface with the decoder's microcontroller.
  • Power Efficiency: The induction of the rotor's windings will average the current flow (Inductors resist the change of current.) The transistors have low impedance with a low voltage drop and power dissipation. A resistor dissipates a lot of power (I2R) as heat.
  • Speed Control: The motor will sees a low impedance current source, even as the source constantly switches between high and low voltage. The result is a motor which has higher torque. A series resistance will cause the motor to experience a very poor current source and it will easily to stall.
  • Control Circuit: For digital electronics (such as a microcontroller) it is very easy to switch voltages on or off using transistors or FETs. An analog output (either electronically or mechanically controlled) requires more components and increases power dissipation, wasted as heat. It will be more expensive in terms of electronics and power requirements.


The voltage available to the motor is a function of the track voltage.

Since the DCC signal combines both the power and the digital signal, it stays at a fixed level. For example, when set to HO a command station will put about 14V RMS onto the track. Now the decoder consumes energy, and a couple of volts are lost when the DCC signal is rectified for use with the motor controller.

If the track voltage is low, the motor will not get as much voltage, limiting top speed. It will also increase current consumption by the decoder. If you want to limit the top speed of the motor, use the V High CV.

The voltage applied to the motor is also of constant amplitude. Speed is controlled by the pulse width, which is adjusted using the V High to limit the maximum average voltage.

How Does it Work?

PWM is implemented by the decoder by switching the output to the motor on and off rapidly.

At a slow speed, full voltage may be applied to the motor for 20% of the time. The other 80%, it is off. This switching might be happening 1000 times a second. So for one millisecond, the power is on for 200 microseconds (uS), and off for 800 uS. The effective voltage being applied to the motor averages 20% of Vmax. If Vmax is 13V, the average would be 2.6V.

At mid speed, the voltage might be on for 500uS. At full speed, it might be 1mS on and 100uS off. Using Vmax at 13V, the motor would see a Vaverage of 6.5V.

Despite some CVs being named VStart, VMid, and VHigh there is no way to change the voltage output. Their names are not descriptive of what they really do. They allow you to set the output to start the then motor turning at step one, adjust the maximum speed, and tweak mid-range operation. This is done by adjusting the duty cycle of the output pulses. Which controls the current flow through the motor, not the voltage applied.

Back EMF and Sound

The PWM output is related to the BEMF, as the frequency will be altered by the BEMF values. This will also impact sound, as the decoder can use these values to create appropriate loading sounds for a steam or diesel engine.


Heat and Demagnetization

While it allows the decoder to run cooler, the motor will run a little hotter. It also may not have as much torque.

This was an issue when Pulse Power appeared many years ago. There were also concerns that the high frequency high voltage pulses would demagnetize the motor's field magnets. This was of particular concern in the early days of carrier control when there was concern about the high frequency carriers having the same effect. Modern alloys seem to have conquered that fear.


At certain frequencies or speeds, the motor and chassis may begin to resonate, making an annoying buzz. Increased noise can also be caused while in operation, changing in amplitude and frequency with the speed.

Modern decoders minimize this by offering variable frequencies, and many now use supersonic frequencies above what a human can hear. (Your dog may get very annoyed.) Higher frequencies plus the ability to modify them can also be used to tune the PWM to minimize any resonance. Much like the tone controls on your hi-fi let you adjust the sound to your room and your preferences.

Some decoders may even use a dynamically changing frequency to minimize any resonance and improve torque response.


Other than the previously mentioned heat issues, you get Back EMF!

When the power is disconnected from the motor, the decoder can then measure the voltage generated by the motor. By monitoring the BEMF, it can make adjustments to control the speed accurately. This allows the decoder to change the modulation as needed.

External Links

Pulse Width Modulation