Pulse Width Modulation
Digital circuits can only produce two numbers: ”0“ and ”1“. Analog circuits, on the other hand, can use any number. For example, with a digital circuit we can only turn on (”1“) or off (”0“) an engine or light bulb, while with an analog circuit we can control infinite bright or speed levels.
For a digital circuit to control an analog one – like the brightness of a light bulb or the speed of an engine – there are basically two techniques: Digital/Analog Conversion (DAC) and Pulse Width Modulation (PWM).
Digital/Analog conversion uses a number of bits proportional with the number of ”steps“ we want to have. For example, if we use 4 bits, we can have 16 (2^4) brightness/speed steps, from 0000 to 1111.
The problem with this technique is that the more steps you want, the more number of bits is required.
PWM technique on the other hand uses just one bit. PWM generates a squared waveform where the load cycle (time that the waveform stays at ”1“) defines the speed/brightness of the analog system.
For example, supposing a perfectly squared waveform, where 50% of the time it is at ”0“ and the other 50% of the time it is at ”1“, the final result will be that the light bulb will bright at 50% of its brightness and the engine will rotate at 50% of its speed.
If we configure this waveform to be 30% of its time at ”1“ and 70% of its time at ”0“, the result will be a 30% brightness/speed.
In summary, PWM is a technique for digital/analog conversion using just one bit, generating a squared waveform where the time it stays at ”1“ defines the output value (speed/brightness).