Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a microprocessor’s digital outputs. Consider to control a 5V DC motor with linear relation between given voltage and rotation speed with a 5V microcontroller, then you need it to works on 3V for achieve slower rotation. This goal can be achieved at least by 2 ways, DAC, or PWM.
By using DAC technique, let say it have 8-bit resolution (256 level), then you need to connect 8 pin of your microcontroller to the DAC, powering the DAC, and takes output of DAC into your motor. it might looks quite simple and easy to understand :). But, using his technique, it will cost you 8 pin of microprocessor output, extra DAC device (only few microcontroller have DAC), and also extra noise. SO, what to do?
Fortunately, there is a simpler way to get this goals, PWM technique. By using PWM, system costs and power consumption can be drastically reduced. In a nutshell, PWM is a way of digitally encoding analog signal levels. Through the use of high-resolution counters, the duty cycle of a square wave is modulated to encode a specific analog signal level.
[math]\frac {1}{T}$ \int_0^{T} f(t) dt$[/math]
[math]\frac {1}{T}$ \int_0^{DT} f_{max}(t) dt + \int_{T-DT}^{T} f_{min}(t)dt$[/math]
above equation should describe how PWM can emulates analog signal by using digital signals.
One of the advantages of PWM is that the signal remains digital all the way from the processor to the controlled system; no digital-to-analog conversion is necessary. By keeping the signal digital, noise effects are minimized. Noise can only affect a digital signal if it is strong enough to change a logical-1 to a logical-0, or vice versa.
Increased noise immunity is yet another benefit of choosing PWM over analog control, and is the principal reason PWM is sometimes used for communication. Switching from an analog signal to PWM can increase the length of a communications channel dramatically. At the receiving end, a suitable RC (resistor-capacitor) or LC (inductor-capacitor) network can remove the modulating high frequency square wave and return the signal to analog form.
PWM finds application in a variety of systems. As a concrete example, consider a PWM-controlled brake. To put it simply, a brake is a device that clamps down hard on something. In many brakes, the amount of clamping pressure (or stopping power) is controlled with an analog input signal. The more voltage or current that’s applied to the brake, the more pressure the brake will exert.
The output of a PWM controller could be connected to a switch between the supply and the brake. To produce more stopping power, the software need only increase the duty cycle of the PWM output. If a specific amount of braking pressure is desired, measurements would need to be taken to determine the mathematical relationship between duty cycle and pressure. (And the resulting formulae or lookup tables would be tweaked for operating temperature, surface wear, and so on.)
To set the pressure on the brake to, say, 100psi, the software would do a reverse lookup to determine the duty cycle that should produce that amount of force. It would then set the PWM duty cycle to the new value and the brake would respond accordingly. If a sensor is available in the system, the duty cycle can be tweaked, under closed-loop control, until the desired pressure is precisely achieved.
PWM is economical, space saving, and noise immune. And it’s now in your bag of tricks. So use it.
Leave a Reply