Shop OBEX P1 Docs P2 Docs Learn Events
control stepper motor_need help — Parallax Forums

control stepper motor_need help

temctemc Posts: 4
edited 2006-06-01 19:41 in BASIC Stamp
·hi there, i'm a newbie.I try to use basic stamp 2 and ULN2003 to
control a stepper motor. Any one can help me upload the circuit schematic
and source code...Thanks a lot..

I'm trying now..but dun know·whether I can·finish this task in time..

shakehead.gif

Post Edited (temc) : 5/28/2006 8:13:00 PM GMT

Comments

  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-28 20:12
    Details, please.

    Is it a bipolar or an unipolar motor?
    (Bipolar usually have 4 wires, unipolar 5, 6 or even more)

    What is the voltage and current rating?

    What are you trying to accomplish with it, and most importantly, when is your project due, and when were you supposed to start working on it.
    (Sorry, but this sounds like one of those 'I have a school project due tomorrow and I haven't started on it, yet. can spomeone please do it for me', and while we are all willing to help, we prefer to help those who are willing to do a proper attempt themselves.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • temctemc Posts: 4
    edited 2006-05-28 20:19
    I have 2 weeks, my small project is sth like a automatic rainshield.
    When the sensor detects the rain, the motor runs to open the cover and after the rain, it runs in opposite direction.
    some seniors suggest to use bs2, i did buy one and download some manual from parallax website,still reading it now. the code seems not very difficult, but I dont know how to make the circuit..what is the function of uln2003..

    the motor I got here is a unipolar (6 wires), 12V , 0.6A (by sanyo denki 103-718-0140)

    firstly i have to make the motor be able to run..then control the direction due to signal feedback·from sensor..
    sencondly, handling with the sensor. I found a circuit that make a "beep-beep" sound when it rains.is this possible to interface it with bs2? it used 9v battery.
    this is the schematic diagram of rain detect circuit :
    cc.jpg

    thanks for anyhelp smile.gif

    Post Edited (temc) : 5/28/2006 8:43:46 PM GMT
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-28 21:16
    I'm not too much into the Analog part of things, but I can tell you that most of the circuitry in that schematic is superfluous to your task.
    The 4 gates seems to be a oscilator of some sort. And as it is started by a signal on the one to the lower left, I suspect that what you need is the detector-grid, the rsistor and the cap under it.
    (Connect them as seen in the schematic)

    The transistors are there to function as an amplifier, and are also not needed.

    The ULN chip is a wonderful thing...
    smile.gif

    It contains a whole bunch of Darlington drivers(transistors) which can sink up to about 1A each.
    (It won't hurt to have some sort of cooling if it needs to do that for longer periods)

    I tried to search the Sankyo website, but unfortunately, it doesn't work with my browser, so I were unable to find any datasheets for it.

    Do you know how many coils/windings there are on the motor, and the colour/sequence on the wires attached to them?

    There will be one or two 'Common' wires. That one should be connected to 12V, and the rest of them to separate outputs of the ULN chip.
    Then you need to connect one I/O-pin on the BS2 for each of those wires, to the inputs on the ULN.
    That is the Hardware taken care of...

    Runing a unipolar stepper is done by energising each coil in turn, so that the rotor moves a fraction of a rotation for every step. (That is why we call them steppers)

    Assuming that there are 4 coils in the motor, we'll just use pins 0 - 3 (also collecktively known as OUTA)

    A quick and dirty stepping function might look like this:
    turns VAR Word
    
    DIRA = 15  , Sets the pins as outputs
    
    FOR turns = 1 to 1000
       OUTA %0001
       PAUSE 10
       OUTA %0010
       PAUSE 10
       OUTA %0100
       PAUSE 10
       OUTA %1000
    NEXT
    
    



    This will repeat the sequence 1000 times, with approx 100 steps/second.
    (the motor is probably capable of going much faster)

    Of course, the load might be heavy, and then we would want to 'half-step' the motor, which means we do this:

    turns VAR Word
    
    DIRA = 15  , Sets the pins as outputs
    
    FOR turns = 1 to 1000
       OUTA %0001
       PAUSE 10
       OUTA %0011
       PAUSE 10
       OUTA %0010
       PAUSE 10
       OUTA %0110
       PAUSE 10
       OUTA %0100
       PAUSE 10
       OUTA %1100
       PAUSE 10
       OUTA %1000
       PAUSE 10
       OUTA %1001
    NEXT
    
    



    And in this case we've added a step where both the current and the next coil is energised at the same time. Then we dump twice as much power into the motor, while only moving it half as far. This is GREAT for heavy loads.

    The third thing you should be aware of is 'ramp-up' and 'ramp-down'.
    Steppers doesn't like being forced to run at max speed immediately. In fact, if you try, they will often slip and miss whole sequences.

    so it might be a good idea to start it slowly, possibly half-stepping at slow speed, then do two or more speed increases by shortening the delay after a few hundred sequences., until you get it to the speed you want.

    Hope this makes some sense?

    Edit:
    BTW: It never hurts to 'de energise' the coils afterwards with a
    OUTA %0000
    
    DIRA 0
    
    



    Also, the ULN2003 may be a model which can't deliver more than 500mA on each output. In that case you may have to connect two outputs in parallell to get the required current. (Most ULN2003 chips allows this) Unfortunately, there are only 7 Darlingtons in each IC, so in that case you'll need at least two ICs.
    (Spread the load evenly amonst them)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...

    Post Edited (Gadgetman) : 5/28/2006 9:28:43 PM GMT
  • SuperwormsSuperworms Posts: 118
    edited 2006-05-28 21:25
    what does the moter look liike. i am trying to find some info for gadgetman, and anyone woh might be helping


    EDIT:
    if possibvle pleas attach multiple pictures from different angles of the stepper and a pic of the lobel on the stepper
    thanmks


    Post Edited (superworms) : 5/28/2006 9:29:57 PM GMT
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-28 21:29
    I seems to have searched the Sankyo site instead of the Sanyo site, not that it helped...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • SuperwormsSuperworms Posts: 118
    edited 2006-05-28 21:30
    lol
  • temctemc Posts: 4
    edited 2006-05-28 21:45
    thanks gadget and worm, I think this motor has 4 windings. it has 6 wires, 1 white, 1 black, 1 blue, 1 red, 1 white with red, 1 white with blue idea.gif ..there are some marking on each wires : the pure white marked V, black one was not marked, the others are A,B,C,D.

    cc2.jpg

    cc3.jpg

    the circuit of rain detect here (i havent soldered it yet):
    instead of connect it to the small speaker 8ohm, 0.2W , can I connect it to one pin of bs2 to generate an input pulse..

    cc4.jpg
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-28 22:14
    A quick way of finding the common is to measure the resistance.

    Write a table like this
          Un   V   A    B    C    D
    Un
    V
    A
    B
    C
    D
    
    



    Then measure the resistance between the wires.

    If V is the common one, you willonly measure halv as much resistance between it and any other pin as you will between the other pins.

    The unmarked one can be a sensor, or it can be a chassis Gnd?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...

    Post Edited (Gadgetman) : 5/28/2006 10:17:01 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-28 22:54
    How about... (see attached drawing)

    Regarding the "rain detector", the first oscillator is enabled by the water making a current path across the pattern area, resulting in a tone, and then the second oscillator modulates the first osc's output, resulting a 'beep, beep'.




    Post Edited (PJ Allen) : 5/28/2006 11:07:00 PM GMT
    595 x 268 - 60K
  • temctemc Posts: 4
    edited 2006-06-01 15:25
    Using 2 parallel uln2003, my motor can run now.smilewinkgrin.gif
    One question, can I connect a 3.4 volt source to one pin of bs2?
    you see the schematic of "rain detect" circuit, can I connect 2 wires ( that's used to be connected to a small speaker) to one pin and common ground? the potential voltage difference between 2 wires is 3.4V.. so this pin can be read as High.
    it's urgent..tmr I have to show sth to my supervisor..skull.gifsmilewinkgrin.gif
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-06-01 19:41
    The ONLY thing you want to use of that rain-detector is the 'detector-cell', the resistor and the Cap below it.
    Whatever comes out of the transistors is pulsed rather rapidly, and isn't really a good signal to feed to the BS2.

    Instead, scavenge those three components and hook them up to the Stamp such that the the Input on the gate marked '1' goes to an I/O-pin on your Stamp.
    It may be a good idea to connect a small resistor (say, 200 - 300 Ohm) between the circuit and the Stamp, though, just to make certain that you don't get too high currents flowing.

    Anyway, the two wires used to connect to a speaker in that schematic are definitely no go as one is the Vin and the other is the Collector of the Transistor, and neither have anything to do with Gnd.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
Sign In or Register to comment.