More speed required

655 views
Skip to first unread message

Luke Lawcock

unread,
Nov 9, 2016, 7:22:02 AM11/9/16
to accelstepper
Hi all,

I have an Arduino Due running the following code, I require more speed however. 
  • If i remove the setMinPulseWidth I lose torque and gain no speed, if I increase it, i lose speed
  • If i increase setMaxSpeed, it stays almost the same, i have tried increments upto 20000
  • I cannot increase the acceleration due to the weight and inertia of the gearbox and adjoined parts.
Any advice?

Kind Regards
Luke

//Stepper Motor 23HS33-3008D
//Driver M542T
#include <AccelStepper.h>
#include <MultiStepper.h>

AccelStepper motor(1, 7, 8);

const int buttonPin = 3;     // the number of the pushbutton pin

// * pushbutton attached to pin 3 from +5V
// * 10K resistor attached to pin 3 from ground

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  motor.setMaxSpeed(12250);
  motor.setAcceleration(61250);
  motor.setMinPulseWidth(20);
  motor.setCurrentPosition(0);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is high:
if (buttonState == HIGH) {
    motor.moveTo(36750);
    motor.run();
} else {
    motor.setCurrentPosition(0);
    motor.stop();
}
}

gregor

unread,
Nov 9, 2016, 7:28:45 AM11/9/16
to accelstepper
have you tried increasing the motor driver supply voltage, too? higher supply voltage means higher maximum step speed. you can supply up to 50V to the M542T (according to this page: http://www.omc-stepperonline.com/24-phase-nema-23-stepper-motor-driver-2450vdc-15a45a-256-microstep-m542t-p-293.html )

Luke Lawcock

unread,
Nov 9, 2016, 7:36:51 AM11/9/16
to accelstepper
Yes the power supply is 48V, 4.4A

gregor

unread,
Nov 9, 2016, 7:47:54 AM11/9/16
to accelstepper
I'll check your sketch with my oscilloscope as soon as I have time. what speed do you need to reach?

Luke Lawcock

unread,
Nov 9, 2016, 8:12:58 AM11/9/16
to accelstepper
I'd need to calculate it, I will get back to you this evening. 


On Wednesday, 9 November 2016 12:22:02 UTC, Luke Lawcock wrote:

Hugh Gilhespie

unread,
Nov 9, 2016, 12:22:09 PM11/9/16
to accels...@googlegroups.com
Hi Luke,

I am running AccelStepper with a Teensy 3.2 with a 96 MHz clock and it has no problem reaching about 18000 steps per second. This is with a Nema23 motor (23HS30-2804S_PG47) with a 47:1 reduction gearbox. The driver is a Gecko G251X.

I have not tried to run my setup any faster than 18000 steps/second but I would expect it to run to around 24000 based on the known  limit of ca. 4000 steps per second with a 16 MHz Arduino chip and by similar reasoning, you should expect about 21000 steps/second from your motor.

I know the M542 driver says up to 200 kHz input pulse rate but I have had at least one bad experience with the Chinese stepper drivers so if your code is OK - which it certainly seems to be, I think I would suspect the driver.

Regards, Hugh

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gregor

unread,
Nov 10, 2016, 3:03:38 PM11/10/16
to accelstepper
with the sketch from your original post I was able to achieve a maximum speed of ~12,500 steps / second. you can still gain a bit of speed by setting the minimum pulse width lower - 20 is default, i was able to achieve ~16,000 steps / second with pulse width 0. (I set the maximum speed much higher for this test)

you should move the run() outside the if block, towards the end of your loop function, or the motor will not decelerate after you call stop().

Luke Lawcock

unread,
Nov 10, 2016, 3:13:47 PM11/10/16
to accelstepper
Hugh, gregor,

Thanks for the information, I looked at the teensy but went for the Due as it is 84MHz without overclocking, maybe I should have gone for the teensy. I have tried two M542T drivers and both give the same result, not to say that they both aren't a bit rubbish. 

I have today calculated the steps and speeds and I can say that when I have changed 'motor.moveTo(36750);' to 3000 which is the steps I require, I am achieving this. However, the speed I require it to do it at is 0.3 seconds, which i am not achieving. Is there a formula to work out the amount of steps travelled in the accelerating period? I am awfully close to where I need to be, I'd imagine in the region of less than 0.1, possibly 0.04 seconds.

KR Luke


On Wednesday, 9 November 2016 12:22:02 UTC, Luke Lawcock wrote:

Luke Lawcock

unread,
Nov 10, 2016, 3:15:30 PM11/10/16
to accelstepper
Hi gregor,

I will try again with no pulse width, however i think it lost all torque when i tried it before, i have posted more information a few minutes ago. Thankyou for your help.

Luke Lawcock

unread,
Nov 10, 2016, 3:21:27 PM11/10/16
to accelstepper
Also i want the motor to stop without deceleration, currently it stops dead which is what i want to achieve 

Luke Lawcock

unread,
Nov 10, 2016, 6:07:27 PM11/10/16
to accelstepper
//Stepper Motor 23HS33-3008D
//Driver M542T
#include <AccelStepper.h>
#include <MultiStepper.h>

AccelStepper motor(1, 7, 8);

const int buttonPin = 3;     // the number of the pushbutton pin

// * pushbutton attached to pin 3 from +5V
// * 10K resistor attached to pin 3 from ground

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  motor.setMaxSpeed(15000);
  motor.setAcceleration(75000);
//motor.setMinPulseWidth(20);
  motor.setCurrentPosition(0);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is high:
if (buttonState == HIGH) {
    motor.moveTo(3000);
    motor.run();
} else {
    motor.setCurrentPosition(0);
    motor.stop();
}
}

From some napkin math, this code should achieve 3000 steps in 0.3 seconds, can anyone confirm?

KR Luke
 

Hugh Gilhespie

unread,
Nov 11, 2016, 6:06:42 AM11/11/16
to accels...@googlegroups.com
Hi Luke,

My napkin suggests a rather different answer.

Accel = 75000 pps^2 maxSpeed 15000 pps
Accel iniSpeed endSpeed avgSpeed Total
Time, s pps pps pps Pulses
0.02 0 1500 750 750
0.04 1500 3000 2250 3000
0.06 3000 4500 3750 6750
0.08 4500 6000 5250 12000
0.1 6000 7500 6750 18750
0.12 7500 9000 8250 27000
0.14 9000 10500 9750 36750
0.16 10500 12000 11250 48000
0.18 12000 13500 12750 60750
0.2 13500 15000 14250 75000
0.22 15000 15000 15000 90000
0.24 15000 15000 15000 105000
0.26 15000 15000 15000 120000
0.28 15000 15000 15000 135000
0.3 15000 15000 15000 150000

I am not convinced this calculation is correct but if it is, you will have made a lot more that 3000 steps in 0.3 seconds.
My calculation - Excel spreadsheet - is based on the following assumptions:

Acceleration is linear wrt time
The 'mean' pulse rate over a time interval is simply half of the final rate - initial rate.

I would normally say Hope This Helps - but I'm not at all sure that it does.

Regards, Hugh

 

--

Hugh Gilhespie

unread,
Nov 11, 2016, 6:14:20 AM11/11/16
to accels...@googlegroups.com
Right, having used a nice, clean napkin, I find we are in total agreement!!

Accel iniSpeed endSpeed avgSpeed Total
Time, s pps pps pps Pulses
0.02 0 1500 750 15
0.04 1500 3000 2250 60
0.06 3000 4500 3750 135
0.08 4500 6000 5250 240
0.1 6000 7500 6750 375
0.12 7500 9000 8250 540
0.14 9000 10500 9750 735
0.16 10500 12000 11250 960
0.18 12000 13500 12750 1215
0.2 13500 15000 14250 1500
0.22 15000 15000 15000 1800
0.24 15000 15000 15000 2100
0.26 15000 15000 15000 2400
0.28 15000 15000 15000 2700
0.3 15000 15000 15000 3000

Apologies for my initial stupidity - I used an old spreadsheet I had set up where my time intervals were 1 second
so I missed out on the need to count pulses in fractional seconds.

Regards again, Hugh

Luke Lawcock

unread,
Nov 11, 2016, 6:38:57 AM11/11/16
to accelstepper
Hugh,

Thankyou so much for the clarification from your spreadsheet, I hadn't thought to do that, I was literally drawing graphs on paper lol! I'm rough with excel but I may have a go myself as it looks very handy.

I also think I have a small delay from my PLC as its a relay output which is 2Hz or 0.5Hz depending on resistive or inductive, which I need to look into. 

Do you have a link to your Teensy setup as I may need to increase the processor speed as gregor was only able to get ~12500 steps out of the arduino setup I have with the minPulseWidth set a 20 microseconds (if I go lower, I have zero torque). 

Thanks again,

Kind Regards 

Luke  

Hugh Gilhespie

unread,
Nov 11, 2016, 6:52:52 AM11/11/16
to accels...@googlegroups.com
Hi Luke,

The answer is yes but I am just about to go out so I will reply in more detail this evening.

Regards, Hugh

--

Luke Lawcock

unread,
Nov 11, 2016, 6:59:40 AM11/11/16
to accelstepper
Hugh,

Thankyou kindly sir, I look forward to it.

KR Luke
Reply all
Reply to author
Forward
0 new messages