Using stepper motor kit

I bought this stepper motor kit,

i think its designed to run grbl firmware. How can i just tell the motors to spin without the grbl firmware involved?

Just make code for the controller...
That shield works with Grbl 0.9. Another version is suggested for Grbl 1.1, if my memory is right.

One helper has a good picture telling which controller outputs goes to x, y resp. z stepping, using Grbl standard. Of course any other configuration can work....

I use that shield for my micro CNC....

Here is how the CNC shield pins map to the Uno.

cnc shield Uno pins

simple stepper code tutorial.

Stepper basics.

Make sure that the coil current limits on the stepper drivers are properly set.

The enable pin (Uno pin 8) must pulled be LOW to enable the steppers. Either do it in software or connect the enable pin on the CNC shield to ground.

1 Like

Talking about the ghosts... Thanks gF!

I tried this example from the accelStepper library,

// MultiStepper.pde
// -*- mode: C++ -*-
//
// Shows how to multiple simultaneous steppers
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Runs other steppers at the same time
//
// Copyright (C) 2009 Mike McCauley
// $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define some steppers and the pins the will use
AccelStepper stepper1; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper2(AccelStepper::FULL4WIRE, 6, 7, 8, 9);
AccelStepper stepper3(AccelStepper::FULL2WIRE, 10, 11);

void setup()
{  
    stepper1.setMaxSpeed(200.0);
    stepper1.setAcceleration(100.0);
    stepper1.moveTo(24);
    
    stepper2.setMaxSpeed(300.0);
    stepper2.setAcceleration(100.0);
    stepper2.moveTo(1000000);
    
    stepper3.setMaxSpeed(300.0);
    stepper3.setAcceleration(100.0);
    stepper3.moveTo(1000000); 
}

void loop()
{
    // Change direction at the limits
    if (stepper1.distanceToGo() == 0)
	stepper1.moveTo(-stepper1.currentPosition());
    stepper1.run();
    stepper2.run();
    stepper3.run();
}

my motors come on but just vibrate.

Then i tried this example but only 1 motor was spinning.

#include <AccelStepper.h>

// for the Arduino Uno + CNC shield V3 + A4988 + FL42STH47-1684A

#define MOTOR_X_ENABLE_PIN 8
#define MOTOR_X_STEP_PIN 2
#define MOTOR_X_DIR_PIN 5

AccelStepper motor_X(1, MOTOR_X_STEP_PIN, MOTOR_X_DIR_PIN); 


void setup()
{
  motor_X.setEnablePin(MOTOR_X_ENABLE_PIN);
  motor_X.setPinsInverted(false, false, true);
  motor_X.setAcceleration(20);  
  motor_X.move(200);
  motor_X.setMaxSpeed(100);
  //motor_X.setSpeed(100);
  motor_X.enableOutputs();
}

void loop()
{
  motor_X.run();
}

is the accelStepper library compatible with that shield setup? So i'm basically sending pulses to the step pin? how can i get a motor up to max rpm? atleast the max achievable rpm of this setup

In the first example MultiStepper.pde you have the wrong driver type in the constructors. Should be:

// MultiStepper.pde
// -*- mode: C++ -*-
//
// Shows how to multiple simultaneous steppers
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Runs other steppers at the same time
//
// Copyright (C) 2009 Mike McCauley
// $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define some steppers and the pins the will use
// DRIVER (1) is the right driver for the step/dir drivers like A4988 or DRV8825
AccelStepper stepper1(AccelStepper::DRIVER, 2, 5);
AccelStepper stepper2(AccelStepper::DRIVER, 3, 6);
AccelStepper stepper3(AccelStepper::DRIVER, 4, 7);

const byte enable = 8; 

void setup()
{
   pinMode(enable, OUTPUT);
   digitalWrite(enable, LOW);
   
   stepper1.setMaxSpeed(200.0);
   stepper1.setAcceleration(100.0);
   stepper1.moveTo(24);

   stepper2.setMaxSpeed(300.0);
   stepper2.setAcceleration(100.0);
   stepper2.moveTo(1000000);

   stepper3.setMaxSpeed(300.0);
   stepper3.setAcceleration(100.0);
   stepper3.moveTo(1000000);
}

void loop()
{
   // Change direction at the limits
   if (stepper1.distanceToGo() == 0)
   {
        stepper1.moveTo(-stepper1.currentPosition());
   }
    stepper1.run();
   stepper2.run();
   stepper3.run();
}

The second code is just for the X axis. To run the other motors, duplicate that code with the right step and dir pin numbers.

AccelStepper works fine when it is used right. I use AccelStepper with the CNC shield regularly.
You might consider the MobaTools stepper library. I have just started to use it and it is interesting. Maybe easier to use than AccelStepper.

If it were set up right, yes, you send a pulse for each step and set the direction pin to choose the direction of rotation.

No way to tell without knowing a lot more about your setup.

You really must set the coil current on the drivers before attempting to get the motors to spin. There are many pages on the net, look for "set A4988 coil current".

1 Like

I adjusted the coil current so that the motor seemed to have the most torque and used the least amount of current. I will try the new example thanks.

So the shield seems to be working okay. i have the jumpers under the driver removed. this should enable larger step? How can i make sure the parameters match the hardware configuration?

I have been reading the AccelStepper classes documentation. Should i change the setMinPulseWidth. My 3d printer sure accelerates faster than this.

That sets micostepping to single step. For your motors that means 200 steps per second.

Probably not. In the AccelStepper examples the speed is controlled with the setMaxSpeed() function. The setAcceleration() function controls how fast it gets to speed. If acceleration is set too low a number the motor will skip steps when asked to speed up.

You would probably learn a lot by reading the tutorials that I linked in reply #3.

I think im getting better performance with higher voltages. i have noticed if i run all 3 steppers to full speed, im limited by what seems to be the speed of the arduino. if i run just 1 stepper the motors runs 3 times faster

I do not care about position of motor. im using for mixing. How can i get higher speed not so limited by arduino. i been trying to figure out how to switch from 1/16th step mode to full step mode? how can i do this?

Would i get better performance with a esp8266? is this just a limit of arduino speed?

200 steps per revolution

1 Like

Yes, of course. Thanks.

1 Like

Why does that same program crash on esp8266. I cant get past boot?

Why are you using steppers? DC brushed motors would give you the speed that you need.

If all the jumpers are removed from the microstep header the motor will be in full step mode.

How are the motors connected to the ESP8266? Post a schematic.
There are certain pins that have to be at certain levels for the ESP to boot. See which pins ESP8266.

Pins used during Boot

The ESP8266 can be prevented from booting if some pins are pulled LOW or HIGH. The following list shows the state of the following pins on BOOT:

  • GPIO16: pin is high at BOOT
  • GPIO0: boot failure if pulled LOW
  • GPIO2: pin is high on BOOT, boot failure if pulled LOW
  • GPIO15: boot failure if pulled HIGH
  • GPIO3: pin is high at BOOT
  • GPIO1: pin is high at BOOT, boot failure if pulled LOW
  • GPIO10: pin is high at BOOT
  • GPIO9: pin is high at BOOT

Right now im trying the program without the pins connected. I keep getting watchdog resets. i tried to disable/yield watchdog but it still crashes. Ive tried lots of different pins in the code with no success.

Well it did end up being a pin. the enable pin to be exact. i think changing the enable pin ,ay have solved that problem

brushed motors are too fast for this and at low speed not enough torque. i dont really need speed. im just experimenting with the motors

I have seen libraries mentioned that purport to allow higher stepper speed than AccelStepper. I don't remember names but a bit of Google work should find them.

accelStepper runs a lot better on the esp8266

Have you heard of these things called "gears"? :grin:

And also you can slow a DC motor, to some extent, with PWM.