PWM Motor Drive

PWM stands for Pulse Width Modulation. 
I offer the following for those who are mystified on how a decoder controls the motor speed and how motor voltage and current are related.

THIS SECTION SHOULD BE READ FIRST BEFORE READING THE SECTION ON MOTOR BEMF.

Below are the sections covered.  At the end of each section name you will find (DCC) and/or (DC) appended.  This indicates how this section specifically applies to the motor under DCC control or DC control.  In most cases the section applies to both as shown.

1) Motor Voltage. (DCC)
2) PWM Motor Speed Control. (DCC)
3) PWM Pulses vs smooth motor rotation. (DCC)
4) PWM pulse Vs DC Voltage (DCC).
5) Track Voltage vs Motor Speed Range. (DC and DCC)
6) Motor vs Generator (DC and DCC)
7) Ideal Motor Current Draw (DC and DCC)
8) Real World Internal Motor Loses (DC and DCC)
9) Real Motor Current Draw with No Shaft Load. (DC and DCC)
10) Real Motor maximum current and efficiency. (DC and DCC)
11) Real Motor Current Draw with a Shaft Load (DC and DCC Observable Effects)
12) Decoder BEMF Control. (DCC)
13) Decoder BEMF VS Variable Track Voltage. (DCC)


1) Motor Voltage. (DCC)

Under DCC, the track voltage is constant, regulated by the Booster and set the upper limits of both maximum engine speed and power (Current) available from the track.  With DC, the track voltage is intentionally varied to directly control the speed of the motor.  Compared to DC, DCC requires a CONSTANT track voltage which is generated and regulated by the booster contained in all DCC systems.  The decoder connects the track voltage, after rectification, directly to the motor terminals using on-off switches in the form of a special type of transistors.  Because the switches are on or off, they are extremely efficient (minimal heat).  Simplistically, the decoder applies FULL track voltage to the motor terminals at all speeds from speed step 1 to speed step 28 or 128.  Stated another way, the constant motor voltage from the track does NOT control the motor speed since it does not change.

(KISS Principle: This discussion ignores the layout wiring voltage losses and the precision level offered by the booster to regulate the track voltage under all current loads.  These will effect motor speed range but they are variable outside the basic principles involved in decoder motor speed regulation.   We will assume we have an ideal booster and ideal layout wiring. I will address the track voltage dropping effect at the end of this discussion)



2) PWM Motor Speed Control. (DCC)

DCC decoders use what is called PWM or Pulse Width Modulation to control the motor speed.  Again, the voltage applied to the motor terminals in the form of full voltage pulses using the transistors that turn power on and off.  The decoder does NOT apply a variable DC voltage to the motor.

To control the speed, the decoder varies the voltage pulse duration in units of time.  Because the motor must be run continuously, the PWM voltage pulses must be applied in the form of a pulse stream.

The duration of time between repeating pulses is called the PWM Period.  We often express the PWM period in the form of a frequency which is easy to understand in some ways.

PWM Frequency = 1/(PWM Period).

This is why high end decoders talk about PWM frequency as it related to motor drive.  Using higher Frequencies that are at or above the limits of human hearing (15,000 or 15KHz or higher) allows them to make very little audible noise driving the motor.

When a voltage pulse is applied to the motor, it only last a certain amount of time.   We use the term "Pulse Width" to describe the duration of the ON-time pulse applied to the motor terminals. 

When the voltage pulse is not being applied, that is called the pulse OFF time and has no other name.   The sum of the On-time (Pulse Width) and the OFF-Time must always equal the PWM period.  Hence the maximum "Pulse Width" can never be greater than the PWM period.

We only talk about the Pulse Width since that number scales with speed.   The long the Pulse Width, the high the speed of the motor.  However talking about the Pulse Width in terms of time is hard to understand and make comparisons to other decoders with high PWM frequency difficult.  However, by talking about the ratio of the Pulse Width relative to the PWM Period, we can use units of % and not worry about the PWM frequency making it easier to understand.  We call the percentage based ratio value the Duty Cycle.

Duty Cycle (%) = Pulse Width / PWM Period.

Examples:

When the Pulse Width time = ZERO, there is no ON-Pulse and hence there is no voltage being applied to the motor.  This is the stop condition. It is the same as 0 on a throttle on a DC powerpack. The Duty cycle = 0%.

When the Pulse Width = 1/2 of the PWM Period, the On-Pulse is half way.  This is the same as half speed.  The Duty Cycle is 50%.

When the Pulse Width = PWM Period, the On-Pulse is applied continuously to the motor.  This is the full speed condition.  It is the same as full throttle on a DC powerpack.  The Duty Cycle = 100%.

So you can see, the speed tracks the Duty cycle value. Duty Cycle is an expression of the pulse width's time.   As the pulse width time goes up and down to control the speed, we call this variation of time "Modulation" of the Pulse Width.  Hence the term "Pulse Width Modulation" or PWM. 



3) PWM Pulses vs smooth motor rotation. (DCC)

You may ask: Given the voltage is not applied to the motor continuously, will not the motor slow down between the pulses.  The answer is YES it does in the real world using a real motor.  However you will not physically see the motor slow down to your naked eye much unless the PWM frequency is very low.   The mechanical mass of the motor armature with it flywheel effect without without any external flywheels averages out the pulses into a smooth constant average rotation speed for the given load.   More accurately, the rotating mass creates "Angular momentum" which keeps the motor spinning when the pulse is not being applied.  The higher the rotating mass gets, there is corresponding reduced up and down RPM speed change during a given PWM cycle.

From a conservation of energy point of view, the Angular momentum energy is "collected" during the moment the pulse is on speeding up the motor and then "spent" the next moment when the pulse is off and the motor is slowing down.   



4) PWM pulse Vs DC Voltage (DCC).

The higher the Duty Cycle, the higher the motor speed.  We can express the "effective DC motor voltage" by taking the track voltage and multiply it by the Duty Cycle % value.

Motor Speed = Track Voltage x Duty Cycle.

Half Speed = 12V x 50% = 6VDC.
Crawl Speed = 12V x 10% = 1.2VDC
Full Speed = 12V x 100% = 12VDC

Below are more examples of Duty Cycle and how it related to the "effective average DC voltage" that the motor sees.

In practice, stiction, cogging and other motor losses can effect the success of slow speed operation.   Tricks like Decoder BEMF control can extend the range to lower RPM values.  See section 11.

When we adjust our DCC throttle to a given Speed Step with BEMF off, we are in fact directly adjusting the On-Pulse Duty Cycle going to the motor.   So when one is using 28 speed step mode the decoder is using 28 unique fixed Duty Cycle values or 28 equivalent fixed DC voltages available to control the motor speed in a 1:1 relationship with the speed step value chosen on the throttle."



5) Track Voltage vs Motor Speed Range. (DC and DCC)

Under DCC, the track voltage is held at a constant. However there remains what is the track voltage.   This may or may not be adjustable by the booster.   The track voltage does determine the speed range over which PWM motor speed control will work.   Stated another range, a higher track voltage will allow the engine to have a higher maximum speed. Likewise a lower track voltage will set a lower maximum speed.



6) Motor vs Generator (DC and DCC)

Remember DC motors are also DC generators.  The voltage they generate is called the motor's "Back EMF" also known as "BEMF".   In generator mode, the BEMF voltage is the same as the generator voltage used to power the load.  The amount of voltage generate is directly related to the speed of the motor.  You can prove this your self by hooking up a 12V headlight bulb to the terminals of a old 12V motor and spin the motor shaft with a standard drill.  Remember to hold the motor body still when doing this. Watch the light bulb light up depending on how fast the motor spins.  The polarity of the voltage generated is determine by the direction of rotation.

When we are using a Motor as a motor and not a generator, the BEMF voltage does not go away.  The BEMF voltage is the same polarity as the applied voltage going to the motor leads since the direction is the same.  You can verify this your self using a volt meter in the above test when the rotation direction is the same between motor mode and generator mode.



7) Ideal Motor Current Draw (DC and DCC)

The Motor operating as a Motor uses this equation to determine motor current.

Motor current = (Applied Track Voltage - Motor BEMF Voltage)/ Motor coil resistance

This is basic Ohm law rewritten to reflect what is happening in the motor.

Under ideal condition with a perfect motor, the motor will not consume any current because there are no losses in the form of heat or friction.  The motor efficiency is 100%. It will spin forever at a constant speed directly proportional to the applied track voltage.

Why? The term Back in Back EMF is a way of describing the BEMF voltage position in the circuit relative to the applied voltage on the terminals.  Since there is only one set of terminals use in both motor and generator mode, the two voltages are always wired in parallel to each other.  For a given direction, the polarity of the two are always the same. Electrically this places the BEMF Voltage in opposition to the Applied Track Voltage.  The BEMF voltage pushes BACK against the applied voltage. The motor only see the DIFFERENCE between the two as the effective voltage that will do work.

When there is no load on the perfect motor, the Motor BEMF Voltage is the same as the Applied Track Voltage.

Lets assume the Coil Resistance is 10 ohm for simple math purpose.

Motor Current = (12V -12V) / 10 Ohms = 0 / 10 = 0 Amps of current.

So our perfect motor will consume no current because there are no losses and yet spin.



8) Real World Internal Motor Loses (DC and DCC)

If you look at the equation in section 6, it becomes clear the motor will only consume current if the Back EMF Voltage is LESS THAN the track voltage.

When will this happen? When there is a load (friction) on the motor shaft is forcing the motor to slow down.

With a real motor and NO load on the motor shaft, there is still friction in the motor itself.   The friction is found in the motor's "Friction Bearings" and in the motor brushes rubbing against the motor's commutator.  All friction turns to heat which is ENERGY LOSS. Real motors are not 100% efficient.

To keep the motor spinning against these friction based energy loss factors, we must put energy back into the motor that is equal to the energy lost.   That means the motor must consume current.

A conductors including wires have resistance. When current flow through the wires, the wires will also dissipate into heat which is what causes the motor to get warm under load.

Coil Power Loss = (Motor Current)^2 x Coil Current Resistance.

Motor Load = Coil Power Loss + Friction loss

Any heat loss with no load on the motor shaft means a less than 100% efficient motor.   These loses cause the motor to spin slightly slower generating LESS "Motor BEMF voltage". Now the difference between the track voltage and the Motor BEMF is more than zero.  The motor will consume some small amount of current whose Power level is equal to the motor load.



9) Real Motor Current Draw with No Shaft Load. (DC and DCC)

Lets assume the motor without any load on the shaft only has to compensated for its own internal losses.   For these losses, lets assume the speed is reduced by 4%.  The percentage of motor speed drop is called "Motor Slip".  It is the actual motor speed relative to its ideal speed.

Remember that motor speed is proportional to the BEMF voltage it generates.  So the BEMF voltage is now less than the Applied voltage. 

So with a 4% motor speed slip:

BEMF(4% loss) = Applied voltage x (100% - 4%) = 12V x 96% = 11.52V

Now let applies this voltage to the Motor Current Equation

Motor Current = (12V -11.52V) / 10 Ohm = 0.48V / 10 = 0.048 Amps of current. (48mA)
This is what our real motor will draw just by itself spinning.

In terms of power (Energy), the motor is consuming

Motor Power = Applied Voltage * Motor Current = 12V x 0.048A = 0.576 Watts.
So our real motor will draw just over 1/2 Watt just by itself spinning replacing it internal losses.



10) Real Motor maximum current and efficiency. (DC and DCC)

This is also called the stall current rating of the motor I(stall).  This is the maximum current the motor can draw with 12V applied to it terminal but the shaft is locked and not allowed to spin.  With no spinning, there is no BEMF to counter the applied voltage.  We are at 100% slip.

I(stall) = Applied Voltage / Coil Resistance = 12V / 10 Ohms = 1.2Amps.

W(stall) = Applied Voltage x I(stall) = 14.4Watts.

We can now figure out the motor efficiency with no shaft load.

Motor Efficiency (no load) = (14.4W - 0.576W) / 14.4W = 96%



11) Real Motor Current Draw with a Shaft Load (DC and DCC Observable Effects)

When there is a load applied to the motor shaft, the motor speed goes down and Motor Slip along with the current increase.  When you lessen the motor load the current decreases and the motor speed increases.

When there is an increase in current, the motor is drawing more watts to drive the shaft load.  Hence a long train will draw more current than a light engine move which will draw the least.  Likewise when pulling a train up a hill the motor will draw a lot more current.  When going down the hill, it will draw the very least.

When working with a heavy shaft load and drawing more current to power that load, the motor become less efficient since the current in the coils have gone up.  The point is the motor will draw more power just for itself in addition for what is needed for the load.