2012年11月7日 星期三

DC motor direction control using L293d

源自於http://www.electroons.com/8051/electroons/dc_motor_control.html



DC motor direction control using L293d   


This is another tutorial for microcontroller interfacing series. This is all about how to interface/control a simple DC motor using microcontrollers. Controlling a DC motor is nothing but controlling the direction and speed of a motor. It is very necessary to go through motor controlling concept, if you are designing an autonomous robot.

How does DC Motor work ???
Lets start with how actually DC motor runs? Direction control of a DC motor is very simple, just reverse the polarity. Mean to say that every DC motor has two terminals out. When we apply DC voltage with proper current to a motor, it rotates in a particular direction but when we reverse the connection of voltage between two terminals, motor rotates in another direction.


Controlling using Micro Controllers !!!

I think you are now familiar how to change the direction of DC motor. Now let us consider how to control motor using Microcontroller provided:
1. Microcontroller provides us only digital logic (1 or a 0).

2. We cant provide polarity from microcontroller Digital I/O.

3. We cant connect motors to Controller as mostly motors runs on volatage level more than +5V, and motors demands high current (depends).

Now the solution to above limitations is, to use a H Bridge circuit.



It is a special circuit which allows motor rotation in both directions. From four terminals of a H bridge you can control the direction of a DC motor.
Using L293d Dual half H Bridge
Depending on current & power requirments, We can make our own H bridge using transistors/MOSFETs but it will be better to demonstrate the working, if we use some ready made IC such as L293d, its a dual half H brige IC.


we can drive a maximum of two DC motor and One stepper motor using one L293d.


Decision Table will look like

IN1   IN2   Motor1   
0   1   Rotates in one direction   
1    0   Rotates in other direction   


Similar is true for another motor connected to Out3 and Out4 of L293d and can be controled through IN3 and IN4. This is all about controlling direction of DC motor using L293d and 8051.

 
/*********************************************************************
Example program for DC motor control using L293d H bridge IC
This program simply make both of 2 Dc motors to rotate some time in one direction and sometime in other.
*********************************************************************/
#include<at89x52.h>



void delay(void)
{
unsigned int i,j;
for(i=0;i<200;i++)
{
for(j=0;j<1250;j++);
}
}



void main(void)
{
P2=0x00; // initially both motors stopped
while(1==1)
{
P2=0xA0; // both motors in one direction
delay(); // Some delay
delay();
delay();
P2=0x50; // Both motors in another direction
delay();
delay();
delay();
}
}




Note- Do not connect toy car small DC motor directly to L293d as they consume lot of current and has small internel resistance. 



源自於
http://www.freewebs.com/isuru-c/motor_driver.htm



Here is a simple motor driver circuit using the L293D Motor driver (available from Surplustronics www.surplustronics.co.nz NZ):
It's perfect for robotics applications, with just 4 MCU lines you can make two motors move forwards and backwards and stop.

沒有留言:

張貼留言

MQTT Explorer 與 Node-Red 介面的實驗

 MQTT Explorer 與 Node-Red 介面的實驗 MQTT EXplorer 與 Node-Red介面的設定 (1) 設定  MQTT EXplorer Client    (2)        Node-Red LED ON  --> MQTT Explor...