Tuesday, November 8, 2011

Pluse Width Modulation

As I mentioned somewhere near the beginning, controlling the speed of a DC motor is one of my goals.

After some research, I discovered Pulse Width Modulation (PWM) can be used to do this. I had heard of PWM before, as a method of transmitting communication signals. But speed control? This was something new!

DC motors are designed to achieve their  full rated speed at some nominal supply voltage, but will turn more slowly within a certain range of lower voltages. Sure, I could simply put a potentiometer in series with the motor and control the voltage that way, but then I'd need to "be there" to turn the potentiometer knob, or build some Rube Goldberg mechanism to turn it for me.

PWM is a way to vary the average voltage (per unit of time) to the motor.
If you vizualize a regular square wave (referenced to zero volts) you'd notice that the ON time is exactly the same as the OFF time. This is known as a "50% duty cycle".



Thanks Google and masteringelectronicsdesign.com for this graphic.

OK, the ON time is represented by the line at Vp, lasting from Time Zero
to T/2. The OFF time is represented by the line at 0, lasting from T/2 to T

T is the Time Period of this pulse cycle.

PWM works by making the ON time of a square wave variable. A simple definition of duty cycle would be the percentage of ON time in one cycle, compared to the duration of one entire On/Off cycle.



Thanks Google and csound.noisepages.com for this cool graphic


To use PWM to control our DC motor, we use that ON again, OFF again signal to control a MOSFET that in turn controls the supply of power to our motor.

A 50% duty cycle applied to a 12 volt supply gives an effective 6 volt supply.
A 25% duty cycle would give 3 volts, and a 75% duty cycle would give 9 volts.

Again, thanks to my friend Gus for showing me how to build a variable duty cycle PWM circuit. My little PWM circuit uses a potentiometer too, but for now it's baby steps.

A really cool PWM circuit  would be controllable by a digital input from a personal computer or the some other form of electronics, allowing for automatic or programmable control.  

I checked the output of my PWM circuit on an oscilloscope, and I see that it is capable of a variation in duty cycle from around 10% to very nearly 100%.

The next step was to design some way to make this PWM signal turn on and off my H-Bridge MOSFETS, when the motor is rotating in either direction.

The approach I chose (again, following the helpful advice of my friend Gus) was to use the PWM output to control a new MOSFET that would alternately turn the gate signal to my H-Bridge MOSFETS On and Off.


(insert schematic here)

I was very gratified that this setup worked the on the first attempt.