AccelStepper - do other tasks at the same time?

Hi guys,
Found and installed AccelStepper for the first time yesterday. Great little library that allowed me to get more speed out of my servo with little effort. I also wrote my own acceleration code with some basic FOR statements, just to make sure I had the concept down.

With the AccelStepper code... when the motor is turning towards its new position, it seems that all other processing on the Arduino stops – the motor function essentially uses all the cycles until the destination is reached. From the perspective of the rest of the script, it’s basically a fancy DELAY() statement.

Is it possible to have other things happening at the same time – ie. a sensor read on another pin, to interrupt and maybe stop the motor? Or a sensor read to do something else completely apart from the motor (say.. LCD display update)? If there is such a function, it wasn’t obvious to me when I read the documentation.

An alternate solution is to modify the library – find the “next step” code, and introduce a call to a function that reads in the sensors. But, I’d like to avoid modifying a standard library if I could.

Thoughts?

The code to move a stepper is pretty involved. These little machines we call Arduino (and the underlying AVR) don't have a whole lot of excess resources...

Agreed 100%. I’m fine with a decrease in performance to the motor to accomplish these other tasks. However, it’s just as likely that introducing extra sensor code into the library will cause enough of a delay to disrupt the running of the stepper itself.

This may be a pro/con element when deciding between dc vs servo vs stepper motors.

I have enough CPU resources to run at least 6 steppers at once, but not enough pins. Try this it will allow you to run 2 steppers in the background leaving the processor free to do other things:

http://arduino.cc/forum/index.php/topic,89159.0.html

Plenty of extra resources!

Great link/topic - that's exactly the motor I'm working with. Strange that I didn't find your topic when I searched the forum the other day.

I'll download your sketch tonight and give it whirl (literally... :smiley: )

How can I make it easier to find? If you post on that topic it'll come to the top.