0

how to increase the speed of a stepper motor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

how to increase the speed of a stepper motor

by wlaf123 on Wed Sep 06, 2017 12:03 pm

I am using a dc and stepper motor hat to control a 12V, 350mA stepper motor. The motor hat is mounted on a Raspberry Pi model 3. I downloaded and installed the Motor Hat Python Library from GitHub. When I first ran the code StepperTest.py, the motor rotated as expected, but the rotational speed was slower than expected and one of the motor rotated with jerky motion. After running the code StepperTest.py a few more times and another codes like DualStepperTest.py, the jerky motion went away. But the speed of both motor was still very slow. It takes about 11 seconds to make one revolution, which is about 6 rpm. I was expecting 30 rpm and I am not sure what is limiting the speed. I need help to understand this issue.

The speed control .setSpeed() was set to 30. Reducing this value to 10 could reduce the speed by a factor of 2.
The step method was .SINGLE step.
The direction was set to FORWARD.
The number of step was set to 200 as default.
The delay parameter .sec_per_step was set to 0.1 as default. Changing it did not increase speed.

wlaf123
 
Posts: 5
Joined: Sat Jul 15, 2017 5:18 pm

Re: how to increase the speed of a stepper motor

by adafruit_support_carter on Wed Sep 06, 2017 12:14 pm

The speed control .setSpeed() was set to 30. Reducing this value to 10 could reduce the speed by a factor of 2.

This is how you should control speed. Are you saying it had no effecet?

The delay parameter .sec_per_step was set to 0.1 as default. Changing it did not increase speed.

Don't modify this parameter directly. Use .setSpeed().

Post a photo of your setup showing all connections. Can you provide more details about what stepper motor you are using (product link)?

adafruit_support_carter
 
Posts: 3145
Joined: Tue Nov 29, 2016 2:45 pm

Re: how to increase the speed of a stepper motor

by adafruit_support_bill on Wed Sep 06, 2017 12:52 pm

Differences between the selected and actual speed can be due to a number of factors:
1) The speed of the i2c bus. At the default 100KHz, a 1.8 degree (200 step) motor will max out at about 50 RPM. (It is possible to increase the i2c clock rate)
2) Time-slicing on the Pi. If you have other processes contending for processor time, your motor process will get swapped out and the step intervals may stretch.
3) i2c communication overhead. This is not factored into the step timing calculation and can be an issue at high step-rates.

adafruit_support_bill
 
Posts: 62225
Joined: Sat Feb 07, 2009 10:11 am

Re: how to increase the speed of a stepper motor

by wlaf123 on Wed Sep 06, 2017 9:48 pm

Differences between the selected and actual speed can be due to a number of factors:

1) The speed of the i2c bus. At the default 100KHz, a 1.8 degree (200 step) motor will max out at about 50 RPM. (It is possible to increase the i2c clock rate)

I could not find an easy way to check the default value of the i2c clock rate. Posts in on-line forum suggested to use :
sudo sys/module/i2c_bcm2708/parameters/baudrate. When I tried it, my system could not find it. Searching for it found something similar. I found /sys/module/i2c_bcm2835/parameters/debug.

2) Time-slicing on the Pi. If you have other processes contending for processor time, your motor process will get swapped out and the step intervals may stretch.

I am not sure what is time slicing. If it is necessary then I will try it. How much more speed can it deliver?


3) i2c communication overhead. This is not factored into the step timing calculation and can be an issue at high step-rates.

How much more speed exceeding 30 rpm can this deliver?


4) I got the ROB 09238 motor from Sparkfun.com. I believe it is the same as your Stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA PRODUCT ID: 324, which was out of stock for a long period of time.


5) Attached is a photo of the motor, motor controller hat, and Raspberry Pi.
Attachments
IMG_0180.jpg
IMG_0180.jpg (108.23 KiB) Viewed 145 times

wlaf123
 
Posts: 5
Joined: Sat Jul 15, 2017 5:18 pm

Re: how to increase the speed of a stepper motor

by wlaf123 on Wed Sep 06, 2017 10:05 pm

The speed control .setSpeed() was set to 30. Reducing this value to 10 could reduce the speed by a factor of 2.

This is how you should control speed. Are you saying it had no effecet?

I am saying that .setSpeed() is functional. It can slow down the motor but not speed up the motor.

wlaf123
 
Posts: 5
Joined: Sat Jul 15, 2017 5:18 pm

Re: how to increase the speed of a stepper motor

by adafruit_support_carter on Wed Sep 06, 2017 10:35 pm

It can slow down the motor but not speed up the motor.

Yeah, then it sounds like you might be hitting an upper bandwidth limit as Bill has suggested.

adafruit_support_carter
 
Posts: 3145
Joined: Tue Nov 29, 2016 2:45 pm

Re: how to increase the speed of a stepper motor

by adafruit_support_bill on Thu Sep 07, 2017 6:08 am

I could not find an easy way to check the default value of the i2c clock rate.

I believe that the default i2c speed on the Pi is 100KHz. The motor HAT will work fine at speeds up to 400KHz. One customer was running his at 800KHz.

I am not sure what is time slicing.

The operating system on the Pi can run many programs simultaneously. To do that, it switches rapidly between programs - giving each one a small 'slice' of the processor time. Since no program has exclusive access to the processor, they can't reliably perform time critical operations like stepping a motor at a certain rate. To minimize contention for the processor, you need to stop other programs and disable any background daemons that might be stealing time from your motor program.

I got the ROB 09238 motor from Sparkfun.com. I believe it is the same as your Stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA PRODUCT ID: 324,

The fastest I have been able to get these to run is 250 RPM. This appears to be the limits of this motor using a 12v supply and the motor drivers on the HAT (my test was actually on at Arduino with the MotorShield - which uses the same circuitry). To achieve that speed, I had to increase the i2c clock rate to 400KHz and modify the library to minimize the communication overhead.

The step method was .SINGLE step.

SINGLE is the weakest of all the step modes. Use DOUBLE if you are trying to maximize speed.

adafruit_support_bill
 
Posts: 62225
Joined: Sat Feb 07, 2009 10:11 am

Re: how to increase the speed of a stepper motor

by wlaf123 on Fri Sep 08, 2017 10:44 am

Yeah, then it sounds like you might be hitting an upper bandwidth limit as Bill has suggested.

Assuming my i2c clock setting is default to standard speed of 100 kHz, that would enable a motor to run at about 50rpm. Since my motor runs at 6 rpm, which is about 10x slower, it is more likely a hardware issue. I never modified any boards,, so the Rp of the bus is as it is from the manufacturer. I added the motor hat and motor, whose cable was cut to about 12 inches long. Can this reduce speed by 10x ? What was the cable length in your setup ? I wish I had a scope to measure the waveform.

My Raspberry Pi is brand new. I would be very surprised to find some atypical demon running in the background. I do not even know how to make a demon. Whatever demons run on my setup are the standard demons.

wlaf123
 
Posts: 5
Joined: Sat Jul 15, 2017 5:18 pm

Re: how to increase the speed of a stepper motor

by wlaf123 on Fri Sep 08, 2017 10:56 am

Wait a minute, the cable is between the motor and motor controller, so loading of the cable should not impact the i2c bus speed, right?

wlaf123
 
Posts: 5
Joined: Sat Jul 15, 2017 5:18 pm

Re: how to increase the speed of a stepper motor

by adafruit_support_bill on Fri Sep 08, 2017 11:34 am

Since my motor runs at 6 rpm, which is about 10x slower, it is more likely a hardware issue. I

i2c bandwidth is only one of the possible limiting issues mentioned above. If your Pi is doing other things, you may have contention for the processor.

The most common speed-limiting hardware issues are inadequate power supplies. For that motor you need one capable of 700mA minimum.

Also, you mentioned that you were using the SINGLE stepping mode. That is the weakest of all the stepping modes and the lack of torque may be limiting your top speed. Use DOUBLE for best performance.

adafruit_support_bill
 
Posts: 62225
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.