stepper.setSpeed(50);
stepper.moveTo(stepper.currentPosition()-50)
stepper.runSpeedToPosition();
Will the stepper run backwards to get to the position? Last time I
tried this I ended up needing to do .setSpeed(-50) to get it to run
backwards.
Thanks
Sandy Noble
--
Sandy Noble
On Monday, March 12, 2012 04:43:52 PM Sandy Noble wrote:
> Oh cool, I wondered what I was missing to make sense of
> runSpeedToPosition. Does this take reverse speed into account? That
> is, if I do
>
> stepper.setSpeed(50);
> stepper.moveTo(stepper.currentPosition()-50)
> stepper.runSpeedToPosition();
>
> Will the stepper run backwards to get to the position?
Yes, if you have the latest version.
> Last time I
> tried this I ended up needing to do .setSpeed(-50) to get it to run
> backwards.
Yes, that was the bug I fixed.
Cheers.
Mike McCauley mi...@open.com.au
Open System Consultants Pty. Ltd
9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.open.com.au
Phone +61 7 5598-7474 Fax +61 7 5598-7070
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.
I think you want something like:
#include <AccelStepper.h>
AccelStepper stepper; // Defaults to 4 pins on 2, 3, 4, 5
void setup()
{
stepper.setMaxSpeed(1000);
}
void blockingRunSpeedToPosition(long position)
{
stepper.moveTo(position);
stepper.setSpeed(50);
while (stepper.distanceToGo() != 0)
stepper.runSpeedToPosition();
}
void loop()
{
stepper.moveTo(100);
stepper.setSpeed(50);
blockingRunSpeedToPosition(100);
delay(2000);
blockingRunSpeedToPosition(0);
// done, stop here
while (1) ;
}