stepper questions

ok hardware is arduino uno, im looking at the stepper.h include and since being fairly new to arduino was hoping someone could answer some questions.

  1. the pins with the designated sine wave symbol are the ones which can be used for PWM? Is that correct?

  2. If i use the stepper(100,5,6) shown in this web pages the pulse stream would come out of pins 5 and 6, but which would be positive and which negative or does it not matter?

  3. if i supply the arduino with 5v then the pulse stream would be 0 to 5, would that be correct?

  4. The set speed function of the stepper module, i take it this controls the freq of the pulses, the faster the pulses the faster the speed. Am i understanding that correctly?

What i am looking to do is inside this one machine i am working on is a Warner Electric Slo-Syn stepper, it is an older drive and i know that 20 pulses = 1 inch or travel and i want to use the arduino to control this stepper rather than the old archaic thing that is in the machine now. So I am trying to wrap my head around how the arduino works so i might be able to use it.

I would also like to see if i can put an encoder signal into the arduino as it is without any additional shields and then have the arduino compute the speed based on this encoder and use that to control this stepper. But first i have to understand the stepper module.

Of course please feel free to comment on any of these.

Thanks for any and all input you can provide.

yes, what web page, yes, what module?

you say warner slo-syn stepper as in the motor. then you say old drive. that might be worth it's weight in gold to you.

stepper motors are rated on power. stepper drivers are priced per the amp. 1 to 2 amp, $3, 3-4 amps $30. 5 amps, $30-50, 7 amps ? a gecko is about $150.

before you decide age makes a thing worthless, you might want to find out what a modern one might cost.

as for pronouns, we hate them. 'this webpage' not informative, you should post a link so we know what you are talking about.

I searched for your page... no joy.. arrived here

please post details of the motor and the existing driver.

since you are probably a bit new to this. you have a motor, simple enough. you need a DRIVER, this converts the power to pulses. it is NOT a controller. you need a CONTROLLER. this is where the step signals are created, the computer or some such.

A Driver can be the most expensive part of the CNC project on the electrical side.

1: yes. Some boards may also use small lines or dots.

2: I can't answer cause I can't tell what code you are talking about. Please show exactly what you are talking about.

3: that's right. The output of the pins is at the 'logic' voltage of the board. On an Arduino UNO, this is 5 volts.

4: same as 2.

PWM and the analogWrite() function have nothing to do with driving a stepper motor. There is no need to restrict yourself to the PWM pins.

Post a link to the datasheet for the motor you are using.

What stepper motor driver are you using - you cannot connect a motor directly to an Arduino.

Read through Stepper Motor Basics


Ok ladies and gents i was able to find the data sheets on the motor and drive. Here is the sheets on the motor and drive. The part i am refering to is laid out on page 15 of the manual where it shows the avail inputs to the drive, these inputs are: Pulse, Direction, AWO, OPTO

So I want a pulse train output from the arduino to control this drive. So here is the web page from this site that talks of using the stepper.h include and using 2 pins. I copied the example over to my first post which shows calling the stepper with Stepper(100, 5, 6)

So if i call the above method of using the stepper but instead of using 100 using 120 because the motor i am using is 120 ppr. Would i be able to using pins 5 and 6 to supply a pulsed output to the drive in question?

And i take it the setspeed, all that does is determine the freq of the output.

So now you have all of the avail manuals and such, can the arduino drive the above mentioned drive?

If the above will work, the next part is attaching an encoder to the arduino then using logic inside the arduino factor the speed from the encoder pulses. Can an encoder be put into these PWM pins?

mrtweaver: So if i call the above method of using the stepper but instead of using 100 using 120 because the motor i am using is 120 ppr.

If the above will work, the next part is attaching an encoder to the arduino then using logic inside the arduino factor the speed from the encoder pulses. Can an encoder be put into these PWM pins?

please read Robin2's link on steppers.

you do not need an encoder if the motor is sized right. you control the speed with the steps, not the other way around.

you still have not listed the motor number. I would offer that you mark the shaft, send out 120 pulses and see where the shaft lands. I would have expected 200 ppr, not 120. and your driver has settings to make make 1/2, 1/10 step settings, and more.

but, yes, the motor can be controlled by the stepper. you have a step and direction input, with the option to power down.

as a note, so far, you have jumped to conclusions that have no basis on facts or knowledge. take a minute and read xyproblem

Ok NJ here is the full facts, there is a vac belt table, this carries what is refered to as carrier piece, there is a servo motor driven tip on device as it is called.

The carrier piece is conveyed across when it reaches a certain point it trips a sensor and the servo motor runs and attaches what is required.

Now the given way is 1992 and the logic board that controls the servo motor is very limited. There is no way to alter the speed of the carrier piece because as you alter the speed of the carrier piece you change where the attachment is attached to.

So my first test is to see what will control the stepper motor and drive. If i can get an arduino to control it then great. So now you see the drive that does the application to the carrier piece. And you know what i am trying to do.

Once i am able to control the motor and drive, either via a arduino or other device, then the next step will be seeing if i can take an encoder and run it from the vac belt table then monitor the speed based on encoder feedback and control the speed of the servo drive that way both the servo drive and the vac belts will always be at the same reference so as the belt speed is increased the servo speed is increased and the place where the attachment lands is always the same.

There should be no problem connecting an Arduino to the connector shown on Page 15 of the manual. Connect the Arduino 5v pin to OPTO and a pair of I/O pins to PULSE and DIR. If you want to be able to turn the motor power off then also connect AWO to another I/O pin. If not, connect it to the 5v pin so it is always HIGH.

After that, this Simple Stepper Code should be sufficient to test everything. Obviously match the program to the pins used with the stepper driver. If you study the code you should see the general principles that apply to driving stepper motors.

It may not be necessary to use any library but if you do prefer to use a library I suggest you use the AccelStepper library as it has a specific "DRIVER" option for use with your type of stepper driver.

Of course all this assumes that your driver and motor are suitable for each other and that you have an appropriate motor power supply.


Robin, thanks for the info. So if you dont mind i would like to ask a few questions.

Whats the difference between using the stepper.h and the accelstepper.h?

Is there a big benefit to using one vs the other?

Could i use either to control the stepper in question?

To answer your question the motor and drive are properly sized, its just the old way in which they are contolling it i need to try to make it better.

In your humble opinion could i use the stepper.h and since it provides pulses out provide those pulses to the drive? Or would it be better to use the script you provided the link for?

As i said i am fairly new to this so i am just asking for guidance on what would be the best way

I know that the freq or the steps controls the speed that is why i thought the stepper.h but maybe the accelstepper would be better.

The AccelStepper library is much more competent. I don't think the simple Stepper library is really intended for step and direction drivers such as you have.

As its name implies the AccelStepper library has the option of accelerating and decelerating the motor which can be important to ensure it does not miss steps - especially if you want to move a heavy load quickly.

As to whether you use the AccelStepper library or the system in my demo - that's your decision. If you are developing from my demo be sure to use the second example that uses millis() and micros() rather than delay().

All of these options control the speed by varying the interval between steps.