Quick stepper.h question

Guys, A quick question or two if I may.

I am just starting out with stepper motors and Im not sure about a couple of things.

My hardware is: - Arduino Uno R3 - MA860H Driver - NEMA 34 13Nm BiPolar (4 wire) stepper motor - 60V 7.2A power supply

[u]Question 1:[/u] The Arduino Reference documents for stepper.h, particularly with reference to the Stepper Constructor says: Stepper(steps, pin1, pin2) or Stepper(steps, pin1, pin2, pin3, pin4)

My motor is a 1.8 degree stepper and so has 200 steps per revolution. The MA860H driver allows for setup of the steps per revolution upto 51200 (micro ??) steps per revolution.

Should "steps" in the constructor be 200 or whatever the driver is set to? Im thinking Id like 1600 steps per revolution and don't know if I should set steps to 200 or 1600.

[u]Question 2:[/u][/u] [u]Using Stepper.h, pin3 and pin4 don't appear to make any difference. At the moment I am only playing with the Arduino stepper examples.[/u] [u]Whats the point of pin 3 & 4 / What are they supposed to do?[/u] [u]At the moment I have pin1 and pin2 (2 & 3 on the Arduino) connected to PULS+ and PULS- on the MA860H and I can make the motor move.[/u] [u]Thanks[/u] [u]Jon[/u]

The PUL+ pin should be connected to Vcc (5V on Arduino) and PUL- to an output pin, inputs are enabled on LOW, set the steps per rev to whatever you have set on the DIP switches, for example, if you set microsteps to 4, steps per rev would be 800, see page 5 on datasheet. You only need 3 pins connected PUL, DIR and ENA + Vcc. You would probably get better performance using the Accelstepper library: http://www.airspayce.com/mikem/arduino/AccelStepper/

http://www.gbeshop.com/InfoBase/downloads/MA860H-N_User-Manual-EN.pdf

The regular Stepper library is not really suitable for a stepper driver that takes step and direction signals. Use the AccelStepper library. For that type of driver it is also easy to write code that does not need any library.

...R Stepper Motor Basics Simple Stepper Code

The Stepper library can work with step/direction signals if you use the function-calling mode and implement the step pulses in the functions you pass to it.

Don't bother, you will need speed-ramping anyway, use AccelStepper in the first instance.

Thanks guys, much appreciated.

I have downloaded the AccelStepper library and had a quick look through the documentation and Arduino examples.

All the examples work with wiring 4 pins to 2,3,4, & 5 on the Arduino but I cant find where it says what the other end of the wires should connect to.

Ive kind'a assumed the following: Arduino 2 --> PULS+ Arduino 3 --> PULS- Arduino 4 --> DIR+ Arduino 5 --> DIR-

With the above configuration the motor seems to work as my reading of the example codes suggests it should (it goes forwards & backwards smoothly etc).

At the moment I do not have ENA+ or ENA- connected.

Based on my reading of the MA860H manual and my current application, I don't think I need to concern myself about enabling or disabling the stepper.

Assuming the above is correctly wired, I now just need to figure out how to set the motor to a prescribed rpm - Im looking for 0 - 30rpm (via a 10k pot) at the spindle.

Thanks Jon

The PULs- and DIR- should connect to Arduino GND and the PULS+ and DIR+ should connect to the appropriate I/O pins. Likewise with ENA if it is needed.

Alternatively connect the + connections to 5v and the - connections to the I/O pins.

Both will probably work.

Use the DRIVER option with AccelStepper - it is the one for step and direction drivers.

...R

Robin2:
The PULs- and DIR- should connect to Arduino GND and the PULS+ and DIR+ should connect to the appropriate I/O pins. Likewise with ENA if it is needed.

Alternatively connect the + connections to 5v and the - connections to the I/O pins.

Both will probably work.

Use the DRIVER option with AccelStepper - it is the one for step and direction drivers.

…R

Thanks R,
I think its always good to know when Ive got things right, rather than just working! Whilst connecting pins 2,3,4 & 5 work, its rather hungry on the Arduino pins, especially when I have a SPI device to hang on as well. It’s great to be able to connect 2 of the 4 to +5V and GND therefore freeing up 2 digital pins.

I’ll check out the DRIVER option, I did see it in the AcceStepper reference docs but thats about all so far.

On the rpm side of things, I cant believe how easy that was. The AccelStepper reference material confirmed that speed() was in steps/s, a quick bit of math and then out with the stopwatch to verify - all good!

The one problem that I did encounter (I think) was that the Arduino is not capable of providing the very fast pulses required for 30rpm once the steps get above 1600 - 3200 range. At 800 steps it was fine and controllable down to zero (via the 10k pot).

The biggest problem I have found is knowing with certainty what the DIP switch settings should be for a given number of steps. So far I have found 3 or 4 different tables. The OMC-stepperonline manual aligns with the printout on the MA860H, but the Leadshine and Savebase manuals for apparently the same driver show different DIP switch positions for the same speed - the only speed they all agree on is 400 steps!

My project (welding positioner) has a 3:1 reduction chain and I need control from about 0.5rpm through to about 10rpm at the reduced shaft.

Thanks again,
Jon

Yorkshire_Jon: It's great to be able to connect 2 of the 4 to +5V and GND therefore freeing up 2 digital pins.

I hope you meant OR rather than AND

The one problem that I did encounter (I think) was that the Arduino is not capable of providing the very fast pulses required for 30rpm once the steps get above 1600 - 3200 range.

The AccelStepper library has some limit on the number of steps per second that it an produce. However it is possible to produce very much higher rates if you don't use the library.

How many steps per second do you need? Are you using micro-stepping? If so, do you need it?

You need the documentation for your specific driver to get the correct DIP switch settings. However if all you want is to set the micro-step rate it should not be too difficult to figure by experiment if you get the Arduino to provide a constant known pulse rate.

...R PS, what was the quick question :)

Yorkshire_Jon: Thanks guys, much appreciated.

I have downloaded the AccelStepper library and had a quick look through the documentation and Arduino examples.

All the examples work with wiring 4 pins to 2,3,4, & 5 on the Arduino but I cant find where it says what the other end of the wires should connect to.

Ive kind'a assumed the following: Arduino 2 --> PULS+ Arduino 3 --> PULS- Arduino 4 --> DIR+ Arduino 5 --> DIR-

With the above configuration the motor seems to work as my reading of the example codes suggests it should (it goes forwards & backwards smoothly etc).

At the moment I do not have ENA+ or ENA- connected.

Based on my reading of the MA860H manual and my current application, I don't think I need to concern myself about enabling or disabling the stepper.

Assuming the above is correctly wired, I now just need to figure out how to set the motor to a prescribed rpm - Im looking for 0 - 30rpm (via a 10k pot) at the spindle.

Thanks Jon

User DRIVER mode in AccelStepper - that uses two pins only, step and direction