DC motor interfacing with AVR ATmega16/ATmega32

DC motor converts electrical energy in the form of Direct Current into mechanical energy.
In case of motor, the mechanical energy produced is in the form of rotational movement of the motor shaft.
The direction of rotation of the shaft of the motor can be reversed by reversing the direction of Direct Current through the motor.
DC motor interfacing with AVR ATmega16/ATmega32
The motor can be rotated at a certain speed by applying a fixed voltage to it. If the voltage varies, the speed of the motor varies.
Thus, the DC motor speed can be controlled by applying varying DC voltage; whereas the direction of rotation of motor can be changed by reversing the direction of current through it.
For applying varying voltage, we can make use of PWM technique.
For reversing the current, we can make use of H-Bridge circuit or motor driver ICs that employ the H-Bridge technique or other any other mechanisms.
For more information about DC motors and how to use them, H-Bridge circuit configuration, PWM technique, refer the topic DC Motors in the sensors and modules section.
For information about PWM in ATmega16 and how to use it, refer the topic PWM in AVR ATmega16/ATmega32 in the ATmega inside section.
Here we will be using ADC feature of AVR ATmega16.
For information about ADC in ATmega16 and how to use it, refer the topic ADC in ATmega16/ATmega32 in the ATmega inside section.
Here, we are going to interface DC motor with AVR ATmega16 microcontroller. In which we will control the DC motor speed by using POT connected to ADC of ATmega16 and direction by using a switch.
We are going to use L293D motor driver IC to control DC motor movement in both directions. It has in-built H-bridge motor drive.
–  As shown in above figure we have connected 1kΩ Potentiometer at ADC channel 0 of ATmega16 to change the speed of DC motor.
–  One toggle switch is connected to INT0 pin (2nd pin of PORTD) which control the motor rotating direction.
–  PORTC is used as an output control signal port.It provides control to motor1 input pins of the L293D motor driver which rotate motor clockwise and anticlockwise by changing their terminal polarity.

Programming steps

  • Enable ADC and map its output into 0-255 range.
  • Enable Global interrupt, INT0 external interrupt with the rising edge triggered mode.
  • Set Fast PWM mode of Timer0 with F­OSC/64 timer clock.
  • ADC value is given to the OCR0 register and in an interrupt routine, we are toggling motor direction.
  • Now continuously check for the interrupt for direction and read ADC value for speed control.
  • A switch will produce interrupt which causes to change in motor direction. By varying potentiometer, variable ADC values can be given to OCR0 register to achieve speed variation.

DC motor interfacing with AVR ATmega16/ATmega32 Schematic
 
Read More: DC motor interfacing with AVR ATmega16/ATmega32

Related Post

Be the first to comment

Leave a Reply

Your email address will not be published.


*


*
= 4 + 9

Read previous post:
Keysight Technologies’ E36300 series bench power supplies

Keysight Technologies' E36300 series of bench power supplies provide three outputs with power of 80 W or 160 W with...

Close