View Full Version : Using external (i.e non parallax) stepper drivers with BS2 module

09-18-2008, 10:22 AM

First of I want to say I have searched the forums a lot but to no avail before posting this question.

The main question I have is can you or rather how hard would it be to control a stepper motor driver that rquires a step and direction signal via a Basic Stamp? I realize that parallax offers stepper motor drivers, however, I need something with a little more juice, like a gecko driver for a NEMA 34 size motor. These drivers require a step and direction signal that usually comes from a com port on a pc. I beileve the signal is TTL signal.

I have a lot of expierience with CNC equipment and stepper motors but I am just now getting into robotics and automation. I just recieve my discovery kit a few days ago and so far so good. I do have coding experience as well but to extensive.

Would it be as simple as sending a high or low signal to the step and direction ports while the number of pulses determince the number of steps?

I would love any feedback if you have done anything of the sort. Sample code, ideas anything would help. The reason I ask is I would love to use the basic stamp to control 2 steppers for very simple tasks that would not need a computer. I am willing to work on it so if you could just send me in the right direction that would be great!

Thank you for your help!!!
Regards Brian


09-18-2008, 09:28 PM
Well,,, Brian,,, I don't know how to address the question of 'how hard', there are no units for that. BUT!
What you are trying to do has been done. Your question is unclear but I've got two answers for you.
If all you need is a direction bit and a pulse train into a controller then it's a simple problem to solve.
If you are looking to get from two control bits to the four or six wires on the stepper then it's not so simple. You need the stuff in between.
So, what do you have, specifically?

A wise man told me; "All electronics are made to work by magic smoke.

Don't ever let it out as it's·very difficult·to get it back in."

Chris Savage
09-19-2008, 12:02 AM
gth629e said...
Anyone? lol
Please allow forum members time to reply to messages.· Prompting for replies in under 2 hours isn't going to get them any faster.· It could take·2 to 48 hours to get a reply depending on when you post it.

Chris Savage
Parallax Engineering

09-19-2008, 12:58 AM

Thank you for your reply. I don not wish to control a stepper motor directly from the Basic Stamp. You are right that would be quiet laborious on the BS2 module and I imagine writing the code for that operation wouldn’t be easy either.

What I want to do is to communicate to the stepper motor controllers via the bs2. The bs2 module would be taking the place of a computer. The stepper motor controller receives TTL signals (Step and Direction) and interprets that into the alternating coils required be a stepper. So the stepper controller/driver should be doing most of the “work”.

Even so I am unsure how the BS2 module would handle this operation. Should I use the PULSOUT command or a simple HIGH and LOW for different durations of time, or something else?

Maybe that made more sense and thank you for your time and any future help!!


09-19-2008, 04:39 AM
Do you have a link to documentation for the controller? That would be a great help.

When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

09-19-2008, 09:35 AM

Here is an example of a stepper driver http://www.geckodrive.com/product.aspx?c=3&i=14458, of course there are many different kinds but most operate on a standard Step and Direction signal such as these.

Here is the Data sheet for that product http://www.geckodrive.com/upload/G201-REV-16-MANUAL.pdf


09-19-2008, 10:38 AM
Would it be as simple as sending a high or low signal to the step and direction ports while the number of pulses determince the number of steps?

Yes. And the code is not complex, BUT the Stamp may or may not be fast enough or regular enough, *depending on your needs and code requirements*. Depending on your skills and desire to learn, you might consider an SX or a Propeller, where you would be able to devote many "background" tasks to running stepper pulses, tracking limit switches, etc, and let the "foreground" handle input, decision making, logic, etc.

That said, for quasi- "plug n play", and if $$ are not too big a concern, a Stamp and PWMPal would work nicely -- the PWMPal can handle the PWM out to the stepper driver and the Stamp can run the dir/en/status pins and logic/input.

When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

09-19-2008, 11:26 AM

Thanks so much for your help. I was just found the pwm pal and was thinking the same thing but was unsure then read your post. I am very eager to learn and am working my way through the discovery kit. I would like to learn to program an SX or Propeller but it seems a little harder at this point. That is why I was starting with the basic stamp.

The process I was wanting to use this for is a very simple "back and forth" motion using steppers. I chose steppers because they are pretty easy to operate in an open loop system and still maintain some level of accuracy. I am trying to design the system so that there would be no multitasking or background tasks. However, it would be nice to have digital inputs constantly being checked. You say the PWMpal would allow that? I will order one and play around with it. Do you think I could use a PWMpal in conjustion with a BS2 PLC? That would take care of all my I/O's and the motor control.

Thank you for your time, that will probably cover it for now when I get the pwm pal I might need help coding, hopefully I can figure it out though. In your opinion(s) how much more difficult is coding for the SX or propeller compared to BASIC language? Again, thank you for your time!!


Mike Green
09-19-2008, 12:11 PM
The PWMpal can produce output pulses of a specified width and repetition rate. It can also count pulses, but it doesn't automatically use the count to change anything. It's up to the Stamp to periodically request the count and do something with it.

The PWMpal isn't really compatible with the Stamp PLC. The I/O pins are allocated differently. P8-P11 are outputs, so they match up, but P12-P15 are inputs for the PWMpal while they're outputs for the PLC. You can still use the PWMpal from that standpoint as long as you don't use the PWMpal counter or motor control functionality. P0 is used by the PWMpal for control and will conflict with PLC ADC use.

The PLC certainly is a convenient package. If it works for your other needs, it's a good way to go.

You can certainly control a stepper, particularly one with a step and direction signal control, with a Stamp by itself. You'd have to interleave any stepping with any other operations that need to happen at the same time, but people have done this before. It would help to use one of the faster Stamp modules like the BS2sx, BS2p, or BS2px. I'm a proponent of the faster the better unless the cost or power consumption is too high. In this case, I'd go for the BS2px in the PLC.

Post Edited (Mike Green) : 9/19/2008 5:18:16 AM GMT

09-20-2008, 12:58 AM
I understand what you are saying about the conflict of the plc and the PWMpal, the pins would seem to conflict. I plan on using a BS2px or sx. I am skeptical of using basic stamp in itself without the assistance of the PWMmal because I may need to constantly be checking a few inputs. For example, lets say I just want to run the stepper attached to a linear screw until the device comes in contact with a limit switch etc.
Again, I can probably work my way around this as steppers can be pretty accurate, so on startup I could have it find “home” and then it shouldn’t lose its position after that. Actually at 19,000 instructions per second I could probably put a small IF THEN and Loop in there because I only need maximum of 500 RPM from the motor. Though it would be nice to be able to have the user interface buttons monitored periodically.
One last thing, and keep in mind I am still reading through the PWMpal documentation, but how hard do you think it would be to include a ramp up or ramp down into the signal. So that mechanically it would be safer and not so demanding on the motors?
Again, thank you all for your help and I can’t wait to get my stuff so I can experiment!!

Post Edited (gth629e) : 9/19/2008 6:04:06 PM GMT

Mike Green
09-20-2008, 01:38 AM
The PWMpal is really designed for use with servo motors and DC motors, not steppers. If you want to ramp up or ramp down the motor speed, the Stamp has to repeatedly change the PWMpal settings. There's nothing automatic involved.

I think you'll find that monitoring several switch closures while producing control pulses for the motor including ramping is pretty easy programming for any Stamp model.

09-20-2008, 11:20 AM
Thank you guys for all your help. I see what you mean about the PWMpal. Honestly I would have not complain with using dc motors with an H-brindge coupled with the PWMpal, hoever, reading through the forums it seems like feedback would be an issue. It seems like encoders are very demanding on any system, depending on the number of quadrants of course, but I would need at least 720 pulses per revolution to get the desired accuracy and precision. Thats why I decided on steppers. I built a CNC router and operate it in an open loop system and it heardly ever skips steps. If you guys know how I could use encoders I would love to hear about it, just to learn if nothing else.

Thanks Again!!

03-31-2009, 05:30 AM
I am in the same boat, as you. I am controlling an Easydriver with the BasicStamp2 to run a stepper, and have problems with RPM's. I didn't realize that stamp had a limited clockspeed until I read this post. I was wondering what route did you chose? 1. The pwmpal connected to the BasicStamp2, or 2. changing to a faster stamp.

Also, How much harder is the coding for the other stamps, like, the bs2px?