Shop OBEX P1 Docs P2 Docs Learn Events
Help with H-bridge circuit not working — Parallax Forums

Help with H-bridge circuit not working

WallydragWallydrag Posts: 16
edited 2009-12-17 00:42 in BASIC Stamp
I'm attempting to have a 9-18v DC motor turn one direction for 5 sec., stop for 5 sec., then turn the reverse direction for 5 sec. and then start over.

I'm using the L293D Quad Half-H Drivers with a BS1 Module and the Carrier Board for BS1-IC.

I've attached both my code and the schematics of how I've hooked it up.

When I get everything plugged in and going, the motor never turns. The best I get is I can hear a faint clicking from the DC motor at the times when it should be turning. When I power the DC motor straight from a 9v battery it spins like a champ.

I just really don't know where I've gone wrong. Here's a link to the L293D datasheet www.parallax.com/Portals/0/Downloads/docs/prod/compshop/603-00019-L293D-Datasheet.pdf

Any help would be appreciated. Thanks!

Comments

  • Brad_HBrad_H Posts: 35
    edited 2009-12-14 01:41
    Had a quick look at your program, looks ok but I didn't look too close because there is absolutely nothing for documentation. A few remarks never hurt even on a small simple program.

    Looks to me that your H-Bridge circuit is incorrect, missing a couple diodes.



    Brad
  • WallydragWallydrag Posts: 16
    edited 2009-12-14 02:39
    Sorry. Here's an update program with remarks.
  • Brad_HBrad_H Posts: 35
    edited 2009-12-14 03:20
    I would look at figure 5 on the data sheet. Everything looks fine except your motor connections. Add a couple diodes, make sure they are all oriented properly, and it should work.

    Brad
  • WallydragWallydrag Posts: 16
    edited 2009-12-14 15:42
    I've added the additional diodes but it still doesn't work.

    My working theory right now is that I possibly don't have the grounding's correct.

    Am I correct in thinking that when the BS1 sends on output (aka 1) through a pin that it's sending out an electrical current that has to been grounded somewhere else for the circuit to complete?

    Am I also correct in thinking that on the carrier board the Vss is the ground?

    Additionally, from the data sheet Fig. 5, where are those grounds supposed to connect to? The Vss on the card or the negative on the auxillary 9v that goes into PIN 8 on the L293D? Do some ground go one place and the other grounds go to another?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-14 15:50
    All of the grounds have to be connected together or it won't work. Ground, by definition, is a reference point for all voltages. When you're running motors or other high drain items, you may have two ground points to avoid what are called "ground loops" ... look that up in the Wikipedia, but the two ground points are connected together. Usually you have one point where the motor grounds and the ground of the motor power supply are connected together (where high currents flow) and another point where all the low current logic grounds are connected together with the logic power supply. The two ground points are then connected together with a piece of wire. Vss (SubStrate Voltage) is the term sometimes used for the logic ground.
  • WallydragWallydrag Posts: 16
    edited 2009-12-14 17:39
    Okay, so from the data sheet, of Pins 4 and 5, does one pin ground the low current logic and the other pin ground the higher voltage from the battery?

    Where does the Vcc2 power going into Pin 8 ground?

    I'm just having the toughest time figuring this out.
  • WallydragWallydrag Posts: 16
    edited 2009-12-14 21:59
    Maybe this might help.

    Attached is an image of how I've constructed the breadboard.

    Additionally, attached is a text file. You can copy the contents and go here: www.musicfromouterspace.com/ElectronicTools/virtualbreadboard/index.html

    In the bottom left is a button called "Save/Load". Click that and paste the contents from the text file and click "Load Circuit". It will bring up my breadboard.

    Thanks!
    916 x 582 - 118K
  • ZootZoot Posts: 2,227
    edited 2009-12-14 23:00
    The L293D has *integrated* EMF diodes, so you don't need to use external diodes with this chip.

    Your code seems odd, though I would expect the motor to turn. Personally I would just tie the EN pin on the L293D high (to 5v) and just control the two h-bridge pins for start/stop/direction.

    
    Main:
    
      PAUSE 5000
    
      HIGH PIN1              'Turn Motor Right 0.5 seconds
      LOW PIN2
      HIGH PIN3
      PAUSE 500
    
      LOW PIN1               'Motor Stop 5 seconds
      LOW PIN2
      HIGH PIN3
      PAUSE 5000
    
      LOW PIN1               'Turn Motor Left 0.5 seconds
      HIGH PIN2
      HIGH PIN3
      PAUSE 500
    
    
      LOW PIN3   ' this should be brought low as it's the enable pin
      LOW PIN1               'Motor Stop 5 seconds
      LOW PIN2
    
      GOTO Main
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-12-14 23:05
    Wallydrag,

    In your SBB diagram, the diode at J2-J5 is reversed, as well as the diode at J18-J21

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • WallydragWallydrag Posts: 16
    edited 2009-12-14 23:21
    That makes sense with the code.

    I've rearranged the breadboard to exclude the external diodes and also omit PIN3 and just run the Vdd from the BS1 card to the L293D PIN1 (EN) and PIN 16 (Vcc1).

    I've also take the PIN commands out of the code.
    905 x 574 - 109K
  • WallydragWallydrag Posts: 16
    edited 2009-12-15 06:06
    Okay, progress is being made but I've hit another bump.

    I've eliminated the diodes (since with this model they're internal) and I've run a jumper from Vdd to 1,2 EN (Pin 1 on the L293D) instead of from PIN3 like I had.

    I've connected a PIR to trigger the motor.

    In the code I've put in a Pause of 10 seconds to delay the PIR from activating.

    After 10 seconds have elapsed the PIR is live. When it senses motion it activates the motor just great.

    Here's where the bump is. The motor spins one way for 1/2 second like it's supposed to but instead of coming to a fast stop for 5 seconds before reversing direction, it goes straight to reversing direction and keeps going until I either push the reset and remove the battery.

    According to the data sheet www.parallax.com/Portals/0/Downloads/docs/prod/compshop/603-00019-L293D-Datasheet.pdf on Page 9, there are 3 ways to do a fast stop: a) Leave EN High and make the two inputs low b) leave EN High and make the two inputs High, and c) make EN low.

    I tried make PIN1 & PIN2 High and that didn't work. I tried make them both Low and that didn't work. Instead of running a jumper from Vdd to EN, I ran PIN3 to EN and set it to High in the program when the motor should turn and made it Low when it should stop. Doing this the motor never worked at all. It only seems to work when EN is connected straight to Vdd.

    I'm kinda at a loss now since it's not like I can program Vdd to turn off. I don't know why the motor will work when EN is connected to Vdd but not when it's connected to a PIN.

    Attached is the new code.

    I'm sorry I'm bothering you guys so much. All your help had been wonderful!
  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-16 18:00
    The Doc.s I have for the L293 (this is from Unitrode pg.4) show the 4 diodes brought up earlier ,they even have part#s SE85001

    I'm not sure if this is the problem or not. Every thing else looks OK.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • ZootZoot Posts: 2,227
    edited 2009-12-16 18:12
    $WMc% -- there are different flavors of the L293 -- L393D and L293DNE include the diodes on-chip at the expense of lower peak current per bridge. The L293N, L293NE, L293DWP and other flavors do *not* include the on-chip diodes, with the benefit of higher peak currents.

    See PDF for examples.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-16 23:51
    Zoot

    It still looks to Me that the L293/L293D need the diodes even after looking at Your spec. sheet. It calls out the external diodes as part#s SES5001 on pg. 9 and 10. Now I'm confused. I've used the L293D in the past and don't recall needing the diodes.But I was driving steppers.

    This isn't the first time that I've ran across some confusing data sheets!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • ZootZoot Posts: 2,227
    edited 2009-12-17 00:37
    The "typical" circuit is just that, and is not differentiated for the different varieties.

    But the very first column of info in the datasheet:
    said...

    - Peak Output Current 2 A Per Channel
    (1.2 A for L293D)

    - Output Clamp Diodes for Inductive
    Transient Suppression (L293D)

    Then, if you look at the equivalent schematic for L293 on page 3 and L293D on page 4, you will see that schematic for L293D shows output diodes on each channel, just as if you had wired 'em up yourself, while the straight L293 on page 3 does not.

    The "D", I'll presume, stands for "diodes included" smile.gif Note in the excerpt that peak current is significantly lower, however, for the "D" version, I presume because the clamp diodes aren't super beefy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ZootZoot Posts: 2,227
    edited 2009-12-17 00:42
    Wallydrag --
    said...
    Here's where the bump is. The motor spins one way for 1/2 second like it's supposed to but instead of coming to a fast stop for 5 seconds before reversing direction, it goes straight to reversing direction and keeps going until I either push the reset and remove the battery

    Your code seems OK, presuming the chip is wired properly.

    Can you take a photo of your current wiring and post it? Something seems dang odd here.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
Sign In or Register to comment.