PDA

View Full Version : Basic 2 Program



NWUpgrades
03-04-2005, 02:16 AM
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.

allanlane5
03-05-2005, 12:28 AM
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 Williams
03-05-2005, 12:41 AM
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

NWUpgrades
03-05-2005, 12:54 AM
I am using Kit-158 from www.kitsrus.com (http://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.

NWUpgrades
03-05-2005, 12:57 AM
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_b
03-05-2005, 12:58 AM
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."

NWUpgrades
03-05-2005, 01:03 AM
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 Williams
03-05-2005, 01:50 AM
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

NWUpgrades
03-05-2005, 03:31 AM
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.

NWUpgrades
03-05-2005, 03:51 AM
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.

dandreae
03-05-2005, 03:56 AM
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 (mailto:dandreae@parallax.com)
www.parallax.com (http://www.parallax.com)

·

NWUpgrades
03-05-2005, 04:14 AM
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.

NWUpgrades
03-05-2005, 04:24 AM
I figured it out!!!!!!!!!!http://forums.parallax.com/images/smilies/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.

allanlane5
03-05-2005, 04:39 AM
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.

NWUpgrades
03-05-2005, 04:41 AM
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.

allanlane5
03-05-2005, 04:53 AM
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, ["Program Starts", CR] ' So if you see lots of "Program Starts" you know the BS2 is resetting.