# Running a stepper back and forth

**URL:** <https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810>\
**Category:** Jobs and Paid Consultancy\
**Created:** [August 22, 2026, 4:43am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810 "2026-08-22T04:43:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter-add](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/peter-add/32/1280732_2.png) [@peter-add](https://forum.arduino.cc/u/peter-add)\
**Post date:** [August 22, 2026, 4:43am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/1 "2026-08-22T04:43:26Z")

</div>

**[  
peter-add](https://forum.arduino.cc/u/peter-add)**

[1 d](https://forum.arduino.cc/t/i-am-a-dummie-and-need-help-to-run-a-stepper-motor/1456561 "Datum för inlägg")

**post #1**

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

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [August 22, 2026, 4:46am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/2 "2026-08-22T04:46:31Z")

</div>

You already have a topic (that you linked to): [I am a "dummie" and need help to run a stepper motor](https://forum.arduino.cc/t/i-am-a-dummie-and-need-help-to-run-a-stepper-motor/1456561/)

What is the purpose of this topic? Are you looking for paid help?

// Edit  
I see (now) in the other topic that you have followed advice and that you're looking for paid help.

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [August 22, 2026, 5:14am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/3 "2026-08-22T05:14:23Z")

</div>

Doesn't it seem like a DC motor with a crank and connecting rod would be so much easier?

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [August 22, 2026, 3:49pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/4 "2026-08-22T15:49:57Z")

</div>

This is fairly straightforward to do. Would you be satisfied with having to modify code and reload in order to change speed, distance, etc. parameters or do you want the unit to have a user interface that would let you do so? The former is considerably simpler than the latter.

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [August 22, 2026, 5:32pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/5 "2026-08-22T17:32:32Z")

</div>

Maybe some pictures / drawings of your apparatus, what it's supposed to do and how you propose to do it would help. Things like boom swing radius, weight (mass), and time interval between swings need to be known.

---

<div class="post-metadata">

**Author:** ![peter-add](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/peter-add/32/1280732_2.png) [@peter-add](https://forum.arduino.cc/u/peter-add)\
**Post date:** [August 22, 2026, 9:40pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/6 "2026-08-22T21:40:10Z")

</div>

Hi CedarLake  
Yes, I am satisfied with having to modify code, no need for a user interface. I want to set it up once, then run fot weeks (at least), so the inconvinience of not having a user interface is neglible.  
Looking back, I realise I have missed listing one parameter, there needs to be a time gap at endpoints, a bit of resting before starting next move

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [August 22, 2026, 11:19pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/7 "2026-08-22T23:19:42Z")

</div>

Fantastic. Now to address some of the concerns others raised. Microstepping is good for smoothing out the motion, but it will probably cause the motion to drift somewhat over time. Especially if you plan on letting this run for weeks, I recommend a limit switch at one end of travel to get the steps realigned after a full cycle.

If you avoid microstepping and instead use half steps, you should be able to avoid needing a limit switch. TBH, I've never seen a system that ran completely open loop like this for days or weeks on end, so if the mechanism wears, belts stretch, etc., (and it sounds like this is exactly what you are trying to accomplish) the positional accuracy will go down over time. However, having enough "slop" between the travel distance and the distance between physical end stops should take care of this.

I have some demo code for an arduino uno that runs a motor back and forth. It won't run at those speeds, but it will at least show you what is possible and you can scale up from there if you need to run it faster.

---

<div class="post-metadata">

**Author:** ![peter-add](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/peter-add/32/1280732_2.png) [@peter-add](https://forum.arduino.cc/u/peter-add)\
**Post date:** [August 23, 2026, 10:16pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/8 "2026-08-23T22:16:23Z")

</div>

Hi CedarLake  
I know for a fact that it will not drift w microstepping.  
This has been tested many times w an "expensive pulse and direction provider".  
I am looking for a lower cost solution where I do not have to tie up something expensive.  
You are right, it is excactly what I want to find out, how will performance , precision, noise etc etc alter over time.  
What speed (pulses/sec) would your solution w arduino reach?  
Does version of arduino make any difference?  
Would it be possible to increase speed w fex raspberry?

---

<div class="post-metadata">

**Author:** ![peter-add](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/peter-add/32/1280732_2.png) [@peter-add](https://forum.arduino.cc/u/peter-add)\
**Post date:** [August 23, 2026, 10:19pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/9 "2026-08-23T22:19:38Z")

</div>

.......also, does that solution have acceleration and deacceleration ramps?  
Jump starting will not work.

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [August 23, 2026, 11:51pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/10 "2026-08-23T23:51:49Z")

</div>

My demo code uses acceleration but it runs on a standard Nano, so it will be speed limited. However, by changing to one of the faster libraries and a different processor (not the Raspberry Pi) it looks like it's possible to get to 200k steps/second.

I sent you a PM to explore other options.

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [August 24, 2026, 12:00am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/11 "2026-08-24T00:00:38Z")

</div>

> [@cedarlakeinstruments](#):
>
> I've never seen a system that ran completely open loop like this for days or weeks on end

You likely have one hanging on your wall (battery-powered clocks have steppers inside) 😀

Steppers are very reliable as long as you keep things within their limits.  
But a limit switch for if they go beyond their travel is a good idea.

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [August 24, 2026, 12:07am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/12 "2026-08-24T00:07:11Z")

</div>

Yes, actually when I made that statement I had a similar application in mind, but in both cases the motor always moved in the same direction. My concern is that by moving back and forth, backlash will increase over time, causing loss of position. However, that increase in backlash is likely one of the things that OP is trying to characterize.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [August 24, 2026, 1:40am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/13 "2026-08-24T01:40:13Z")

</div>

Use circular motion (of a stepper or DC motor) to driver linear motion an exact amount.  
 ![https://i.gifer.com/origin/e8/e831158322fd5d77d82b779f85eaf450_w200.gif](https://europe1.discourse-cdn.com/arduino/original/4X/1/f/7/1f7b8d223ee00a7f526cd9a57697c9a566ee4b4a.gif)

---

<div class="post-metadata">

**Author:** ![peter-add](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/peter-add/32/1280732_2.png) [@peter-add](https://forum.arduino.cc/u/peter-add)\
**Post date:** [August 24, 2026, 5:22am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/14 "2026-08-24T05:22:38Z")

</div>

xfpd  
Yes, the motion can be executed, but what I want to test is the drive mechasnism with stepper and reduction gearing. I will want it to be able to go between any positions in its real application (like a robot)  
That is why comment from CedarLake is valid; how much will for example positional accuracy vary over time.

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [August 30, 2026, 12:24am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/15 "2026-08-30T00:24:48Z")

</div>

> [@peter-add](#):
>
> how much will for example positional accuracy vary over time.

That depends on your abilities (mechanical and coding).  
If you stay within the limitations of speed/torque/acceleration/deceleration/full step etc., then a stepper can stay accurate forever. I can mill with my CNC machine the whole day, without losing zero position.

---

<div class="post-metadata">

**Author:** ![peter-add](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/peter-add/32/1280732_2.png) [@peter-add](https://forum.arduino.cc/u/peter-add)\
**Post date:** [August 30, 2026, 10:31am UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/16 "2026-08-30T10:31:31Z")

</div>

Wava  
Yes, of course. I expect load on stepper to be well within limits.  
Meaning stepper will not differ.  
So it is not accuracy of stepper I am interested in, it is the wear and tear of mechanism after the stepper.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [August 30, 2026, 2:44pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/17 "2026-08-30T14:44:00Z")

</div>

> [@peter-add](#):
>
> wear and tear of mechanism

Rather than forcing a device to perform a function (accurate/low wear and tear), use a device made for that function. (right tool for the job)

My Toyota pistons have been moving accurately with near-zero change in tolerance due to material wear for over twenty years.

---

<div class="post-metadata">

**Author:** ![PerryBebbington](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/perrybebbington/32/238766_2.png) [@PerryBebbington](https://forum.arduino.cc/u/PerryBebbington)\
**Post date:** [August 30, 2026, 3:20pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/18 "2026-08-30T15:20:06Z")

</div>

> [@xfpd](#):
>
> My Toyota pistons have been moving accurately with near-zero change in tolerance due to material wear for over twenty years.

I think you will find that before Toyota fitted your pistons into your engine they did a lot of research and testing to ensure the pistons and all the other parts would perform as intended.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [August 30, 2026, 3:56pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/19 "2026-08-30T15:56:44Z")

</div>

> [@PerryBebbington](#):
>
> research and testing

I understand the benefit in discovering failures first hand, but if accuracy and tolerance over time is the desired starting point, using existing, tested, ideas helps keep Amazon out of your mailbox and wallet.

I once had the idea of writing a graphic simulator for a system I worked on (circa 1983) on my C64. Everyone in my shop said, "Who would waste time on fixing things in a simulation?" I wanted to add MTBF option (some shops log "hours" the devices had been in-use to create MTBF "on paper") for a simulated time-slider to "break" the system. I never followed through. However; I've been playing with using this sim thingy, but it will not break from use: [Electude Simulator - Engine Management](https://simulator.electude.com/simulator)

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [September 9, 2026, 6:38pm UTC](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810/20 "2026-09-09T18:38:54Z")

</div>

@peter-add did you ever find a solution to the problem? I remembered this as I was working with a Thomson linear slide

[![](https://europe1.discourse-cdn.com/arduino/original/4X/1/0/c/10cb1004501d59ddb6713142af6b07f85bac2bf5.jpeg "motion cycler") ](https://www.youtube.com/watch?v=EGTmN3_i_T0)

[![](https://europe1.discourse-cdn.com/arduino/original/4X/6/0/0/6001025e7d9b9d965d61d035101e966f509d9ef2.jpeg "cycler ui") ](https://www.youtube.com/watch?v=SXsWKjV-y44)

[Next page](https://forum.arduino.cc/t/running-a-stepper-back-and-forth/1456810.md?page=2)
