Shop OBEX P1 Docs P2 Docs Learn Events
Basic 2 Program — Parallax Forums

Basic 2 Program

NWUpgradesNWUpgrades Posts: 292
edited 2005-03-04 20:53 in BASIC Stamp
Does anyone know of a simple program to make a stepper motor rotate at various speeds CW and CCW? I have the Homework Board and a BiPolar stepper Controller. The stepper controller has 2 wires, one for step and the other for direction. I do know about programming, but I just need a simple solution to get started. Thanks in advance for any help.

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-04 16:28
    Aha! I found your question that hasn't gotten answered yet. Well, it HAS been more than 24 hours. Let me give it a try.

    No, nobody knows of a simple program to make a no-brand, no-part number stepper motor rotate at various speeds CW and CCW -- especially if you have some generic, no-brand, no-part number "BiPolar Stepper Controller" chip in the middle. I'm not complaining that you left out the manufacturer and part numbers in your question, just trying to explain why it can't be answered unless you give us the manufacturer and part numbers.

    I think this is why no-one has answered your question already. First of all, I understand that some stepper motors CAN be used with the BS2 -- but I don't know of manufacturers or part numbers that will work. Next, that Controller in the middle seems like a good idea to me -- but if we don't have a manufacturer name or a part number, we can't help.

    BS2's are more typically used with Servo motors, so the Stepper motor question probably whooshed past a lot of the regular people who answer questions. Thus it's taken a while to get back to you.

    Even so, I'm sorry nobody responded yesterday. We really do try.

    Oh, and I don't work for Parallax, I just really like their parts and support.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-04 16:41
    Hmmm .... I was sure I posted a response to this question yesterday, but it is nowhere to be found. Let me try again:

    What stepper controller are you using?

    That has great impact on your question. Some are controlled through a serial link. Some want TTL direction and step controls. This stuff matters.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 16:54
    I am using Kit-158 from www.kitsrus.com. Here is a link to the .pdf file. http://www.kitsrus.com/pdf/k158.pdf
    They say to look in various places on the web, but I am having no luck. I am sure the programming can be done. If someone can just point me to an example or 2 I would greatly appreciate it. The motors I am using are all smaller motors from Panasonic and Epson printers. Thanks again in advance for any help.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 16:57
    One other thing, the Stepper Motor Controller has 1 wire out for Step, and 1 for Direction. I am able to wire my motors to the Controller and get CW and CCW action using Pulsout, but only for the Step, not the Direction.
  • steve_bsteve_b Posts: 1,563
    edited 2005-03-04 16:58
    The direction pin is probably a logic state.· So hold it high for CW and hold it low for CCW....just an assumption

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 17:03
    Thanks, But could you send some specific code that I can use just to get started? I have knowledge of programming Servos, but not Steppers. Thanks again.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-04 17:50
    The docs for that controller are pretty skinny ... perhaps you should ask them for better support.· That said, I think this will get you going -- but you may have to tweak it as I don't have one of those controllers.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
     
    StepperDir      PIN     0                       ' direction control
    StepperMove     PIN     1                       ' movement
     
    CW              CON     0
    CCW             CON     1
    
    idx             VAR     Byte
     
    Reset:
      OUTPUT StepperDir
      HIGH StepperMove                              ' move on high-to-low transition
    
    Main:
      StepperDir = CW
      FOR idx = 1 TO 100
        PULSOUT StepperMove, 500
        PAUSE 5
      NEXT
     
      StepperDir = CCW
      FOR idx = 1 TO 100
        PULSOUT StepperMove, 500
        PAUSE 5
      NEXT
     
      GOTO Main
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 19:31
    Live and learn. I know what you mean about the details being sketchy. I will in the future try to find better resource for inexpensive controller boards. I do like the idea of putting them together myself. Does Parallax carry any boards of this nature? I will geive this code a try later today and let yu know. Thanks for the help.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 19:51
    I tried this and it partially worked. With 4 wires, I connect 2 to each terminal. When the first set of 2 are connected I can get CW rotation. However, When I connect the second pair it all ceases to work. I have swapped my wires and still get the same thing. Does Parallax carry an inexpensive controller board that can be used with the Basic 2 Stamp? If so, please point me to it. Thanks.
  • dandreaedandreae Posts: 1,375
    edited 2005-03-04 19:56
    Here is a link to the Bi-polar motor controller that we have here at Parallax:· http://www.parallax.com/detail.asp?product_id=30004·.

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com

    ·
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 20:14
    Here's a strange twist to the whole scenerio. I grounded the motors to the Homework Board. I seen somewhere that it says to do this. I can hook up of my six total wires and this code works just fine. I thought I found the 2 that are ground and have 4 wires left. How can this thing possibly work with only 2 of the wires connected? As soon as I connect the other 2 wires, the motor acts as if it wants to move but is seizing up. I am really confused now.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 20:24
    I figured it out!!!!!!!!!!tongue.gif·For future reference, which I am sure you are already aware. When using a Unipolar Stepper motor The motor Gounds AND the Step/Direction Grounds must be connected to the Homework Board. Once I did that everything functioned the way it is suppose to.

    One last question on this line: How do I adjust the speed/step sequences with the code you sent? Thanks for all your help and now I know I will be purchasing from Parallax in the future.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-04 20:39
    Excellent! And thanks for the update, we all can learn from other's experience.

    I would guess the speed is controlled by how fast you do the steps -- the PAUSE 5 pauses 5 milliseconds, if you pause less time you may be able to speed it up.

    And each step moves a certain number of degrees -- you may have to experiment to find out how many. So then positioning is just keeping track of where you start, and then how many steps (degrees) you need to move to the new position.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-04 20:41
    I forgot to ask one other thing. How do I get the Program to stay in the Basic2 chip on the Homework Board? It runs fine as long as the Program is running, but if I shut it off and press reset, the motor runs continuously CW.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-04 20:53
    Well, actually the program is ALWAYS stored to EEPROM on the BS2 board. So whenever you press RESET the program always restarts from the beginning. Even if you've removed power and put it back on.

    Now, the symptom you talk about does happen. One common fault is to 'brown-out' the BS2 by turning on a motor, or a servo, which is connected to the same power supply the BS2 is using. The BS2 then resets, comes back up, and starts over at the beginning. Since the first thing your program does is go CW, your program starts to go CW, Resets, then starts CW again. You might want to add a 10 uF, 20 uF, or 220 uF capacitor between the supply lines for the Stepper motor to prevent its turning on from resetting the BS2. A low battery can also cause this.

    A good defensive programming measure on the BS2 is to have an LED under BS2 control.
    Then, when you start up the program, blink the LED. Thus you can see when RESET happens.

    You could also put this at the beginning of your program:
    SEROUT 16, $4054, [noparse][[/noparse]"Program Starts", CR] ' So if you see lots of "Program Starts" you know the BS2 is resetting.
Sign In or Register to comment.