Pages: [1]   Go Down
Author Topic: AccelStepper - do other tasks at the same time?  (Read 848 times)
0 Members and 1 Guest are viewing this topic.
Ontario
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Peter

Arduino and electronics newbie... but enjoying what I'm learning

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1024
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Ontario
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Peter

Arduino and electronics newbie... but enjoying what I'm learning

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Ontario
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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-grin )
Logged

Peter

Arduino and electronics newbie... but enjoying what I'm learning

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Pages: [1]   Go Up
Jump to: