Circuit Problem Nema 17 with DRV8852 motor driver

Hi everyone! This is our first post… we are two unexperiences guys trying to move 5 steppers Nema 17 with a ArduinoMega 2560 controlled by a webcam programed in processing with serial comunication… We knew it wasnt going to be easy but this is getting hard for us…

Nowadays we are trying to controlled just one [/url] Nema17(42SHD0001)12 V 0.4A. Feeded with a 12V 1A transformer conected throug a capacitor of 100 microfarads and controlled by a DRV8852. The driver has a SMD R100 resistance. Acording to the manual of the driver we have adjusted the potenciometer following the next ecuation:

Vref=Imax5Rs

in our case:
Rs= R100 (SMD calculator says 0.1ohm)
Imax= 0,4 A

Vref=0,14 V

Is it a problem of the current?

We have tried a few very simple codes with and without Accel.stepper library. This is the one that works better but not smooth at all… It roughtly does some steps foward and backwards

Here is the Code:

#include <AccelStepper.h>
#define STEPPER1_DIR_PIN 9
#define STEPPER1_STEP_PIN 8

// The Y stepper pins

// Define the steppers and the pins 
AccelStepper stepper1(AccelStepper::DRIVER, STEPPER1_STEP_PIN, STEPPER1_DIR_PIN);


void setup()
{
  stepper1.setMaxSpeed(100.0);
  stepper1.setAcceleration(200.0);
  stepper1.moveTo(100);
}

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

Sorry about the picture…

Thank you for all!

here is the picture… Sorry

Are you powering that motor through the Arduino? That’s going to eventually make smoke. The stepper needs it’s own power supply. The regulator on the Arduino board can’t handle that sort of current.

The Pololu DRV8825 web page has a good wiring diagram and lots of other useful advice,

And study these links
Stepper Motor Basics
Simple Stepper Code

…R

Hi,

thanks for the answers! we are not powering the motor through the mega. We have already checked your complete guide of stepper motors Robin2 and the DRV8825 Pololu info but we are almost sure it is a circuit problem..
Do you know any reliable example?

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Please include power supply and pin labels.

Thanks.. Tom... :slight_smile:

Have you tried my simple stepper code?

It will be easier to help when you are using an example I am familiar with.

Make a simple pencil drawing showing all the connections and post a photo of the drawing. It is not possible to understand your connections reliably from a photo of the hardware.

This

This is the one that works better but not smooth at all.

does not describe what happens sufficiently clearly

...R

the motor is getting stucked, after recieving violent pulses and the stepper is heating up. as we can see in the
video
both motors in the video are wired independently sharing the ground and the power supply. For the video we used the code already posted just for one motor.

Is possible that the driver is burned?

electroskin:
For the video we used the code already posted just for one motor.

Did you read Reply #6

...R

Our apollogices robin2, we had it already..
Here is the video of the Nema17 with your Basic stepper code
It seems for us it is hardware problem... probably related to the motor driver...

electroskin:
Here is the video of the Nema17 with your Basic stepper code

That seems to be working very nicely but at a very slow step rate.

Post the code that YOU uploaded to your Arduino and which was used for that video. Also post a diagram of how everything was connected.

...R

Thank you Robin2! Its working properly!! Looks like the DRV8825 of the first video is burned… wish we contacted you before… Here is the last video

Our wiring diagram is the same as the Alternative minimal wiring diagram of the official Pololu website with the mentioned 12V 1A power supply and a 16V 100uf capacitor

Here is the code adapted to the 200 stepsperrevolution of our Nema17

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// this version uses delay() to manage timing

byte directionPin = 7;
byte stepPin = 6;
int numberOfSteps = 200;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps


void setup() { 

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    // delayMicroseconds(pulseWidthMicros); // probably not needed
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
}

void loop() { 
}

Any reliable examples to optimice the steppers torche and speed? Thinking in our next step hehe (controlling 5 Nema17 at the same time) Should we used the AccelStepper library? Do you recomend us starting with this example ?

It depends on what you want to do with 5 steppers. If you want them all turning funny-looking clock hands at different speeds on an art project then AccelStepper is one good way to do it.

If you want them moving in perfect synchronisation for a 3D printer or other CAM machine, then you have a lot more work ahead of you.

electroskin:
Any reliable examples to optimice the steppers torche and speed?

You need to respond to Reply #12 so we know more exactly what you want to happen.

Also, how many steps per second do you want to generate for each motor?

...R

What we exactly want to do is to control the five steppers indiviadually, in a range of 800 steps, within five prefixed positions in that range. The stepper should be capable of moving between these positions no matter in which position was. The steppers are pulling from a flexible textile, so dont need so much torche.

If we have 5 steppers, A, B, C, D, E and 5 positionts . For example, the situations atached in the hand drawing can ocurr. Should we use the accelstepper library.

Which is the best way to feed the circuit? shoul we use more voltage?

How can we turn off and on the hole circuit? are the sleep and reset pins of the drv8825 necessary?

posible_positions.JPG

Image from Reply #14 so we don’t have to download it. See this Image Guide

4c6e866818599b0ca9f0743c3553ff20a9f2b185.jpg

…R

Even if I turn my laptop on its side I can't make sense of that drawing.

From Reply #14

What we exactly want to do is to control the five steppers indiviadually, in a range of 800 steps, within five prefixed positions in that range

Does this mean that at any one time only one motor will need to move? That greatly simplifies things.

Have a go at writing the program to make 2 motors (out of the 5) work and see how you get on. If it works add a 3rd etc. If it does not work then post your program and explain what it actually does.

...R

Ok... I´ll try to explain myself:

-All motors have to be able to move at the same time

-All motors have to move in the same range of steps. There are 5 different stops whithin that range

-All the motors have to be able to jump between stops

For example:

Lets say we have motors A B C D E and stops 0 1 2 3 4 in a range from 0 to 800 steps

set up
A0 B0 C0 D0 E0

signal1
A2 B0 C1 D3 E0

signal2
A1 B3 C2 D4 E4

and so on depending on the signal info....

The AccelStepper library seems adequate for that. Just give each of the steppers a position to move to and call run() on each one reasonably quickly.

electroskin:
Which is the best way to feed the circuit? shoul we use more voltage?

How can we turn off and on the hole circuit? are the sleep and reset pins of the drv8825 necessary?

12V is usually pretty good to feed average NEMA-17 motors. More voltage means they can step faster - they don't have any more torque or holding power.

A switch?

You can hardwire sleep and reset to 5V or 0V as appropriate. Or you can have them controlled by the Arduino. That way you can cut power consumption without turning the whole circuit off.