Whenever a robotics we talk about making a robot, the first thing comes to our mind is how Robot will move (How its motion part work). there are always three options in front of the us, one is to use a DC Gear motor , second is to use a stepper motor and third one is to use servo motors. When we think about speed, weight, size, cost… DC motors are always preffered over stepper motors and servo motors. There are many things which we can do with DC motor when we interfacing it with a microcontroller.
- Control the speed of motor.
- Control the direction of rotation
- Using encoder, keeping track of how many turns are made by motors.
Here we will work on interfacing a DC motor with a microcontroller. we will use H-bridge in interfacing a DC moto with microcontroller. Some Ic that are used to interface a DC motor with microcontroller are-
H-bridge can also be made with the help of trasistors and MOSFETs etc. rather of being cheap, they only increase the size of the design board, which is somtimes not required so using a small 16 pin IC is preffered for this purpose.
Why we are using Motor Driver for controlling motor. the perfect Ans of thing question is As microcontroller is running with small current and to run a motor need high current in compare to microcontroller for that purpose we are using Motor Driver.
Most DC motors are normally very easy to reverse. By simply changing the polarity of the DC input, the direction of the drive shaft reverses. This property makes DC motors very popular among enthusiast people involved in robotics. In most cases, DC geared motors are used.
As in diagram shown we can run two motors with the help of 1 L293D Driver.
the following Features are available in a L293D
- two enable (EN) pins, pin 1 and pin 9. Pin 1 EN enables the motor Channel M1 whereas pin 9 EN enables motor Channel M2.
- Connect motor M1 across OUTPUT1 and OUTPUT2 i.e. across pins 3 and 6.
- Connect motor M2 across OUTPUT3 and OUTPUT4 i.e. across pins 11 and 14.
- The inputs for motor M1 is given across INPUT1 and INPUT2 i.e. across pins 2 and 7.
- The inputs for motor M2 is given across INPUT3 and INPUT4 i.e. across pins 10 and 15.
- Connect GROUND pins 4, 5, 12 and 13 to ground also work for heat sink.
- Connect pin 16 to Vcc (=5V For Running Driver) and pin 8 to Vs (battery, 4.5V~36V)(Motor Operating voltage).
- If Input A1 = 0V and input A2 = 5V the motor1 will run Forward
- If Input A1 = 5V and input A2 = 0V the motor1 will run Reverse
- If Input A1 = 0V and input A2 = 0V Or Input A1 = 5V and input A2 = 5V the motor will Stop(0V) Or Breaking(5V).
Same Situation will be occur for second channel
DC Gear Motor Using With Arduino
int switchPin = A0;
int Motor_speed = 0;
analogWrite(motor1Pin, Motor_speed ); // For motor run clockwise with speed //adjusted by potentiometer
analogWrite(motor2Pin, Motor_speed ); // For motor run Anticlockwise with speed //adjusted by potentiometer
DC Gear Motor Using With AVR Microcontroller
Generating Signals for controlling the direction of motor using Port A
Motot is connected to Port A at Pin PA0, PA1, PA2 and PA3.
_delay_ms(500); // wait 0.5s
// counter-clockwise rotation
_delay_ms(500); // wait 0.5s
Here a Video of a Robot that is developed by using DC Gear Motor