I think you would have to do something like (not tested)
void loop ()
{
stepper.moveTo(1000);
long lastPosition = 0;
while (stepper.distanceToGo())
{
run();
long thisPosition = stepper.currentPosition();
if (thisPosition != lastPosition)
{
Serial.println(thisPosition);
lastPosition = thisPosition;
}
}
while(1); // done
}
But its not a very good idea, because the cost of the print might interfere
with the correct operation of the stepper.
--
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.
If AccelStepper ever tries to calculate speeds, it limits the calculated speed
according to maxSpeed.
moveTo() calculate a new speed, and therefore maxSpeed is used at that time.
Suggest you set the speed after every call to moveTo
Cheers.
Hi,
you don't need the while loop in function loop(), you may want to remove it
don't call runSpeed() conditionally, only use setSpeed() to control the steppers
Serial output is slow, don't use it if you need high (or accurate) speeds.
long currentPosition = stepper.currentPosition(); Serial.println(currentPosition);