Sei sulla pagina 1di 12

SparX’09

Robotix Tutorial
Working of DC Motor
Need of L293D:
1. Current can’t be drawn directly from parallel port of CPU as
current rating of Motherboard is much lesser than that of motor.

2. Parallel port of CPU can provide only 5V voltage.


Working of L293D:

If HIGH (1) is provided at INPUT 1, then voltage at OUTPUT 1 will be


Vcc. If LOW (0) is provided at INPUT 1, then voltage at OUTPUT 1 will be
GND (i.e. 0V). This applies for rest of 3 input & output ports too.

Input  Output
0  0V
1  Vcc

By using combinations LOW(0) & HIGH(1), motor can be controlled as


Follows :-
By using one L293D chip, 3 motors can be controlled as follows:
Assume there are two motors motor no.1&2 for motion of robot and robot
motor no.3 for movement of an arm of robot.

As shown in figure, one terminal of each motor is connected in common to


output port op1.

Now, If we supply ip1 = 1(high), ip2 = 0(low), ip3 = 0(low), ip4 = 1(low)

Motor 1 will rotate clockwise (assume one direction)


Motor 2 will rotate clockwise
Motor 3 will not move.
Overall, Robot will move in Forward direction with arm not moving.
Similarly, other cases can be considered as follows:

Ip1 Ip2 Ip3 Ip4 Result


1 0 0 1 Robot move forward & arm stop

0 1 1 0 Robot move backward &arm stop

1 0 1 1 Robot move Right & arm stop

1 1 0 1 Robot move Left & arm stop

1 1 1 0 Robot stop moving & arm moving


A Sample Circuit connecting Serial Port to L293D:
Programming by Turbo C:
The function used to operate Serial port is,
outportb(PORTID,data);

PORTID is 0x378

Example:

Solution => outportb(0x378,0x0b);


Sample Program:

#include<iostream.h>
#include<dos.h>
#include<conio.h>
void main()
{
clrscr();
char x;
while(1) /* infinite loop*/
{
x=getchar();
sleep(1) ; /* say T1 */

switch(x)
{
case w:
outportb(0x378,0x19); /*Forward ; 0x19 = 00011001*/
sleep(2); /* say T2*/
break;
}
}
}
V

Vcc

0
t
T1
T2

T1 & T2 are two delays. T2/T1 ratio controls the speed of the
motor. For maximum speed make T1 = 0;

Now if user runs this program & press “w”.


Chip will supply Voltage Vcc for T2 seconds & won’t supply any
voltage for T1 seconds.

Similarly, other four cases can be programmed.


Hope to see you at Sparx’09
Best of Luck

Potrebbero piacerti anche