Stepper Motor control

931 views
Skip to first unread message

Steven Keller

unread,
Oct 17, 2016, 10:59:40 PM10/17/16
to Node-RED
Does anyone, or has anyone, controlled a stepper motor using node red?  I need to control at least 2 motors at a speed up to 500rpm, which think is around 1700hz pulse rate.  (With no micro-stepping.)
I would like to use either a Pi or BeagleBone.    Does anyone have any suggestions.  (I can handle the hardware drivers, I am more concerned about the pulse rate.)


Thanks

Julian Knight

unread,
Oct 19, 2016, 3:51:14 AM10/19/16
to Node-RED
I've not done motor control from JavaScript and I don't think that NR will be directly the right tool since it is based on JavaScript which isn't particularly suited to realtime operations.

However you can use NR to control a controller. Maybe look to create a control application using Python or something C'ish and then call it from NR. 

Dave C-J

unread,
Oct 19, 2016, 4:04:56 AM10/19/16
to node...@googlegroups.com
Indeed,
the underlying node.js is inherently single threaded - so is dedicated to everything going on in the Node-RED flow... so as Julian says it would probably be better to have a small external motor driver app that can try to keep the timing accurate, that is then controlled by Node-RED. Better would be a dedicated driver chip of some sort - controlled via digital link (SPI, i2c, fast serial, etc)

Sebastian Barwe

unread,
Oct 19, 2016, 4:39:19 AM10/19/16
to Node-RED
Not a node-red-node but maybe a possible way:

I got some good PWM up to >100kHz output with https://github.com/jperkin/node-rpio on a raspberry pi3 - indeed the library just set the settings  from BCM chipset. 
If you need reverse polarity this is currently not supported but can easily be patched.
PWM needs root access because of the direct memory access.

Octavian P.

unread,
May 6, 2017, 7:54:21 AM5/6/17
to Node-RED
So did you manage to control the stepper motors with node-red? I'm trying to build a motion control slider and have an arduino uno with the cnc shield (A4988 drivers). I'm a noob and node-red seems rather easy, but still...do I need to code an app in arduino or does the standard firmata suffice?

Julian Knight

unread,
May 6, 2017, 10:00:49 AM5/6/17
to Node-RED
Probably depends what kind of control you are looking for. Node-RED is built on Node.JS which is a single-threaded JavaScript server -  so real-time control systems are not really what it's about. But if you wanted to send a queue of commands to an Arduino, that would probably work.

It isn't that you can't do direct control with NR, you may get away with it, it depends on:

  1. What else is happening on the Pi
  2. What other flows might run and create interruptions
So I would be wary of using firmata for real-time control from the Pi.
Reply all
Reply to author
Forward
0 new messages