France
Asked — Edited

Easydriver And NEMA17 Stepper Motor

Hi,

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
:loop

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

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

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

ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
USA
#1  

you can't run the stepper from the PC i.e. ARC you need an arduino to run the code.

PRO
USA
#3   — Edited

@Fredebec, 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: https://learn.sparkfun.com/tutorials/easy-driver-hook-up-guide

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

Please post a PIC of your setup and motor specs.

PRO
USA
#4  

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

Resolution:

User-inserted image

I would start with both Low, Low, to see some results (movement)

PRO
USA
#5   — Edited

@Fredbec: 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:)

#6  

@ptp,

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...

PRO
USA
#7   — Edited

Please follow the wiring directions and don't forget the common ground.

Javascript code:

//Sparkfun's EasyDriver 
//
//Wiring:
//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)
{
  switch(value)
  {
  default:
  case 1:
    Digital.set(D4, 0);
    Digital.set(D5, 0);
    driver_resolution=1;
    break;
  case 2:
    Digital.set(D4, 1);
    Digital.set(D5, 0);
    driver_resolution=2;
  case 4:
    Digital.set(D4, 0);
    Digital.set(D5, 1);
    driver_resolution=4;
  case 8:
    Digital.set(D4, 1);
    Digital.set(D5, 1);
    driver_resolution=8;
    break;
  }
  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);
     sleep(delayMs);
     Digital.set(D2, 0);
     sleep(delayMs);
  }
}

disable();
setResolution(1);

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

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

//important
disable();


Let me know if it works for you.

#8  

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
PRO
Synthiam
#9  

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.

#10  

@DJ

Quote:

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