PWM Project

From ProjectPages
Jump to: navigation, search

The aim of this project is to do some experiments around the Pulse Width Modulation capability of the Atmel AVRMega8 microprocessor.


  1. PWM control of a brushed electric motor - done!
  2. PWM control of a brushless electric motor
  3. I2C Electronic Motor Speed Controller (ESC)

Ramping LED brightness

It is based on the project found at AVR Libc The C code ramps up and down the 10-bit PWM of the AVR to change the brightness of the LED

LED Dimmer

  1. Add a potentiometer to input to the Analogue to Digital convertor.
  2. Use that to control the brightness of the LED

Just found this project Programming AVR ADC module with WinAVR, which does just what I want so I will try that next.

Here a 10K pot is connected across the 5 volt supply with the wiper going to the ADC input. The ADC result is being shown on the LCD. We are getting full 10-bit scale reading.

Now I have put together the ADC reading the potentiometer and used that reading to control the Pulse Width Modulation, making an LED dimmer!

Controlling a Motor

As I am just using a small motor, salvaged from a CD-Rom drive, I decided to use a Darlington transistor that I had in my parts bin. The video shows the LED dimming and the motor speed being controlled when the potentiometer varies the voltage to the ADC.

Here is a video showing the PWM waveform on an Oscilloscope.

Brushless DC Motor From a CD-ROM

The motor, in common with most CD-ROM motors, has three Hall Effect sensors These can clearly be seen in the picture below

CD-Rom Motor CD-Rom Motor Pinout


Came across a useful link. I had read that it was inadvisable to run the gate of a MOSFET directly from a uP output pin because of the capacitive load. This link shows the circuit diagram for a motor speed controller using a CMOS hex schmidt trigger to drive the MOSFET.
I have a 4 AMP MOSFET IRF624A in a bunch of surplus stuff so I will probably use that.
Sensor-based Control of Three Phase Brushless DC Motors Using AT90USB family Code here
Sensor-based control of three phase BLDC motor based on tinyAVR and megaAVR devices Code here
Sensorless control of 3-phase BLDC motors based on tinyAVR and megaAVR devices Code here