Shop OBEX P1 Docs P2 Docs Learn Events
H-Bridge to control multiple (16) motors — Parallax Forums

H-Bridge to control multiple (16) motors

adobejoeadobejoe Posts: 17
edited 2010-04-09 11:27 in Robotics
I have figured out the programming for my STAMP BS2 to control switch (PIN HIGH/LOW) for specific time and durations but I have a little problem. I would like to control 16 motors (12 V, 1.2 A) all simultaneously. These motors drive linear actuators for a solar panel setup. Most of the transister switching systems are generally under 2 amp. So, is there a relay approach anyone thnks would work?
AdobeJoe

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-04-03 03:24
    If you're going to use relays to control the motors you'll also need directioal control. Are all the relays moving at the same time and in the same direction and distance?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • adobejoeadobejoe Posts: 17
    edited 2010-04-03 03:39
    Chris, Yes all the motors will be going in the same direction, clockwise multiple steps (intervals) and then reverse ccw at midnight. Can I use one relay to control forward directions for ALL the motors, and another to control reverse? Specs and where to get? I have the software down fairly well, the programming, but the switching is not their yet. I understand with transister switches there is a voltage loss.· Read the Nuts & Volts V1, Column 6, which is kinda helpful.

    AdobeJoe
  • kwinnkwinn Posts: 8,697
    edited 2010-04-03 15:27
    @AdobeJoe, Are these 16 motors controlling the positioning of 16 panels, and if so how can you be sure that all the motors will will be running in lock step when they are powered in parallel ?
  • GWJaxGWJax Posts: 267
    edited 2010-04-03 17:58
    There's a little more to it than just attaching the 16 motors to a relay and having them turn on. You are forgetting the EMF that is made by the motors when electricity is introduced to them. You need a overload protection unit for each motor so you do not blow out the motor that might get stalled or pull too much current. If you can tell or better yet get the data sheet for these liner motors, I can help you out in designing the correct circuit that you need for use with the operation of the Basic Stamps.

    @ Kwinn-- If the motors are connected in series the you could not get the motors to drive at the same speed but in parallel the voltage and the current is constant. The only difference is if the motors have different resistance which this is highly likely but driving them within a 5-10% tolerance should be fine or at least close enough for what he is trying to do.

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..

    Post Edited (GWJax) : 4/3/2010 6:07:10 PM GMT
  • adobejoeadobejoe Posts: 17
    edited 2010-04-03 18:31
    kwinn & GWJax,

    The 16 panels will be in a 4x4 array, each individually rotated (1-axis) with 30 inch stroke linear actuator. The STAMP and battery will be located in the center, for symmetry.

    The motors are rated at 1200 mA, 12 V, under no-load.
    Of course if there is wind, or snow, the load may vary, so I know there will be issues that have impacts.

    The panels are 210 W, for 3.3 KW grid-connect.

    The STAMP and linear actuators will be powered from a 12 V DC battery, on separate PV panel for trickle charge, maybe 30 W.
    The controls from STAMP are Pin 4 on 5V to advance one direction, Pin 6 on 5V to retract or reset. I calculate about 30 amp-Hours per day to run actuators and stamp. In winter, I want about 100 Amp cold cranking capacity for my battery.

    GWJax, I will look for more specs on motors. Any help appreciated

    AdobeJoe
  • kwinnkwinn Posts: 8,697
    edited 2010-04-03 22:05
    @GWJax, Whether they are connected in series or parallel no two motors are going to run at the same speed. They may be relatively close if they have the same load but no guarantee even then.

    @adobejoe, I have never seen a design where all the motors are simultaneously controlled/run in parallel from one controller. I am certain you will end up with some fairly large positioning errors, if not initially, then as time and wear affect the individual motors and actuators.

    For solar panel positioning speed is not a big issue so it would be feasible to have a single control system position each panel individually by enabling each motor in turn. Doing so would allow you to measure the voltage and current from each panel and stop it in a position where it outputs maximum power. Even simpler would be controlling the motors as a 4x4 array similar to how leds are multiplexed. Four H bridges would be enough to control the 16 motors.

    Post Edited (kwinn) : 4/3/2010 10:15:12 PM GMT
  • kwinnkwinn Posts: 8,697
    edited 2010-04-03 22:26
    It would also be possible to control the motors using 8 single pole double throw relays.
  • adobejoeadobejoe Posts: 17
    edited 2010-04-03 23:54
    /Users/mac/Pictures/iPhoto Library/Modified/2007/Roll 248/IMG_1206.JPG

    I am not sure if this photo will come through, above, I am struggling with this MAC!

    My design is unusual in the support which is on a diagonal, corner to corner, with the LA attached to the other "high" corner, providing pivot about the diagonal. This is stable in high winds, strong against winds and is a KISS style of mounting with rotation.

    Anyway, the linear actuator is a Firgelli FA-05-12-30, adn I need to control all 16 with my single stamp program.

    @GWJax, you may be right there may be some positioning errors, but I plan to build and test and determine for myself.

    @kwin, I like the approach you mention with 8 DPDT relays. Can you sketch?

    Regards
  • kwinnkwinn Posts: 8,697
    edited 2010-04-04 02:29
    My thought was to hook up the relays (or half H bridges) as in the attached diagram. It would also require either 8 BS2 I/O pins and a driver like the ULN2803 (or 4 BS2 I/O pins and a TPIC6595) to drive the relay coils.
  • GWJaxGWJax Posts: 267
    edited 2010-04-04 05:03
    @Kwinn, Yes this is the way I was going to attach up the motors, but using the TPIC6595 POWER LOGIC 8-BIT SHIFT REGISTER is just a bit of over kill. Each relay must have a current load of at least 100 Amp contacts since the total of load of the motors will take 48 Amps running at full load. Protecting the BS2 is the top concern. By using Opto-Couplers to do the switching will isolate any stray voltage from any chip or relay to the Stamp. When dealing with motors and hBridges I always use these along side with a thermal cutoff and a clipper circuit. With my circuit there will be at least 3 I/O pins being used. When I done with the circuit I'll post it here for others to review.

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • adobejoeadobejoe Posts: 17
    edited 2010-04-04 19:02
    GWJax & Kwinn,

    Thanks very much for your ideas. One thing, if it helps, would be for me to have two separate stamp BS2, operating independently, so that each would drive 8 motors/actuators...let me know

    AdobeJoe
  • GWJaxGWJax Posts: 267
    edited 2010-04-04 20:07
    Really there's no need for 2 BS2's you can use one and run 2 MOSFET H-bridge circuits to drive the sets. This will cut down on the massive amp rating you need to drive all 16 motors. The reason I would go with MOSFET's is because they only rely on voltage and not current to switch them on thus making them faster and more reliable than the traditional transistor h-bridge designs. By using an opto-coupler chip to turn on the h-bridge you just have eliminated the risk of shorting or over heating your BS2 should you have a short or current overrun in the motor drive circuit.

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • kwinnkwinn Posts: 8,697
    edited 2010-04-04 21:25
    adobejoe, happy to help out.

    I must point out that unless the linear actuators you are using are excruciatingly slow there is no need to drive more than one motor at a time, and driving each motor in turn can reduce the peak power requirement, simplify the design, and opens up the possibility of a better control over panel positioning.
  • GWJaxGWJax Posts: 267
    edited 2010-04-04 23:32
    Very true kwinn. It all depends on how the solar panels are mounted. I would even go to the point to have a self positional circuit to search out the brightest light source for each panel to get the most voltage out of the sun. Also if the liner actuator are too fast then incorporating a PWM circuit or program it into the software will correct this.

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • adobejoeadobejoe Posts: 17
    edited 2010-04-05 01:07
    Kwinn & GWJax,

    Good point, and since I am becoming more proficient with the programming, so I could just modify the code and use additional I/O pins. Say, rotate 4 panels at a time, in 15 minute increments, means I need 4 relays, each relay to control 4 panels? Now, what I need is a make and model for a relay that will operate under the 5 V from the output, and switch for 12 V/4x1200 ma or 4.8 amps, say 12V and 5 Amps on the motors. Where can I acquire a make and model to do this? Solid state or mechanical? Do you have a reference?

    More challenging, is I need to reverse direction for one move of the panels back to home. What is wire diagram to do this?

    Thanks for help, I can try to send a pic tomorrow from another PC.

    AdobeJoe
  • kwinnkwinn Posts: 8,697
    edited 2010-04-05 03:09
    @adobejoe

    While my preference would be to control the motors with solid state devices the relay circuit I posted will allow you to run the motors in both directions, and if your relay coil driver circuit (like the TPIC6595) can turn individual relays on and off you can drive one or more rows or columns of 4 motors at once, or multiple rows or columns at once.

    If you have a circuit that can monitor the voltage and current from the panels you can use the BS2 to calculate the power output from the panels and in essence use them as the position sensor. As the four panels moves through their range the power will reach a peak at the point where they are in the best alignment with the sun. By adjusting each panel group to it's peak you can extract the maximum power from all the panels.
  • kwinnkwinn Posts: 8,697
    edited 2010-04-05 04:16
    @adobejoe, you might want to consider using a single H bridge to control speed and direction with 16 optoisolated triac drivers and triacs to select the motor to drive. A dual triac output optoisolator costs about $1.70, and a 4A triac $0.65 for a total of $1.50 per motor.

    Also would be a good idea to measure how long it takes the linear actuator to go over it's full range of travel. That will determine if controlling each motor in sequence is practical.
  • adobejoeadobejoe Posts: 17
    edited 2010-04-07 01:48
    Kwinn,

    Took me a few days to digest your image of 4/3/2010, but I finally have got it through my thick skull. Yes, I understand 8 single pole relays appear to be able to do the job, where each controls one group of four motors in the forward directions, or reverse. I can easily modify the software code. Thank you for that diagram!

    The optoisolated triac drivers...aren't they only for AC circuits? I assume this is some LED sensing operation?

    I am still confused about whether I should do this with solid state or mechanical relays. I bought at radio shack today a Tyco OMI-SS-212D just to play around. It is mechanical rated at coil voltage 12 VDC nominal coil current 60 mA. Pickup drop out voltage is 9.6//0.6 VDC. Not sure exactly what this means, but I know it switches at less then 9 V, because I tested it.

    My STAMP I/O pin outputs 5 V, and 25 ma (sink) or 20 mA (source). Dumb question: Difference between sink and source? Can this output trigger or switch a relay directly, or do I need to trigger a 12 V with a transister?

    Secondly, the group of 4 motors (linear actuators) should draw about 4.8 amp no load, but I should probably design higher, like 10 Amp?

    AdobeJoe
  • GWJaxGWJax Posts: 267
    edited 2010-04-07 02:39
    OK sorry it took me so long for the circuit or at least the Hbridge. To answer your question about using a mechanical switch is really a bad idea if you want your circuit to last a long time. This reason is that the relays are slow in making contact, arc, and will break down, when using a PWM signal a loud clicking and arcing will occur. The circuit I made will correct all of this and will really handle up to 8 motors as long as a large heatsink is on the power MOSFET's. I'm also attaching a quick diagram for using an optoisolator circuit. You can also see this in the works in one of my youtube videos as well here:

    One the schematics TP1 is A and TP2 is B these are where the signals come from your stamp to run it from CC to CCW and Stop. With this circuit never turn both A&B to a 1 Logic state or 5v to say. below is the truth table for the circuit

    Function | A | B
    Stop | 0 | 0
    Forward | 1 | 0
    Reverse | 0 | 1
    Not
    Allowed | 1 | 1

    all caps are 25V and all resistors are 1/4 watt

    Hope this helps you out.
    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
    433 x 353 - 7K
  • kwinnkwinn Posts: 8,697
    edited 2010-04-07 02:52
    adobejoe,

    Re >> The optoisolated triac drivers...aren't they only for AC circuits? I assume this is some LED sensing operation?

    Triacs are generally used for AC circuits but they can also be used in DC circuits for some applications. In your case the triac is useful because it can conduct current in both directions. Once you trigger (turn on) a triac it remains conducting until the current through it drops below a threshold value. If you put the motor and triac in series between the legs of the H bridge you can use the H bridge to control the direction and to turn off the current through the motor and triac. Once that happens the triac will not conduct until it is triggered again.You could even use a single double pole double throw relay in place of the H bridge with the 16 triac circuits.

    The 12VDC nominal coil 60mA relay spec refers to the normal operating voltage and current of the relay coil. The Pickup drop out voltage is the minimum voltage the relay is guaranteed to turn on and turn off at. It may operate at lower voltages but it is not guaranteed.

    The sink current is when the load is between the +5V and the pin. The pin then sinks that current to ground.
    The source current is when the load is between the pin and ground. The pin then sources the current to the load.
    You will need a driver chip between the STAMP and the relay coils. A ULN2803 using 8 STAMP pins or a S/P like the TPIC6595 using 4 pins.

    Using a relay that has contacts rated for about twice the expected current is a good idea. If you are only activating four motors at a time then an 8-10A contact rating for those 4 relays is a good idea. You could get away with a lower rating (2.5A) for the other 4 relays but it is usually simpler to make all 8 relays the same.
  • GWJaxGWJax Posts: 267
    edited 2010-04-07 05:56
    Here is an update for the Hbridge and the Opto circuit for the BS2

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • adobejoeadobejoe Posts: 17
    edited 2010-04-08 00:38
    @GWJax,

    Thanks for these diagrams. I will have to study--be patient. Stuff like this takes more then a few days to sink in. I sense this may be the way to go, to eliminate the problems with mechanical switching (arcing, etc), but I just to study to understand how this would work. One concern is that I only have 16 I/O pins on the stamp, and three are dedicated to the DS1302 chip, so I have 13 available, and I am trying to rotate 16 panels.

    Your circuit diagram with the Mosfets shows four motors (S1-S4) in parallel, so they would rotate together? The circuit is hard wired to those four motors...the triac drivers (your other diagram) would all connect to the single H-Bridge...to the same four motors? I need to rotate four sets of four as in the Kwinn diagram.

    @kwin,

    Your setup with 16 motors makes complete sense, just trying to couple with the stuff from GWJax.

    AdobeJoe
  • GWJaxGWJax Posts: 267
    edited 2010-04-08 03:04
    AdobeJoe, The second circuit is the optocoupler driving circuit not a triac circuit. a triac circuit would need both -v and +v to operate it just like you would do with a SCR bu the SCR once triggered it remains on until you cut the power.

    When you combine both of the circuits it only takes 2 pin off the BS2 so to drive the 16 motors you will need to build 4 of these circuits. With that said you are only using 8 I/O pins to control the motors.

    The Hbridge circuit should be able to take on 8 motors but this is pushing the circuit to it's limits. Now if you use the Spin chip you can operate all the siginal lines at the same time using 4 COGs but then there is a learning curve on the programming which I'm still trying to learn. If you can get your hands on the BS2PX24 then running your routines will increase about 1.5 times or so. This is my BS of choice.

    The motors in the circuit will move at the same rate or real close to it depending on the resistance of the motors coils. What I would do is measure the resistance of each motor and apply a resistor of for the correct value so each motor has the same resistance at at least a 1% tolerance between them and make sure you use at least a 5-10 watt resistor for these to be on the safe side. The Hbridge will output at around 32 Amps so heat sinking these MOSFETs are a must.

    Did you look at the youtube video of mine that shows how the optocouplers work? if not view this video to get a better understanding on how it works. If you need a detailed description how everything works just let me know and I'll step you through each process.

    Keep us informed on what you will do and how things are working. If you want to share your source code with us we can help you out there as well.

    One other thing is that you must connect all grounds together, that is including the BS2's Ground. If these are not connected then the circuit will not work with the BS2. This was just a little FYI in case you did not know it.


    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • kwinnkwinn Posts: 8,697
    edited 2010-04-08 03:08
    @adobejoe, the circuit that GWJax posted would run 4 motors in parallel. You could use 4 opto isolators and 4 8A to 10A triacs to select one of 4 groups of 4 motors to power.
  • adobejoeadobejoe Posts: 17
    edited 2010-04-09 00:03
    GWJax & Kwinn,

    Thanks for correspondence. Did look at the Utube and that helped some.

    I am discussing this with a local electronics shop. Either have them build it, or decide to do it myself. The cost on the H-bridge can't be too expensive, and, yeah, I would need four, one for each bank of four motors.

    A couple of other concerns is we get very cold here in winter, like -20 deg F, but it would be in an insulated battery box, so maybe not too big an issue.

    I will mull it over the weekend, and decide what to do.

    THANKS for your help.

    AdobeJoe
  • GWJaxGWJax Posts: 267
    edited 2010-04-09 11:27
    The temp and storage of this circuit can operate at a range of -55 to +175 C so your being outside will not affect the circuit as long as it's weather proofed. I'm glad that the video helped you to understand working with the opto's with the BS2

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
Sign In or Register to comment.