| Raspberry Pi CM5 IoT In C - - PWM Using GPIO5 |
| Written by Harry Fairhead | |||||||||
| Monday, 12 May 2025 | |||||||||
Page 5 of 5
What Else Can You Use PWM For?PWM lines are incredibly versatile and it is always worth asking the question "could I use PWM?" when you are considering almost any problem. The LED example shows how you can use PWM as a power controller. You can extend this idea to a computer-controlled switch-mode power supply. All you need is a capacitor to smooth out the voltage and perhaps a transformer to change the voltage. You can also use PWM to control the speed of a DC motor and if you add a simple bridge circuit you can control its direction and speed.
The amount of power delivered to a device by a pulse train is proportional to the duty cycle. A pulse train that has a 50% duty cycle is delivering current to the load only 50% of the time and this is irrespective of the pulse repetition rate. So the duty cycle controls the power, but the period still matters in many situations because you want to avoid any flashing or other effects. A higher frequency smooths out the power flow at any duty cycle. With a sufficiently fast period you can also use PWM as a digital to analog converter. Simply add a low-pass filter to remove the pulsing and you have a steady voltage proportional to the duty cycle. This can be used to create an audio signal if the clock is fast enough. Finally, you can use a PWM signal as a modulated carrier for data communications. For example, most infrared controllers make use of a 38kHz carrier, which is roughly a 26µs pulse. This is switched on and off for 1ms and this is well within the range that the PWM can manage. So all you have to do is replace the red LED in the previous circuit with an infrared LED and you have the start of a remote control, or data transmission, link.
Summary
Raspberry Pi Compute Module 5
|
Christmas Is NP Hard 21/12/2025 It is official - Xmas is NP hard. See exactly how and appreciate the value of holiday algorithms. |
AI - It's All Downhill From Here? 31/12/2025 AI is a complex beast, but it is based on some very simple and very powerful ideas that deserve to be better known as they throw much light not only on the way AI works but on the way the universe wor [ ... ] |
More News
|
Comments
or email your comment to: comments@i-programmer.info


