Question about Stepper motors speed

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Question about Stepper motors speed

Post by MonsieurTempete »

Hey everyone,

I've got an issue with two stepper motor connected to one Shield motor.

It's simple : the speed of the rotation of both the stepper decrease when both are moving a the same time. then it increase to normal level when only one is moving.

I wish to get the same speed, when one or two motors are moving.

I suspect voltage issue - (Voltage is cutted in half, it has to sepparate to power up both motors).

I'm still investigating the case.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

With stepper motors, the maximum combined step rate is limited by the speed of the i2c bus. It is possible to increase the speed of the i2c bus: https://www.arduino.cc/en/Reference/WireSetClock

The shield is capable of i2c clock speeds up to 1MHz.

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

Hey thank for your reply !

Infortunately, it hasn't changed the issue i'm encountering.

I am using accelstepper library combined with the adafruit motor steper library.

What I experienced, is that, if i'm using only the vanilla library, I get a constant speed (Two one-step call in the arduino loop()) - But I lose the smooth control over the speed and the "distance" traveled by the motor.

However, if i'm using accelstepper library, i get this slowlyness.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

Accelstepper does add some overhead. But it also adds 'acceleration'. So your motor takes some time to reach the maximum speed. You can override that by calling runspeed() instead of run(). http://www.airspayce.com/mikem/arduino/ ... 542b0b7514

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

Hey !

Same issue;

From another perspective, I got feedback that maybe the Arduino Uno (v3) isn't fit to both calculate then send enought informations to both stepper motor to fit speed...

So i'm considering tweaking speed when both stepper motor are fonctionning.

Maybe with testing three or four more stepper the issue will become larger.

Considering using a raspberry PI - We want to use 16 motor steppers at the same time, and we wish then to have controled "erratic" behaviors.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

From another perspective, I got feedback that maybe the Arduino Uno (v3) isn't fit to both calculate then send enought informations to both stepper motor to fit speed...
Not sure what kind of calculations you are doing. But computation speed is generally not the issue. The limiting factor is the i2c bus speed.
Maybe with testing three or four more stepper the issue will become larger.
Adding more steppers makes the bus speed issue larger. The speed of the i2c bus will limit the maximum combined step rate for all of the motors.
Considering using a raspberry PI
That would be a step in the wrong direction. The Raspberry Pi is not capable of precise timing. If you want a faster processor, use something like an Arduino (or compatible) with an M0 or M4 processor.
We want to use 16 motor steppers at the same time, and we wish then to have controled "erratic" behaviors.
The shield is probably not the best choice for a large number of motors moving at the same time. The i2c communication overhead would limit your motor speeds considerably.

You would be better off using 'step and direction' controllers. These can be controlled directly with just 2 GPIO pins each. www.pololu.com carries a good selection of 'step and direction' type stepper driver boards: https://www.pololu.com/category/120/ste ... or-drivers

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

Hey,

Thx a lot for your repply, I've just bought two polulu drivers to test them.

I might have found where the issue i'm facing starts :

In the AccelStepper Library, there is a legitimate delay (I don't know why, but I'm a bit fearfull to play with it), and I don't know how i can Bypass them.
Since i can't use multithreading on arduino, i'll be stuck with those microseconds, that are adding up themselves...

Code: Select all

void AccelStepper::step1(uint8_t step)
{
    digitalWrite(_pin2, _speed > 0); // Direction
    // Caution 200ns setup time 
    digitalWrite(_pin1, HIGH);
    // Caution, min Step pulse width for 3967 is 1microsec
    // Delay 1microsec
    [b]delayMicroseconds(1);[/b]
    digitalWrite(_pin1, LOW);
}
Update :
I've tried on a arduino Mega, The issue is the same, I've added another stepper motor, so three stepper motors, the speed is decreasing more.
I've tried also to push further the delay (Up to 250micros), i've noticed no drop of speed, so it's not the actual issue.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

In the AccelStepper Library, there is a legitimate delay (I don't know why, but I'm a bit fearfull to play with it),
That delay is to ensure that the pulse width is sufficient to trigger the step on the driver. Minimum pulse width requirements will vary from chip to chip. But 1 microsecond is the shortest delay supported by the Arduino language. To go shorter than that, you would need to do some in-line assembly code.
Since i can't use multithreading on arduino, i'll be stuck with those microseconds
If you can find a multi-threaded system with guaranteed 1 microsecond scheduling resolution, I will be very impressed. ;-)

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

Hey again !

After some investigations I have noticed that the max speed is determined by the number per seconds/milli of loop() calls.

I've tried to rewrite accelStepper Lib, then punched inside some function of the vanilla adafruit steppermotor and then did some steps by steps prints...

I've determined that, it is the capacity of calls of onestep() that does limits my speed, this is why adding more motors further limit the speed.

I've bought an arduino mega, then tested again on an UNO card, but i'm not sure that calling Wire.setclock(1000000) Does work.... (Am I stupid ? it does seems that a L is missing in the value right ?).

Update : (I've punched inside twi.h functions).
Last edited by MonsieurTempete on Fri Jul 20, 2018 8:53 am, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

I've seen that, the capacity of calls of onestep() that limits my speed, that is why adding more motors does limits the speed.
When using the shield, the speed of the 12c bus determines how log it takes to send the step commands. Using the Pololu drivers, you are only limited by the speed of writing to a GPIO pin.

Code: Select all

 i'm not sure that calling Wire.setclock(1000000) Does work.... (Am I stupid ? it does seems that a L is missing in the value right ?).
Make sure that you call setClock *after* you call begin() on the shield. Otherwise it reverts back to the default speed.
Compiler implementations vary. But strictly speaking, the 'L' suffix is correct.

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

Ok thanks, I've bought the polulu driver, but it pisses me off, i'm used to be a game-developper, not a hardware electrician :D.

I'm a bit lost, kinda like going back 30 years before when game-developper has to control their pixels on the screen.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

Keep in mind that the Arduino is an 8-bit processor similar in computing power to the the machines we developed graphics on >30 years ago - but with less memory.

Motor control, like driving a CRT is 'physical computing'. Unlike modern displays, controlling the CRTs from those days required an understanding of the physical limitations of the device - much like controlling a motor. If you exceeded the limitations of something like the horizontal flyback circuit the screen would go black and smoke would rise from the back of the cabinet. (DAMHIKT).

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

Ahaha thx a lot for your quick anwers !

Ok, i'm a bit stuck at this issue, would you help me ?

I'm trying to plug the right cables into the breadboard with the polulu driver inside.
I'm stuck with the order of the Stepper mottor cables.

https://www.pololu.com/product/2133

According to the blueprint, I've put B2 to RED (B2-A)
B1 to YELLOW (B1-C)
A1 to GRAY (A1-B)
A2 to GREEN (A2-D)

This is not correct ><.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Question about Stepper motors speed

Post by adafruit_support_bill »

This is not correct ><.
What motors are you using and what are the symptoms that bring you to that conclusion?

User avatar
MonsieurTempete
 
Posts: 10
Joined: Tue Jul 17, 2018 12:03 pm

Re: Question about Stepper motors speed

Post by MonsieurTempete »

https://www.adafruit.com/product/324

I'm using this motor, the motor is have some strange shakes/make strange noise.
According to this code the motor should do one full rotation, not just some strange moves.

But "IT TURNS".

digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”