# Stepper motor speed issues

**URL:** https://discourse.nodered.org/t/stepper-motor-speed-issues/52132
**Category:** Hardware
**Created:** [12 October 2021 12:23 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132 "2021-10-12T12:23:02Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Jay1234](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@Jay1234](https://discourse.nodered.org/u/Jay1234)
#### Post date: [12 October 2021 12:23 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/1 "2021-10-12T12:23:02Z")

</div>

I'm playing around with a 28BYJ stepper motor paired with a ULN2003 chip using a Raspberry Pi 3b using this flow [Stepper Motor (flow) - Node-RED](https://flows.nodered.org/flow/54dd7dff5d1432e6bcc53b987dd5f0b6).

There seems to be some sort of glass ceiling on the stepper motor speed - the fastest ive been able to get it to turn is approx 2RPM.

There is nothing else running on the Pi, but there seems to be a delay between whats happening on the screen and the actual motion of the motor.

Any ideas as to what could be causing this?

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [12 October 2021 13:26 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/2 "2021-10-12T13:26:35Z")

</div>

Hi @Jay1234 , welcome to the forum. There is nothing wrong with your setup for sure. If you have look in [github page](https://gist.github.com/Workshopshed/54dd7dff5d1432e6bcc53b987dd5f0b6) you will see that someone else pointed out that this flow will generate slow RPM.

Even if you change the delay inside the subflow the end result will not improve a lot. This flow is nice to understand how to drive a stepper motor. If you want to create something useful you will need to use a microcontroller for driving the motor.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [12 October 2021 16:21 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/3 "2021-10-12T16:21:51Z")

</div>

These steppers have a max in the region of 12 rpm

Step them too slowly and they move slowly, step them too fast and they don't like that! They need a Goldilocks treatment 🙂

I broke the subflow out and changed the rate limit to 200/sec and changed the step sequence to the most coarse one that can be used and can get about 10pm out of it (which isn't too bad for these)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/266ee50e9c7713c9796c46b52c02a85e5991a65b.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/978f104c63de4a2755ec208f3909c56e64a4624a.jpeg)

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [12 October 2021 16:46 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/4 "2021-10-12T16:46:05Z")

</div>

Don’t believe that a full featured os with JavaScript what not is suitable for driving stepper motors. That what microcontrollers are good for - you have precious control over every processor cycle and generate precision pwm signals. Or you use dedicated controller chips like the L6470 via spi where you only give high level commands like speed, count and acceleration

With precise timing you are able to get incredible speeds:

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f46d39f1ba65b8be675fe12026e7ba7b6154b04a.jpeg "L6470 Microstepper driver") ](https://www.youtube.com/watch?v=9XALgBgqDdo)

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [13 October 2021 10:27 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/5 "2021-10-13T10:27:22Z")

</div>

Came back to this this morning and I've done a bit more investigation

It would seem using a rate limit of 60 gives about 2 rpm

Going with higher rate limits does increase the rpm but at the expense of missing out steps (e.g doesn't make a full revolution for a multistep value of 2048)

And now I've actually timed it with a stop watch instead of just counting in my head 🙂 you need about 360 on rate limit to get up to 10 rpm (and it misses off about 15 deg or turning at that rate)

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [14 October 2021 08:11 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/6 "2021-10-14T08:11:43Z")

</div>

BTW What is your end goal for using these?

Years ago, I wrote a python program that interfaced to Scratch to allow control of lots of hardware on a Pi.

And I finally managed to get it talking to NodeRED so this could be a route for you to get full speed

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/c/bcc8d078b7860b33e88b19f51ca49dc64c2f8da8.jpeg)

I've not fully tested it out for robustness but it does get 10 rpm out of the stepper

---

<div class="post-metadata">

### Author: ![Jay1234](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@Jay1234](https://discourse.nodered.org/u/Jay1234)
#### Post date: [31 October 2021 06:12 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/7 "2021-10-31T06:12:30Z")

</div>

Hi All,

Thank you for the help so far. The reason it has taken me so long to come back is because you all gave me A LOT to think about as some one new to this.

> [@Andrei](#):
>
> This flow is nice to understand how to drive a stepper motor.

You're absolutely correct. While I was initially frustrated by this flow being inappropriate for my needs, I begrudgingly admit it was useful for better understanding how steppers work.

> [@cymplecy](#):
>
> BTW What is your end goal for using these?

I am building a Barn Door Star Tracker so I can take longer exposures when doing some astrophotography. Given the materials used, I need to achieve a minimum of 4.1875 rpm from the stepper motor with a fairly high degree of accuracy. The tracker I am building uses a straight drive rod, so one of my upcoming challenges will be to use software to correct for tangential error.

> [@Andrei](#):
>
> If you want to create something useful you will need to use a microcontroller for driving the motor.

> [@Christian-Me](#):
>
> Don’t believe that a full featured os with JavaScript what not is suitable for driving stepper motors. That what microcontrollers are good for - you have precious control over every processor cycle and generate precision pwm signals.

I've (finally) discovered that this would be the optimum solution, however one of my self imposed restrictions is to build this on the cheap, utilising existing hardware I have laying around. I may very well end up buying an Arduino, but for now I am going to explore the possibilities and limitations of my existing setup.

> [@cymplecy](#):
>
> Years ago, I wrote a python program that interfaced to Scratch to allow control of lots of hardware on a Pi.
> 
> And I finally managed to get it talking to NodeRED so this could be a route for you to get full speed

Yep - looks like Python is the way to go. I've figured out how to save a .py file with [this code](https://ben.akrin.com/?p=9768) and then use NR to execute it. I've not tried scratch before, but I will check it out.

Next Steps  
While I can now run a python script from NR, I am now trying to figure out how to change the speed, direction and runtime of the motor via a NR dashboard.

Can any one recommend a good "Dummys Guide"?

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [31 October 2021 06:16 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/8 "2021-10-31T06:16:31Z")

</div>

> [@Jay1234](#):
>
> I've not tried scratch before, but I will check it out.

I didn't mean for you to use Scratch for this 🙂

BTW - Do those steppers have enough torque for the job?

---

<div class="post-metadata">

### Author: ![Jay1234](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@Jay1234](https://discourse.nodered.org/u/Jay1234)
#### Post date: [31 October 2021 06:34 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/9 "2021-10-31T06:34:55Z")

</div>

> [@cymplecy](#):
>
> BTW - Do those steppers have enough torque for the job?

yep, seems to handle it fine but I haven't properly tested it. It's worth noting that I'm using a 2.0834:1 gear ratio between the motor and the nut that spins around the drive rod.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [30 December 2021 06:35 UTC](https://discourse.nodered.org/t/stepper-motor-speed-issues/52132/10 "2021-12-30T06:35:22Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
