Bipolar Stepper Motor

The L293D chip has 16 pins. Here is how each of the pins should be connected:

Pin 1, 9 Enable pins. Hook them together and you can either keep them high and run the motor all the time, or you can control them with you own controller(e.g. 68HC11).

Pin 3, 6, 11, 14 Here is where you plug in the two coils. To tell which wires correspond to each coil, you can use a mulitmeter to measure the resistance between the wires. The wires correspond to the same coil has a much lower resistance than wires correspond to different coils. (This method only applies to bipolar stepper motors. For unipolar stepper motors, you have to refer to the spec. sheet to tell which wires correspond to each coil.) You can then get one coil hooked up to pin 3,6 and another one hooked up to pin 11, 14.

Pin 4, 5, 12, 13 Gets hooked to ground.

Pin 8 Motor voltage, for the motors we are using, it is 12V.

Pin 16 +5V. It is the power supply of the chip and it's a good idea to keep this power supply separate from your motor power.

Pin 2, 7, 10, 15 Control signals. Here is where you supply the pulse sequence. The following is how you pulse them for a single-cycle (to move the motor in the opposite direction, just reverse the steps. i.e. from step 4 to step1):

Coil 1a

Coil 2a

Coil 1b

Coil 2b

Step 1

High

High

Low

Low

Step 2

Low

High

High

Low

Step 3

Low

Low

High

High

Step 4

High

Low

Low

High

In our example, we use the digital outputs of the Handy Board to generate the above pulse. The SPI pins on the connector on the middle right edge of the Handy Board can be configured as digital outputs. Do a poke(0x1009, 0x3c) to make them outputs; then they are mapped o the middle 4 bits of address 0x1008 (SS= bit 5, SCK=bit 4, MOSI=bit 3, MISO=bit 2). Poke to that address (0x1008) to set them.

Here is the code fragment to generate the pulses:

int address=0x1008;

float x=0.005;
int i;
int t=100;
poke (0x1009, 0x3c);
for(i=0; ipoke(address, 00001100);
sleep(x);
poke(address, 00011000);
sleep(x);
poke(address, 00110000);
sleep(x);
poke(address, 00100100);
sleep(x);
}

In the above code fragment, the variable x controls how much time the controller should wait between each steps and this consequently determines the speed of the motor. The variable t determines how many cycles controller should drive the motor and so this control the angular position of the shaft.

Unipolar Stepper Motor

Driving a unipolar stepper motor with the L293D is very similar to driving a bipolar stepper motor. The pulse sequence is the same and you can use the code fragment above to generate the pulse sequence. The only difference between driving a unipolar stepper motor and driving a bipolar stepper motor is that there is an extra wire in a unipolar stepper motor you have to hook up. You can hook it up to the +5V supply and the wires are hooked up in the same way as those in the bipolar stepper motor.

0 comments:

Post a Comment