Voltage drop after connecting stepper motors

Hello!

I did post in this section not too long ago, it was a problem related to my stepper steps per revolution and such.

Now I’m here for something else…

Yesterday, I succeeded in making 2 stepper work simultaneously, without having any problem. Now, this morning, I wired the third one, the wiring is the same as the previous ones.

But what I observed is that my voltage coming out of the generator dropped from 20V to 9V. In the beginning, I thought it was an error of wiring, but when I did it all again (=> I restarted it all again with one stepper), the drop is still here. So obviously now none of my steppers are working since the voltage is not high enough.

The wiring is as such with one stepper :
DIRECTION to D2
STEP to D3
VDD to 5V (Arduino)
GND to GND
VMDT to voltage generator.

Here is the code I’m using for one stepper :

#include <AccelStepper.h>

AccelStepper Stepper2(1, 3, 2); //use pin 12 and 13 for dir and step, 1 is the "external driver" mode (A4988)

int dir = 1; //used to switch direction

void setup() {
  Stepper2.setSpeed(100); //set max speed the motor will turn (steps/second)
  Stepper2.setAcceleration(100); //set acceleration (steps/second^2)
}

void loop() {
  
  Stepper2.moveTo(20);
  delay(2000);
  Stepper2.moveTo(-40);
  Stepper2.run();
 }

and here’s the one I used to control all three steppers :

// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to 
// the same position at the same time for linear 2d (or 3d) motion.

#include <AccelStepper.h>
#include <MultiStepper.h>

// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper stepper1(1, 3, 2);
AccelStepper stepper2(1, 7, 6);
AccelStepper stepper3(1, 10, 9);

// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;

void setup() {
  Serial.begin(9600);

  // Configure each stepper
  stepper1.setMaxSpeed(100);
  stepper2.setMaxSpeed(100);
  stepper3.setMaxSpeed(100);

  // Then give them to MultiStepper to manage
  steppers.addStepper(stepper1);
  steppers.addStepper(stepper2);
  steppers.addStepper(stepper3);
}

void loop() {
  long positions[3]; // Array of desired stepper positions
  
  positions[0] = 75;
  positions[1] = 50;
  positions[2] = 20;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
  
  // Move to a different coordinate
  positions[0] = 0;
  positions[1] = 25;
  positions[2] = 10 ;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
}

The library used was this one.

Any insight on what could be the problem here?

PS: Sorry I forgot, I’m still using the A4988 driver from Polulu

my voltage coming out of the generator dropped from 20V to 9V

What "generator"? If you mean a power supply, post a link to it or state its voltage and current capabilities.

Post a wiring diagram.

Post a link to the motors you are using. What is the motor winding current rating?

Very, very important: to what value have you set the current limit on each of the motor drivers?

Hi Sir!

My generator is a Matsusada PK30-20 DC, I didn’t find his specification since it is a bit old, but I found this one which is the same apart from the fact it goes up to 40V instead of 20V for the one I use.

I can’t give a link to my motor since it is a stepper motor taken from old CD-ROM. So I have no information whatsoever on that.

The wiring diagram I’m currently using was in the link, leading to the A4988 datasheet.
I put it in attachment, it will be easier.

EDIT: I just changed Vref value, it was 0.7 V, but with my current, following Imax=Vref*2.5 => Vref = 0.4V instead of 0.7. I will see if that changes something. But just to be sure, I put Vref to 0.5V.

For the current, if I remember right (I will recheck it) I limited it to 0.7A per coil (I’m applicating 1A for both, and I used the conversion formula given by the link).

Many thanks for your answer

You power supply has current limiting? If so what current is it set to?

If the motor is unknown, set the current limit very low to start with, gradually increasing. Set too high and you will burn out the stepper motor.

Remember never to connect or disconnect the motor when the driver is powered up, this typically destroys the driver instantly.

A stepper motor taken from old CD-ROM is probably high impedance and low power, so current limiting may not be required. Use your multimeter to measure the coil resistance and tell us what that is.

More likely, you have a wiring error.

jremington:
A stepper motor taken from old CD-ROM is probably high impedance and low power, so current limiting may not be required. Use your multimeter to measure the coil resistance and tell us what that is.

More likely, you have a wiring error.

I looked into the resistance with a multimeter, and I found that the coil resistance is ~10 Ohms.
I checked four times the wiring and I think it is good, I will desolder and resolder just to be sure.

MarkT:
Your power supply has current limiting? If so what current is it set to?

If the motor is unknown, set the current limit very low to start with, gradually increasing. Set too high and you will burn out the stepper motor.

Remember never to connect or disconnect the motor when the driver is powered up, this typically destroys the driver instantly.

I said previously that I had a voltage drop, and now my voltage is back to 20V, buy mt current is 0.13A, which also makes no sense since the motor needs a bit of current to work, and I don't think that 0.13A is enough (I might be wrong since I'm obviously not an expert).

Thanks for your concern!

EDIT: I've desolder-resolder the motor, there's still the same problem, voltage generator send 20V, 0.13A, but nothing is moving, only the A4988 that is heating a lot. could it also come from the generator?
EDIT2: I just did an experiment where I held the heating sink on the driver (not for too long of course), and the motor started working. The generator was at this point delivering 1A and 13V. At this point, I'm lost.

20V is too high for a motor taken from a CD drive. It is probably intended to be used with a 12V or a 5V power supply.

Set the current limit on the motor driver to 0.5A and see if the motor gets too hot to touch. If so, reduce it.

If you have the A4988 motor drivers from Pololu, you can follow their tutorial.

jremington:
20V is too high for a motor taken from a CD drive. It is probably intended to be used with a 12V or a 5V power supply.

Set the current limit on the motor driver to 0.5A and see if the motor gets too hot to touch. If so, reduce it.

If you have the A4988 motor drivers from Pololu, you can follow their tutorial.

Following your advice, I switched to 12~13V. I set the current limit to 0.5A by putting Vref to 0.3V (0.3x2x0.7~0.5 - the 0.7 is since I'm on a full-step resolution and the motor draws only 70% of the driver current). But here also, I see that my input current (from my voltage generator), is only 0.06A.
I mean, I already had looked into their tutorial (that's how I adjusted Vref before), and I know that even though the current is low on the input, the current in the motor is more since there's also the voltage acting on the coal. But, the motor and the driver are not heating, in that, this is better.

The problem is, my motor is not moving at all.
The only time I succeeded in making it moves was when I had something like a 1A at the voltage generator output.

EDIT: Ok guys I'm 80% positive there's a bad contact on the driver. I just tried to put pressure on a certain point of the driver, and the output current of the generator went from 0.06 to 1.2A, and my motor moved. My hypothesis is that I messed up with 'the potentiometer' (or the Vref changer) and that
Vref became very small -> So the input current was also very very small. I don't know if that makes sense so can someone light me on this? (If I'm wrong/ If what I just said was possible/...).

EDIT2: Well, after changing the driver the stepper motor worked just fine. But when I tried on another motor (another old stepper motor), it worked but the motor had some trouble at the beginning (was making small noise and stepping one at a time instead of moving directly). Any insight on this (knowing that I changed nothing, and the motor is supposedly the same).

Best regards!

I already had looked into their tutorial (that's how I adjusted Vref before)

If you do not have Pololu's version of the driver, the tutorial may not apply.

The actual setting voltage depends on which current sense resistor the manufacturer uses.

jremington:
If you do not have Pololu's version of the driver, the tutorial may not apply.

The actual setting voltage depends on which current sense resistor the manufacturer uses.

I have the Polulu's version. Mine is the 68 mOhms.

Now, I tried with 2 different steppers and both of them worked separately. But when I want to make them work together, tHere's only a noise coming from both of them... Any idea about the source of this noise (surely the motor, but why?).

Best regards!

Could be a problem with the wiring or the code.

jremington:
Could be a problem with the wiring or the code.

Since the motor is at least working for one instruction, how could it be the wiring?

And for my code, I’m not doing anything complicated…
To be even simpler, I just asked my motor to do 20 steps then pause for 2sec and then go for another 10 steps. It is doing the 20 first steps perfectly, then stop as I commanded, but the next 10 steps, it is doing one by one, and this is also something I don’t understand.

I think this problem is related to my previous one since I rechecked the wiring and if even that is not working, how could 2 steppers run simultaneously.
Code used:

#include <AccelStepper.h>

AccelStepper Stepper1(1, 7, 6); //use pin 12 and 13 for dir and step, 1 is the "external driver" mode (A4988)

void setup() {
  Stepper1.setSpeed(30); //set max speed the motor will turn (steps/second)
  Stepper1.setAcceleration(100); //set acceleration (steps/second^2)
}

void loop() {
  
  Stepper1.moveTo(20);
  delay(2000);
  
  Stepper1.moveTo(30);
  Stepper1.run();
 }

Thanks for your insights!

You use of Accelstepper is wrong - you must call run() every time through loop() and never use delay(), otherwise the library cannot function.

Start with one of the examples, then progress from there, read the AccelStepper.h comments, they tell you all about using the library functions.

MarkT:
You use of Accelstepper is wrong - you must call run() every time through loop() and never use delay(), otherwise the library cannot function.

Start with one of the examples, then progress from there, read the AccelStepper.h comments, they tell you all about using the library functions.

Are you sure about never using delay()? Because in one of the examples of the library, they use this function :

// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to 
// the same position at the same time for linear 2d (or 3d) motion.
#include <AccelStepper.h>
#include <MultiStepper.h>
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 8, 9, 10, 11);
// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;
void setup() {
  Serial.begin(9600);
  // Configure each stepper
  stepper1.setMaxSpeed(100);
  stepper2.setMaxSpeed(100);
  // Then give them to MultiStepper to manage
  steppers.addStepper(stepper1);
  steppers.addStepper(stepper2);
}
void loop() {
  long positions[2]; // Array of desired stepper positions
  
  positions[0] = 1000;
  positions[1] = 50;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
  
  // Move to a different coordinate
  positions[0] = -100;
  positions[1] = 100;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
}

If you don’t believe me, I found this here.

Oh and also, I’ve been using this example (that does work) :

// Blocking.pde
// -*- mode: C++ -*-
//
// Shows how to use the blocking call runToNewPosition
// Which sets a new target position and then waits until the stepper has 
// achieved it.
//
// Copyright (C) 2009 Mike McCauley
// $Id: Blocking.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

void setup()
{  
    stepper.setMaxSpeed(200.0);
    stepper.setAcceleration(100.0);
}

void loop()
{    
    stepper.runToNewPosition(0);
    stepper.runToNewPosition(500);
    stepper.runToNewPosition(100);
    stepper.runToNewPosition(120);
}

EDIT: I tried both of the above examples, the “blocking” example is working, but the multi stepper is not. When I try the second one, it is just making a slight sound and nothing’s working. So to resume my current problem, both motors are working separately but not together.

Thanks for your answer!

Anyway, I changed both my motors and my steppers, redid the same thing, and now it is working fine.

I would be glad if you could just lend an eye to one of the codes I wrote.
This one is responsible for homing both the steppers. And is also using Matlab to work.

Here are the Matlab and Arduino code :

#include <AccelStepper.h>

AccelStepper StepperX(1, 7, 6); //use pin 12 and 13 for dir and step, 1 is the "external driver" mode (A4988)
AccelStepper StepperY(1, 3, 2);

char a;

void setup()
 {
   Serial.begin(9600);

   pinMode(12,INPUT);
       
   StepperY.setSpeed(50);
   StepperY.setAcceleration(50);
   
   StepperX.setSpeed(50);
   StepperX.setAcceleration(50);
   
 }

void loop()
{
  while (Serial.available() == 0)
  {
  }
  
  if (Serial.available() > 0)
  {
    a= Serial.read();
    if (a =='R')
    {
      while(digitalRead(12)!=HIGH)
      {
        StepperY.move(-1);
        StepperY.run();
      }
      while(digitalRead(13)!=HIGH)  // next putton 
      {
        StepperX.move(-1);
        StepperX.run();
      }
    }
  }
}

And

clc;
clear;

if ~isempty(instrfind) 
     fclose(instrfind);
      delete(instrfind);
end   % I find occupied port and empty them

co = serial('COM3','BaudRate', 9600);
fopen(co);
pause(0.1);
fprintf(co,'%c','R');

fclose(co);

As you may have understood by looking at the codes, upon receiving the character R (sent by Matlab), both steppers begin to move back until a logic switch is activated and change its state (low to high here).
I’m sure my Matlab code is working and is sending the R character (I confirmed it).
But when I send the character, instead of moving back until the switch is activated, it moves back for 1sec (and not step by step) and then stops.
Is it a problem with my Arduino code here?

Thanks for all your answers!