Table of Contents
This Tutorial describes PWM and how it’s principles can be demonstrated using the Kookaberry ecosystem.
Specifically, this Tutorial will describe how the speed of a motor or the intensity of an LED is controlled in the digital world.
The analogue world
Our real world is generally an analogue world. Our eyes perceive a continuous range of brightness and colour, and our ears a continuous spectrum and level of sound.
It can be demonstrated by running the Dimmer app on the Kookaberry with a potentiometer as an analogue input and a LED as a digital output. If the DC Fan (a motor) is used instead of the LED, then the same PWM process will vary its speed
PWM Duty Cycle
The percentage of time that a digital signal is ON over an interval or period of time is called the Duty Cycle. This period is the inverse of the frequency of the waveform.
If a digital signal spends half of the time on and the other half off, we would say the digital signal has a duty cycle of 50% and resembles an ideal square wave. In this case the intensity of the LED would be half its maximum value.
If the percentage is higher than 50%, the digital signal spends more time in the ON state than the OFF state and vice versa if the duty cycle is less than 50%. Here is a graph that illustrates these three scenarios. They are also the scenarios used in the screenshots above.
Persistence of vision
When PWM is used to dim lights, the frequency of the waveform should be greater than 50Hz so that the eye’s persistence of vision makes it seem that is ON all the time and does not flicker.
This can be demonstrated in the Dimmer app by reducing the frequency of the PWM waveform by pressing Button B. The frequency can be varied in steps from 16Hz to 100Hz.
Where is PWM used?
In our increasingly digital world PWM is becoming the predominant process for varying illumination level; speed; and direction and positional control.
The intensity of LED lighting and the LED’s in your TV is controlled by PWM. See the explanation of the process for the RGB LED.
The small DC motors used in model cars and tracked vehicles (such as a Mars Rover), and in robotics, all use PWM to control their speed.
Direction and positional control
A form of PWM is used to control the angle that a servo moves through. An example might be when a servo is used to control the steering wheel of a model car or the position of a robotic arm.
In this case, the duty cycle is not important, as the width of the pulse determines how far the armature of the servo moves. See this explanation from Sparkfun