Driving stepper with L293D
I have a bipolar stepper motor that I want to control with an L293D and a 5V MCU. I have a small 5V regulator for the MCU and a variable power supply for the motors.
According to the datasheet, VCC1 is the logic supply and VCC2 is the motor supply.
http://www.ti.com/lit/ds/symlink/l293d.pdf
So I hooked up the circuit this way:
the fours DIR pins (2,7,10,15) to an output pin from the MCU
the 2 enables (1,9) directly to VCC1
(3,6) to a coil and (11,14) to the other stepper coil.
VCC1 to 5V MCU regulator
VCC2 to variable PSU
And by sequecing the DIR output pins, it works!
There is a big problem though...
While the motor is running, if I disconnect VCC2, the motor still runs! This get me worried because the L293D must feed from the logic 5V supply. But even more disturbing... if I disconnect VCC1, the motor still runs too!! So either its taking power from the DIR pins or the ENABLE pins.
Can anyone help me clarify why I have this behavior and what I should do? Ideally, I don't want the stepper to move if VCC2 is disconnected.
According to the datasheet, VCC1 is the logic supply and VCC2 is the motor supply.
http://www.ti.com/lit/ds/symlink/l293d.pdf
So I hooked up the circuit this way:
the fours DIR pins (2,7,10,15) to an output pin from the MCU
the 2 enables (1,9) directly to VCC1
(3,6) to a coil and (11,14) to the other stepper coil.
VCC1 to 5V MCU regulator
VCC2 to variable PSU
And by sequecing the DIR output pins, it works!
There is a big problem though...
While the motor is running, if I disconnect VCC2, the motor still runs! This get me worried because the L293D must feed from the logic 5V supply. But even more disturbing... if I disconnect VCC1, the motor still runs too!! So either its taking power from the DIR pins or the ENABLE pins.
Can anyone help me clarify why I have this behavior and what I should do? Ideally, I don't want the stepper to move if VCC2 is disconnected.
Comments
It all comes down to reading the PDF to determine what the original plan for control is.
Somehow, there is apparently a crossover between power for the stepper motor's logic and the actual BJT half-H-bridges that are driving the stepper. It could be your wiring or it could be how the board you purchase wired the L293 or it could be the L293 internal design.
Without knowing much, I'd first suspect a wiring error on your part. I don't see how it might run without Vcc1 and without Vcc2. But you really should have considered FiRST using the Enable to toggle on and off.
If you must have the motor stop when Vcc2 is disconnected, you may have to use logic chips to sense Vcc2 and have that control the Enable. Of course, without Vcc2, the stepper might not hold position. Is that what you desire?
Focus on testing and understand if Enable is working right. Disconnecting Vcc1 and Vcc2 may actually create a back current and damage the device.
Stopping rotation and holding position should be done with the actual step sequencer.
As Loppy suggests, you want to control the power to the stepper using enable and not the Vcc pins.
If you need to disconnect the Vcc pins, make sure and set the microcontroller pins to inputs.
You nailed it. For some reason, if the motor supply is not present I don't want the motor to run.
Thanks Loopy, Duane and Gordon for your advice. I'm going to connect the Enable to the MCU and sense if VCC2 is present or not before trying to step.
With such a circuit, the split-second motor voltage disappears, the chip is disabled.