Shop OBEX P1 Docs P2 Docs Learn Events
How to run 2 stepper motors in one bs2??? help please — Parallax Forums

How to run 2 stepper motors in one bs2??? help please

arturojarturoj Posts: 4
edited 2008-11-28 15:56 in BASIC Stamp
Hi, I'm new in this programming thing, and I have a school project where I need to run 2 stepper motor but I just have one Homework board with the BS2.
I can controll 1 motor, and I'm using a Darlington buffer ULN2003A, and the external DC source, and it's working OK.

I thought that if I hooked 2 Darlingtons I could control both motors, one with each buffer, because I need them to do direfent command while they work at the same time. But it didn't work.

I supouse there are 2 reasons it's not working,
I'm not conecting correctly the motors, I am going to draw and take a picture of my wiring.

And, this one I'm sure I'm not doing it correctly, I don;t know how to tell the BS2 to send the command at the same time to two diferent motors, for example, while a Loop, I need that the other one turns a couple degrees to the left, and stay there for x seconds, and then again to the left or the right.

What I'm trying to build it's like a little "robot" that "paints streets, so I will will program how much time it must stay turning left, right o straight ahead, and the other motor, must make a marker, to up and down for certain periods of time, so it will "paint" the yellow line in the middle of the street, the one that goes straight all the way or like in short lines, where you can pass the other car.


I'll appreciate very much any help, advice, comments, and hints on which commands to use, so I'll investigate them and learn how to use them

Thank you

Arturo

Comments

  • SRLMSRLM Posts: 5,045
    edited 2008-11-13 00:04
    Whatever code that you have, please...
  • arturojarturoj Posts: 4
    edited 2008-11-13 13:34
    i'm using the BS2 language 2.5. I've managed one stepper with the pulseout comand for exampl. I conected it and the following comands work well
    Bs2. 2,5

    Pulseout 15 ,2500
    Pulseout 13, 2500
    Pulseout 14, 2500
    Pulseout 12, 2500

    And well the for next x amount of times depending on how much I want it to turn. With that command it will turn one step.

    The common wire is conected with the last port of the darlington buffer and the negative wire of the external power source.

    I will conect it and take a picture and make the wiring diagram, it will be easier for me to explain myself.
  • SRLMSRLM Posts: 5,045
    edited 2008-11-13 15:56
    Look at the stepper motor product page here. It has timing diagrams and sample code. The code that they use can be used for up to four steppers (4 I/O pins per stepper). Note that they use an interface chip: a good idea for you too. I measured a stepper motor of similar size to the one listed, and found that it drew .9A while running, much too much for the BS2 to handle directly.
  • arturojarturoj Posts: 4
    edited 2008-11-13 18:20
    SRLM said...
    Look at the stepper motor product page here. It has timing diagrams and sample code. The code that they use can be used for up to four steppers (4 I/O pins per stepper). Note that they use an interface chip: a good idea for you too. I measured a stepper motor of similar size to the one listed, and found that it drew .9A while running, much too much for the BS2 to handle directly.

    Thanks for the tip, I'll read it right away.

    I'm using an DC power source that gives 300mA, that maybe a problem, but I will get a new one in the afternoon.
    I'll attach my schematics on how I'm connecting the entire circuit, and a picture.
    On the first diagram it's how it is already conected and working with one motor, thats what I wrote to test it.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DEBUG "2500"
    tape VAR Byte

    FOR tape = 1 TO 50
    DEBUG ? tape
    PULSOUT 15, 2500
    PULSOUT 13, 2500
    PULSOUT 14, 2500
    PULSOUT 12, 2500

    NEXT
    DEBUG "clockwise"
    END

    IMG_1856.jpg
    IMG_1854.jpg
    The second schematic is how I think I must connect the second motor, but I'm not sure where or how to feed the current to the second Darlington, and I supouse that where the number 1 is, I must connect it to the Vss like in the first Darlington


    So I need to finish these connection, and have an idea on how to program both at the same time but doing diferent stuff.

    I'll read what SRLM told me to research, and keeo trying.

    Thanks
  • SRLMSRLM Posts: 5,045
    edited 2008-11-13 21:17
    The L293D is rated for 600 ma continuous, and something about 1.2A spikes. I found that my motor was drawing 900 ma continuous, and still have to fix that.
  • arturojarturoj Posts: 4
    edited 2008-11-15 00:11
    Some more help??
  • Lab RatLab Rat Posts: 289
    edited 2008-11-15 01:17
    i agree more help please the page on the stepper motor only had the code to run a single stepper motor not two
    if it was continuous revolution servos you would use the boe bot program

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Parallax posesses power beyond belief.

    Believe in it.
  • SRLMSRLM Posts: 5,045
    edited 2008-11-15 04:46
    The stepper motor sample code just shifted the bits in an out register. You can add three more fairly easily, just by choosing other sets of pins.
  • Lab RatLab Rat Posts: 289
    edited 2008-11-15 13:47
    oh
    does that mean i should use a shift register since i would also like to know

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Parallax posesses power beyond belief.

    Believe in it.
  • SRLMSRLM Posts: 5,045
    edited 2008-11-15 16:31
    @Lab Rat


    It's up to you. Try it, see how it works in your setup, and make a decision. That's part of the fun of robotics: experimenting for yourself. It's okay to make mistakes if you learn from them.
  • blacksheep45blacksheep45 Posts: 41
    edited 2008-11-28 13:43
    Hello,

    Does anyone know how i would be able to add a second motor to a professional development board, and are their any specific pins on the bs2p40 that i would have to connect it to?



    Shaun
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-28 15:56
    Have you downloaded the schematic for the Professional Development Board? It shows how the motor driver is set up. There are no pre-assigned connections to the Stamp, so you can connect the existing or a 2nd driver (L293) any way you want. Commonly, because there are 4 signals involved, these are connected to a group of I/O pins that are multiples of 4 (0-3, 4-7, 8-11, 12-15, etc.) With the BS2p40, you have 2 sets of 16 I/O pins. You can access one set at a time and switch between them. You might use a group of 4 I/O pins from one set for one motor and the same group in the other set of I/O pins for the 2nd motor. That way, you could have subroutines for the various functions that you want and use the same subroutine for both motors, just changing the bank of I/O pins before calling the subroutine (using the MAINIO or AUXIO statements).
Sign In or Register to comment.