Shop OBEX P1 Docs P2 Docs Learn Events
help with simple stepper control for bs1 — Parallax Forums

help with simple stepper control for bs1

BlakeBlake Posts: 74
edited 2008-01-16 03:58 in BASIC Stamp
i am attempting to control a stepper motor with a bs1. I am very new at this.

The stepper is a 6 wire, four coil, unipolar with two common leads. So i have set it up with four tip120 darlington transistors with the bases on pins 4 through 7, the collectors to each of the four stepper leads (one for each coil in the motor), and the emitters to ground. This setup using 4 darlington tip120s is described in "physical computing", on page 262.

However, the stepper control example code for bs1 from parallax isn't working for me.

I don't quite understand all of the code so I would like to make a test code as simply as possible.

Would this work to turn the motor?:
'   {$STAMP BS1}
'   {$PBASIC 1.0}


  LOW 4
  LOW 5
  LOW 6
  LOW 7


Main:



  HIGH 4
  PAUSE 2000
  LOW 4

    HIGH 5
  PAUSE 2000
  LOW 5

   HIGH 6
  PAUSE 2000
  LOW 6

  HIGH 7
  PAUSE 2000
  LOW 7


  GOTO Main




Thanks,
Blake

Post Edited (Blake) : 1/13/2008 9:08:10 PM GMT

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-01-13 03:53
    Blake -

    A simple schematic of how you have it wired would be real helpful. I've never heard of "Physical Computing" so I can't go there to see what it says. Perhaps there is a schemtic in there you can scan and upload by attaching it to your next posting.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • phil kennyphil kenny Posts: 233
    edited 2008-01-13 05:25
    Blake,

    If you do post a schematic, be sure to show the Basic Stamp
    and what you have for a power supply. The stepper needs its
    own separate supply that can deliver the rated current.

    Using the Basic Stamp supply for the stepper isn't likely to be
    adequate.

    The code should work, although I don't know why you are
    energizing the winding connected to pin 4 twice.

    phil
  • BlakeBlake Posts: 74
    edited 2008-01-13 06:29
    Okay here is a diagram I drew for this circuit. If you need a more conventional diagram, I can try to do it. This is what I have actually made. I did not include the power supply to the 12 Volt Regulator. Currently this is a 12 Volt, 500ma dc power supply. I have tested the power supply with the stepper only by directly hooking it up to a coil and common lead and the stepper holds well. The second energizing of pin 4 in the basic code was a copy/pasting mistake.
    stepperdiagram.jpg
    I have been reading about this and I think I may need to energize two pins at once in a specific sequence (i.e. 1010, 0110, 0101, 1001).

    Any thoughts?

    Thanks,
    Blake
    763 x 555 - 117K
  • Beau SchwabeBeau Schwabe Posts: 6,569
    edited 2008-01-13 07:57
    Blake,

    First thing, is that you need current limiting resistors on p4,p5,p6, and p7 going to the base of the tip120's

    12V 36 Ohm = 333mA ... say 350mA ... as a good rule of thumb quadruple that... 350mA --> becomes --> 1400mA.
    The hFe (gain) of those transistors is about 1000. So we only need about 1.4mA of base current (1400mA/ 1000 = 1.4mA) ... lets figure 1.5mA Base current.
    Since a darlington transistor has two diode drops (1.2V), the formula would be...

    Current Limiting Resistor = ( I/O Voltage - Diode Drop ) / Base Current
    Current Limiting Resistor = ( 5V - 1.2V ) / 1.5mA
    Current Limiting Resistor = 3.8V / 1.5mA = 2533 Ohms = 2.5K resistor .... In this case I would used the closest standard resistor value of 2.2K or 2.7K


    The second thing that I see in your code... not a big deal, other than a hiccup... You have two instances that assign control to pin 4



    As far as your pattern.... you can get away with only one pin, or use a combination of one and two pins to achieve half-stepping.

    Half Stepping - (0001, 0011, 0010, 0110, 0100, 1100, 1000, 1001)
    Full Stepping - (0001, 0010, 0100, 1000)
    or
    Full Stepping - (0011, 0110, 1100, 1001)

    Note: The main difference between using 1 or 2 pins is that you have better torque control with 2 pins than you do with 1 pin... during half stepping the torque gets averaged.

    What's cool is that if you want to reverse the direction, you swap just the EVEN, or just the ODD bits.
    i.e.

    Forward = (A,B,C,D)
    Reverse = (A,D,C,B)
    or
    Reverse = (C,B,A,D)


    As far as manipulating more than one pin simultaneously, look into the PINS and DIRS commands.





    Also, you should have reverse biased diodes across the C-E junction of each transistor to minimize back emf effects that could damage·the transistors and/or the Stamp.


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

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 1/13/2008 8:15:24 AM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-01-13 08:15
    Blake -

    Here is a tutorial on stepper motors which is often referenced by those who are just learning about stepper motors. It is neither processor nor stepper manufacturer specific, thus it provides excellent generalized examples. Here is the link to that web site: http://www.cs.uiowa.edu/~jones/step/

    What you may need to do, before you go much further, is to "ring out" (check out the internal connections) of all of the wires on your stepper motor to ensure you know which windings are which. If I believe your wiring diagram, and Airpax follows what minimal conventions there usually are on the color coding of the wires, it's my suspicion that you may have the wrong two wires connected for common. More often then not the two common wires are the same color, or they may be black and red. You seem to have a green wire on you common connection. It's not impossible that green is one of the common wires, but I wouldn't also expect it to be a power winding wire as well, which seems to be the case in your diagram.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BlakeBlake Posts: 74
    edited 2008-01-13 16:51
    I will look into all of the advice and post an update. As for the wiring of the stepper, I believe I have it correct. I tested the resistance between the wires, looking for wire pairs with double resistance than normal, ,etc. Also, I found a wiring diagram for Airpax steppers (on parallax i think, in the bs1 application notes) and green and red are confirmed to be common. I will update soon.

    Thanks for your responses,
    Blake
  • BlakeBlake Posts: 74
    edited 2008-01-13 17:06
    Let me just add one thing. The reason I am posting in the first place is because I have tried the code above with the current configuration and I feel torque on the stepper (it is really hard to turn the shaft in any direction) but the shaft doesn't turn. It remains locked in place. So that's where I am, but I'll try your advice.

    Thanks,
    Blake
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-01-13 17:25
    Blake -

    Too bad you didn't mention that earlier. That points to one of two problems. What's happening is OPPOSING windings are being activated together, thus causing the "lock-up" instead of stepper advancement.

    One of these two things is the cause:

    1. Mis-wired coil windings

    or

    2. The binary pattern you are using to activate the coils is incorrect or out of sequence.

    In either case I would go back to the tutorial "Jones on Stepper Motors" and review both conditions. One of them nearly has to be the case.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • kelvin jameskelvin james Posts: 531
    edited 2008-01-13 18:40
    A quick look shows the brown and black on one coil, the yellow and orange on the other. Here is a link you might find useful.



    www.me.umn.edu/courses/me2011/robot/technotes/stepper/
  • BlakeBlake Posts: 74
    edited 2008-01-13 21:26
    While I am reading up on everything, I did a quick experiment.

    I uploaded the following code:
    
    '($STAMP BS1)
    '($PBASIC 1.0)
    
    Main:
    HIGH 4
    PAUSE 3000
    LOW 4
    PAUSE 3000
    GOTO Main
    
    
    



    When I upload this, during upload the stepper's shaft locks tight. When the upload finishes, the shaft stays held for another three seconds then becomes easily turnable as expected. But it never locks again after an additional three second pause. If I reset the BS1, it locks tight for 3 seconds, then never locks again. Shouldn't this code make it repeat 3 seconds locked, 3 unlocked, 3 locked, etc.?
  • stephenwagnerstephenwagner Posts: 147
    edited 2008-01-14 13:10
    Blake,

    Here is a link to the original BS1 & BS2 text. Application number 6 may be of some help. It is a BS1 controller for a unipolar stepper.

    http://www.parallax.com/Portals/0/Downloads/appnt/stamps/bs1Appnotes.pdf

    Stephen Wagner

    ·
  • BlakeBlake Posts: 74
    edited 2008-01-16 03:58
    Okay guys, not sure what happened exactly, but i was getting frustrated, so i unsoldered everything went out and bought a prototyping board and new tip120s and put it all back together and what do you know, it worked.

    Thanks for all the info from everyone it was really informative and I have read through almost all of it.

    Blake
Sign In or Register to comment.