Skip to content
Sandeep Thiruvalluvan edited this page Jul 12, 2016 · 2 revisions

Welcome to the Controlling-DC-Motor-using-PWM-in-AtMega32 wiki!

How to use?

Connect the Forward Direction pin of the motors to the OC1A(PD5) and OC1B(PD4) pins of the microcontroller respectively. Connect the other pin of the motors to Ground.

To Adjust the Speed of the motor, vary the OCR1A and OCR1B values in the code.(Mind that PWM is in "Inverting mode")

Compile the (.c)file to get the Hex file. Burn the Hex file to your AtMega32 and you are ready to go.

Why use PWM?

Power efficiency The induction of the motor will cause the current to average. At the same time the transistors in PWM mode have very low impedance and therefore a low voltage drop and low power dissipation. In case of a series resistor a lot of power is dissipated in the series resistor.

Speed control behavior With PWM the motor will 'see' a very low power supply impedance, even though the power supply is constantly switching between high and low voltages. The result is that the motor has a much higher torque. With a series resistance the motor will experience a very weak power supply and it will be easy to stall the rotor.

Control circuit For a control electronics (eg. a microcontroller) it is very easy to switch on/off transistors. Outputting an analog voltage or controlling a series resistor requires much more expensive circuitry and in turn will cause more power dissipation.

Clone this wiki locally