Let's Make Robots!

Driving an L293 with one I/O pin?

There's the circuit, here's the plan...

I remember the remote control cars from yesteryear (the ones connected to the controller with a wire!). They had a joystick that just went forwards and backwards. When pushed forward the car would drive forward in a straight line. When pushed back, the car would back up while turning. There was no real directional control. I'm trying to acheive a similar level of control with this circuit. The idea is:

  • While the I/O pin and IN1/2 are low, the inverter transistor sets IN3/4 high. This configuration makes both motors drive forward. During this time C1 gets charged up.
  • When IN1/2 changes to high, the inverter makes IN4 low, causing the motor on IN2/4 to reverse.
  • For a short time while the motor on IN2/4 is reversing, C1's charge keeps IN3 high, causing the motor to stop. D1 prevents the same thing from happening to IN4. This should make the robot turn a little bit before R1 (with a high value) lets C1 discharge after... one second, let's say. Just enough time to point the bot in a different direction.
  • At about the same time C1 discharges to the point that IN3 goes low and causes both motors to go in reverse, the I/O pin is turned high again, preventing any possible backing up off of a cliff. 

Thoughts? Critiques? Phoolhardy physics? An easier way? Let me hear it :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

while reading this tread, i remember me blind Lemons "y-bridge" http://letsmakerobots.com/node/15949?page=3 see nuumio's post there.

Edit: oh.. didn't fully understand the steering / breang part until now. Jax got the answer.. Simple with the inverter. But why don't you use relays?

pretty simple to make this with them..

Most of the time I avoid relays because of their power consumption but this time it was for spatial constraints. This project is to fit in a cylinder ~38mm x 50mm. Half of that space is motors, battery, and a servo. Ten grams of robot in a nine gram bag. That and I'm cheap-cheap-cheap and trying to do what I never do: Use parts I have, not those I need to buy.

I saw that Y-bridge too but I think I need to be able to leave the control pin on/off. I think the program will have problems driving the bot in a straight line while doing the other tasks I'm troubling it with. Just a presumption; I've yet to breadboard a damn thing.

Do you want the 2 sensors independently from each other? So it can steer both ways?

The two IR sensors are teamed up with a forward-looking IR sensor as well. A proximity detection on any of them will trigger the avoidance routine via one pin on the uC. If you can show me how to steer away in a direction based on the sensor that was triggered (without adding more than a couple components) I'm all ears. I can't stress how tight the fit is in this bot.

the pins you are using and for what they all have to do. It would be easier to make suggestions.

The 3 sensors could be treated as switches and placed in series with a resistor of different values and all that tied to an analog line. Now, if you could build two circuits like you are considering in this post and tie them to two separate pins. Depending on which pin was driven low you could turn one way or the other, and, while driving forward with one pin, the other could be used as an input. I think rather than trying to put all your circuits on a single plane, you should consider making a narrowly stacked board, or, maybe even deadbugging part of your setup to save space.

IN1 and IN3 are low, IN2 and IN4 are high; both motors go forward.

IN1 and IN3 are high, IN4 goes low, one motor goes in reverse. IN1 and IN2 are both high, so the one motor stops.

Even though the responses are excellent my needs are somewhat specific. I think maybe a better description is in order.

So the reversal/turn is necessary vs the forward/turn option. It will be used as a response to avoid an obstacle/edge...

This is a top-down view of the bot as its IR reflective sensors (the red dots) have detected an edge. It is a cylindrical bot with two wheels on the midline, if you couldn't tell.

If one wheel stops and the other continues forward then the bot drives off the edge/into the obstacle.

If one wheel stops while the other goes into reverse then it gets a little clearance from the edge and alters course at the same time. This is what I want to acheive. With Max shaking one of my sleepy neurons awake I think I can just tie what I call IN3 in my original diagram (should be IN4 fwiw) to V+. Remove all the D1, C1, etc. Keep what is called IN4 (should be IN3) connected to the inverter output as shown. This should get the desired motor response, yes? Hard to visualize, perhaps. Hopefully someone will understand.

Here's the logic table on the L293 (borrowed from our pals at SOR):

It looks like what we want to do from this break down is to use one pin to control two motors, causing one motor to break and the other to reverse on a state-change. Using an inverter (transistor or IC) will let you drive both inputs on one side of a 293/754410 brakelessly with one pin, but I think the problem is going to be one pin on two motors.  In other words, you want two states going to each side of the bridge normally (which is easy with an inverter) but only one state on one side and the reversal of previous states on the other.  I don't have the chops to do it in my head even using 6 inverters.

Normal (Out L): "Backup" (Out H):

Motor A:| H/L | L/H

Motor B:| H/L | L/L (or H/H)

The problem is that you can't uninvert that second input to one side of the h-bridge if you're using the inversion method to save pins.

Which brings us back to a possible mechanical solution.  Since it's easy to control one motor this way (or two motors acting as a single drive) it might be the way to go.  With a front steering wheel on a pivot, you can make the bot back up in a circle (red is direction of travel):

Granted it would be tricky to implement in something as small as a beer can, but so is playing the labrynth puzzle with inverters and logic tables...

A slipwheel seems so simple when seen in line-drawing format :)
I think you missed a small change I made in my revision. But as you said:

Normal (Out L): "Backup" (Out H):
Motor A:| H/L | L/H
Motor B:| H/L | L/L (or H/H)
The problem is that you can't uninvert that second input to one side of the h-bridge if you're using the inversion method to save pins.

Your table is just backwards of what I'm going for...
 
Normal (Out L): "Backup" (Out H):
Motor A:|  L/H  | H/L
Motor B:|  L/(H)  | H/(H)
 
The solution is to do away with the inversion process. In the second (EAGLECAD) schematic I don't invert the second input on the "second motor," only the first motor. The second input is tied to V+ instead, thus giving you the H/(H) brake situation you describe when the I/O pin goes high and reverses the first motor.  
editors note - this comment took about half a dozen separate edits to get the highs and the lows all sorted out correctly.

I had to make a spreadsheet to check your schematic but I think you've got it.  Just make sure to test the motors for direction before you set it free!