I am a "dummie" and need help to run a stepper motor

I want to endurance test a mechanical rig I have built.
It is powered by a stepper motor.
I have the "power amp", the box that accepts pulses as "step" and "direction" as input, PSU etc, all set up and working.
I have tested with a signal generator and can make the motor run ok.
I need something that can deliver pulses + direction.
The task is to run endlessly between two positions, back and fourth, back and fourth etc etc etc ...... (It is an endurance test as mentioned)
I want to be able to set:

  • Number of pulses between endpoints.
  • Set some sort of accereration and deacceleration ramp.
  • Set top speed (Pulses per sec or minute fex)
    It is important that it always is the exact same number of pulses in each direction, so it does not "drift" with time.
    I would be very happy to recieve precise instructions on what arduino to buy, and how to get correct code into it and how to be able to change parameters indicated above.
    I have no problem with powersupplies, soldering etc, but the digital bit is my problem.
    Very greatful for help
    Peter Add

Please read this post:

The information you gave is is far too few to get reasonable advices.
Please tell us more about your HW and e.g. what speed you want to achive. 'Stepper' covers a very broad spectrum, ranging from very tiny to very large. Do you need microstepping? How do you want to change the parameters? Hard coded? Is Serial Monitor sufficent? Do you need some sort of control panel? ...
As you see ... we need much more information.

The mechanical device is a "boom" with rather much inertia, that is why I need acceleration and deacceration ramps. The motor can not "jump start" with this amount of inertia.
Yes, the power unit can microstep up to 1/256, but this is of no importance for what I need from the arduino. The arduino does not have to know how the power unit is set, the arduino just delivers the pulses, of course it must be set for very many more pulses if the "power unit" is set to higher microstepping.
This means that I am happy with just being able to set number of pulses between endpoints, even if this can be a very high number, perhaps into millions with fex a 1/256 microstepping and 0.9 degree motor.
I would be happy if we can reach speed of some 100 000s of pulses/sec
It is ok if I have to go into the code to change parameters

It looks like you missed the advice in post 2.

Let me give you a clue, we need to see what you see, not a word salad.

That's really a lot. You will not reach that with a classic AVR Arduino. At least you need something like ESP32 or Pi-Pico, and a fast stepper library like

( I don't have own experience with that library ).

The simplest solution, IMO, is an Arduino Nano (the old school one), an install of grbl - How to Setup GRBL & Control CNC Machine with Arduino and a download of UGS to your PC. The arduino will be connected to your driver to send step/direction signals.

That option requires no programming, and you can configure all parameters in UGS and have it send g-code to the Arduino indefinitely.

However, it does require that a PC remain connected. I think that there's a g-code setting to repeat a script, but I don't remember for sure right now.

The second simplest solution is to write a short arduino script using AccelStepper or similar, but that may have a steeper learning curve depending on your programming experience. It's not difficult -- I may even have some demo code if I can find it -- but it is work.

In both cases your step rate of 100k/sec is going to be a problem. Another option might be the MKS-DLC32 step controller. It has everything built in (motor controllers, motor drivers, and a user interface screen) and might support that step rate. I don't remember. Relaxing this speed requirement and the level of microstepping will probably make the task much easier.

What voltage do the step and direction inputs need to be?

  • Pulse input, what is the min/max voltage for a low level, and min/max voltage for a high level.
  • Direction input, is it just one input? If so, same info for that input is required. If it's not just one input then please explain further.
  • How much current do those inputs need to provide, or alternatively, what is the control signal input impedance?
    These questions are an example of why this was said:

Thanks a lot for your interest!
A few answers:
I am a digital dummy, so I need full step by step instructions, all code etc.
I am however a analogue master, meaning I can build simple circuits to invert/adjust levels(voltage) impedance etc to match any outputs to any inputs, so this is not a problem.
I now understand from your answers that the speed I am asking for (100 000s pulses/sec) can be a problem. What would you say is a reasonable speed?
Would it be easier on another device as fex raspberry?
I would like to avoid end switches.
I need both pulses and direction as separate outputs.

Then you need to power the stepper motor with the highest voltage you can supply at the rated current. Could be in the 40 volt range.

Paul and others
I have full control of the stepper driver (Brand: Leadshine), voltages, current PSU etc and the stepper motor itself, so I do not need advice on those items.
I only need the pulses, step and direction to feed into the Leadshine stepper driver.

Sorry. I assumed that not drifting was a requirement.

Have you tried AI?

256 steps to turn .9 degrees? If so 102400 steps turns 360.

I'm just puzzled and +1 to using sensors to know where the boom is and adjust speed/direction with those. You could probably make that work with a DC motor if all you want is swing back and forth.

With a "classic" Arduino Nano as I mentioned in post #7, the FastAccelStepper library from post #6 will give you 50k steps/sec. With an ESP32 (also arduino programmable), it looks like you can get 200k steps/sec. Assuming FastAccelStepper has similar behavior to the regular AccelStepper, it will produce pulse/direction outputs that you can feed into the Leadshine controller.

Since you have no programming experience I still suggest using grbl and a front-end like UGS. It is very flexible, but you do need a PC to run the front end.

I have built a system to do fatigue testing of a dental tool before, but IIRC, the motor controller had its own back & forth behavior.

Do you actually need the microstepping ability? Does your controller have the ability to have microstepping turned off or reduced while still giving you adequate position control of your test rig?

That could greatly reduce the maximum step pulse frequency that the Arduino would have to generate for a given motor speed.

Be aware that this forum is not a free code writing service. You can get a lot of help here, but it’s about helping people to help themselves. You need to dig into code-writing and in the end write the code by yourself.
If you don't want to do that, there is a forum category 'Jobs and Paid Consultancy' where you can try to find someone to write the code for you in return for payment.

The more torque the motor has, the more that the pulses will couple with the coil fields and slow down.

So just how fast do you think to change motor speed?

How will your Arduino program know where the endpoint is located when you power up the Arduino? The stepper motor always begins at the nearest full step when it is first powered up.

Yes MicroBahner, that is perhaps correct.
I have posted it as you suggested.
Perhaps CedarLake could make a suggestion.
You seem to understand the situation?
Also, Paul, on your comment on "homing".
Yes, this is of course an issue.
As this will be a very long term test it is ok for me to manually move it to a suitable start position before fatigue test starts.