How to drive multiple stepper motor ?

Hi, I want to drive multiple stepper motors using DRV8825 and AccelStepper library, i want a code that i can control the speed and number of step!

You should have no problem doing that with the AccelStepper library - what have you tried? What happened?

Really, if you are serious about getting help you need to tell us a lot more about your project

How many stepper motors?
What are the motors being used for?
Is it essential that the motors move in a co-ordinated manner - for example motorB moves 123 steps in the same time that motorA moves 837 steps?

Post a link to the datasheet for your stepper motors.

...R
Stepper Motor Basics
Simple Stepper Code

There are 4 motors in my project, firstly the name of motors appear on LCD then I choose the number of steps by increasing it from a switch, example: M1: 62 steps, M2 : 0 steps, M3: 259 steps, M4: 9 steps , I just want to know the code for controlling the motors .

You have answered my first question in Reply #1.

Now if you answer the other 3 questions we can make some progress.

If you just want someone to write a program for you please ask in the Gigs and Collaborations section of the Forum and be prepared to pay.

...R

I already answer you about the concept of my project , i just want to know , how to drive the 4 motors connected by DRV8825 using Accelstepper library , because they turn in the same time but with different step numbers

I have been doing my best to help you - but you need to work with me. I did not take the trouble to write my questions just to be irritating.

...R

What do you want from me ?

aymannox:
What do you want from me ?

The answers to the 3 questions in Reply #1 that you have not yet answered.

...R

How many stepper motors?

There are 4 stepper motos

What are the motors being used for?

I will use 4 motors (17hs4401) connected with an auger as powder dispenser

Is it essential that the motors move in a co-ordinated manner - for example motorB moves 123 steps in the same time that motorA moves 837 steps?

Yes they start in the same time , as i tell you for example M1: 62 steps, M2 : 0 steps, M3: 259 steps, M4: 9 steps

aymannox:
Yes they start in the same time , as i tell you for example M1: 62 steps, M2 : 0 steps, M3: 259 steps, M4: 9 steps

You have not said whether they must all stop at the same time after having moved different numbers of steps - that is the essential thing I want to know as it has an important impact on how you write the code.

Can you provide a diagram of the powder dispenser machine you want to create - it will help us to understand what you are doing?

And you have not posted a link to the datasheet for your stepper motor.

...R

No, Stopping at the same time is not necessary
The 4 motors are placing on a horizontal plane

My motor datasheet (17HS4401)

Any help ?

That information makes things very much clearer. if you are asking a future question be sure to provide that level of info at the start.

Things are very simple if the motors do not need to stop at the same time.

All you need is code something like this

stepperA.setSpeed(sss)
stepperB.setSpeed(sss)
// etc

stepperA.move(mmm)
stepperB.move(mmm)
//etc

stepperA.run()
stepperB.run()
// etc

All the code won't go in the same place, of course. You might set the speed in setup() and set the movement in a function that takes input from the user. The calls to run() will go into loop()

...R

Robin2:
That information makes things very much clearer. if you are asking a future question be sure to provide that level of info at the start.

Things are very simple if the motors do not need to stop at the same time.

Thank you very much and, i will not redo this mistake.

Last question :
I want to know how to set Vref of my motor (17HS4401) that have 1.7A as rated current , as shown in the table

I have DRV8825 driver
1-Method
1.7A / 2 = 0.85v (vref)

2-Method
The motor use the full step mode so the current will be 0.7 times (70%) the current limit :
current limit = 1.7A / 0.7 = 2.43A
Vref = current limite / 2 ==> 2.43/2 2.43 = 1.21V

3-Method
vref = Inom * 5 * Rsense *0.7 so Vref = 1.7 * 5 * 0.1 * 0.7 = 0.6V

what do you think?

The Pololu DRV8825 web page has a lot of info, including a video, about setting the current limit.

See also this tutorial

...R

Yes, I've seen them before
Only 70% value bothered me, i did not understand it well !!! Should i divide or multiply it in 1.7A my motor rated current or just use 1.7A directly to calculate vref , please tell the correct method, I do not want to burn the motors

1-Method
1.7A / 2 = 0.85v (vref)

2-Method
The motor use the full step mode so the current will be 0.7 times (70%) the current limit :
current limit = 1.7A / 0.7 = 2.43A
Vref = current limite / 2 ==> 2.43/2 2.43 = 1.21V

3-Method
vref = Inom * 5 * Rsense *0.7 so Vref = 1.7 * 5 * 0.1 * 0.7 = 0.6V

This is what the Pololu page says - it seems very straightforward.

One way to set the current limit is to put the driver into full-step mode and to measure the current running through a single motor coil without clocking the STEP input. The measured current will be 0.7 times the current limit (since both coils are always on and limited to approximately 70% of the current limit setting in full-step mode).

Another way to set the current limit is to measure the voltage on the “ref” pin and to calculate the resulting current limit (the current sense resistors are 0.100Ω). The ref pin voltage is accessible on a via that is circled on the bottom silkscreen of the circuit board. The current limit relates to the reference voltage as follows:

Current Limit = VREF × 2

So, for example, if you have a stepper motor rated for 1 A, you can set the current limit to 1 A by setting the reference voltage to 0.5 V.

The reason for the 70% is because if you use a multimeter to measure the coil current in a stationary motor set at full-step mode what you measure will be 70% of the limit that is applied when the motor is running. The driver lowers the current when there are no steps being made.

Be VERY CAREFUL never to disconnect the wires between the motor and the stepper driver while the driver is powered up. The driver will be instantly destroyed,

...R

Please can you tell how to calculate vref in my case: bipolar stepper motor (17HS4401) 1.7A rated current as mentioned in the datasheet

Current Limit = VREF × 2

1.7 = VREF x 2

1.7 / 2 = VREF

0.85 = VREF

...R

Thanks, is this the correct schematic circuit to drive the 4 stepper motors??