AFMotor and accelmotor and servo

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
drmacro
 
Posts: 18
Joined: Sun Jun 03, 2012 2:39 pm

AFMotor and accelmotor and servo

Post by drmacro »

I had multistepper example working with two steppers.

I then added code to run a servo. Now the servo is working but the steppers don't move...

Are there gotchas that I haven't discovered yet above using two steppers, a servo, and the accelmotor library?

Basically added the for/next loop from the servo example right after the stepper move code in the main loop.

Mac

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: AFMotor and accelmotor and servo

Post by adafruit_support_bill »

AccelStepper requires you to call "run" regularly to step the motor. Normally it is done on each pass of the main loop. If you go into a loop doing something else, the steppers will stop until you finish that loop.

Code: Select all

// Run the motor to implement speed and acceleration in order to proceed to the target position
// You must call this at least once per step, preferably in your main loop
// If the motor is in the desired position, the cost is very small
// returns true if we are still running to position
boolean AccelStepper::run()
{
    if (_targetPos == _currentPos)
	return false;
    
    if (runSpeed())
	computeNewSpeed();
    return true;
}

User avatar
drmacro
 
Posts: 18
Joined: Sun Jun 03, 2012 2:39 pm

Re: AFMotor and accelmotor and servo

Post by drmacro »

Wasn't quite the issue but it led me to find it.

Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”