Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited

Easydriver And NEMA17 Stepper Motor


I am trying to use a NEMA17 stepper motor (from an old 3D printer) with the EZB v4, through the EasyDriver - Stepper Motor Driver from Sparkfun.
I have connected everything this way:

User-inserted image

and use the following code (from this thread: Link):


$x = 0

$x = $x + 1
SET(D1,ON) # dir pin (maintain current direction)
SET(D0,ON) # step pin
SET(D0,OFF) # step pin

print($x) # let me know the loop progress
if($x = 6400)
$x = 0 # don't go crazy

goto (loop)
But the motor barely moves and I cannot change the speed by playing with Sleep().

I use a 24v 15A alim (the same I used before with this stepper motor in my 3D printer) so I should have enough power

Any idea what I do wrong ?

Related Hardware EZ-B v4
Related Control Set Digital


Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

you can't run the stepper from the PC i.e. ARC you need an arduino to run the code.
#3   — Edited
Soon or later you will find out that is not efficient to run the stepper through the PC (ARC) versus running on the micro-controller.
If you look to your code you are sending ON,OFFs to the controller in a short period, when you do that you are "flooding" the controller.
The timing is another issue sleep(1) is not 1 ms, sleep(5) is not 5 ms and so on, sleep only works when you are in the context of Javascript, Python, when you get out that context e.g. sending a command through network, and then to EZB queue there is no guarantee of speed.

nevertheless that does not mean you can't run a slow stepper using all the Elephant power (ARC).

Looking to the documentation:

Did you match the motor coils wiring, and the motor amps (Potentiometer) ?

Please post a PIC of your setup and motor specs.
you missed a few things:
Enable (Low = Activates) / (High= Deactivates). Don't forget to switch off otherwise the coils are active. Don't change the wiring while the coils are active.User-inserted image

User-inserted image

I would start with both Low, Low, to see some results (movement)
#5   — Edited
Sparkfun's documentation is pretty good, did you missed that ?
User-inserted image

ARC simplifies a lot of things, but wiring less signals (2 of 5)  is not an ARC's feature:)

Thanks for the help.
I used this (arduino) link : Easy Driver Example
that showed the simple setup i used. It seems that I have been misled...:D

I am going to make the complete circuit and see how it goes. But first, I have some soldering ahead...
#7   — Edited
Please follow the wiring directions and don't forget the common ground.

Javascript code:


//Sparkfun's EasyDriver 
//D2 = Step
//D3 = Dir
//D4 = MS1
//D5 = MS2
//D6 = Enable

//typical motor with 1.8 degrees per step = 200 full steps per revolution
var motor_steps_per_revolution = 200

var driver_resolution = 0;

function forward()
print("set direction to forward");
Digital.set(D3, 0);

function backward()
print("set direction to backward");
Digital.set(D3, 1);

function enable()
print("enable motor");
Digital.set(D2, 0);
Digital.set(D6, 0);

function disable()
print("disable motor");
Digital.set(D6, 1);

function setResolution(value)
case 1:
Digital.set(D4, 0);
Digital.set(D5, 0);
case 2:
Digital.set(D4, 1);
Digital.set(D5, 0);
case 4:
Digital.set(D4, 0);
Digital.set(D5, 1);
case 8:
Digital.set(D4, 1);
Digital.set(D5, 1);
print("set resolution to 1/" + driver_resolution + " steps.");

function steps(steps, delayMs = 1)
print("execute " + steps + " steps with delay:" + delayMs + " ms");
for ( ; steps>0 ; steps--)
Digital.set(D2, 1);
Digital.set(D2, 0);


//run two turns (revolutions)
steps(2 * motor_steps_per_revolution * driver_resolution, 1);

//run three turns (revolutions)
steps(3 * motor_steps_per_revolution * driver_resolution);


Let me know if it works for you.
So, I have made some testing, and some progresses.

First, I don't use the EasyDriver module anymore, because it stopped working at some stage, without any obvious reason. So, I changed for a DRV8825 (I have a lot of them).
I use this kind of setup:
User-inserted image

+ the "Enable" pinout connected.

With @ptp's script (and my EZ-script) I am able to rotate the motor, with two main limitations:
- I am unable to obtain a continuous rotation. It rotates, but randomly...
- I am unable to change the direction. Putting DIR on or off don't change anything, it always moves in the same direction
For something as granular and repetitive as a stepper, use an Arduino between the stepper driver and ezb. Or, use an Arduino as an ezb with stepper capability added. 

Operating systems for PCs, such as windows and Linux and macOS are not real-time. They don’t have precision such as the stepper would need. Additionally there’s overhead of the entire network and WiFi stack.


Or, use an Arduino as an ezb with stepper capability added.
What do you mean by that?
I already have an "EZBfied" Arduino Mega, so I am interested