Shop OBEX P1 Docs P2 Docs Learn Events
Driving stepper with L293D — Parallax Forums

Driving stepper with L293D

FredBlaisFredBlais Posts: 370
edited 2015-03-09 13:30 in Robotics
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.

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-09 09:07
    You just may have to find an alternative way to stop the stepper.
    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.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-03-09 09:17
    It's not uncommon for devices to pull power from I/O pins when the regular power supply is disconnected. This can destroy either the device and/or microcontroller.

    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.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2015-03-09 09:34
    I assume that you're not really intending to actually control the chip by removing its Vcc1/Vcc2 power, but you're worried what might happen to your controller should motor voltage be accidentally removed or lost (e.g. in the event of a blown motor supply fuse). You can always protect logic pins by placing (1K or so) resistors inline to them, which will limit any current in the case of parasitic draw. There are other ways, but this seems to work pretty well in most cases.
  • FredBlaisFredBlais Posts: 370
    edited 2015-03-09 10:28
    I assume that you're not really intending to actually control the chip by removing its Vcc1/Vcc2 power, but you're worried what might happen to your controller should motor voltage be accidentally removed or lost (e.g. in the event of a blown motor supply fuse). You can always protect logic pins by placing (1K or so) resistors inline to them, which will limit any current in the case of parasitic draw. There are other ways, but this seems to work pretty well in most cases.

    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.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2015-03-09 13:30
    One method that does not require you to tie up your MCU is to use the Vcc2 voltage and the MCU with an AND gate to create a positive enable circuit. Your motor voltage will likely be over 5V, so you need to clamp or convert that voltage before feeding it into the ENable in's of the 293. All sorts of methods for converting CMOS voltages to TTL, so you can take your pick.

    With such a circuit, the split-second motor voltage disappears, the chip is disabled.
Sign In or Register to comment.