Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: motor disableOutputs not releasing motors
polarhb
Newbie
Posts: 11
Permalink
Post motor disableOutputs not releasing motors
on: June 25, 2013, 19:03
Quote

Arduino Mega 2560
AF-compatible motorshield

This small sample (http://pastebin.com/raw.php?i=3qEbf6Si) engages the motor properly but doesn't seem inclined to release it with the disableOutputs() command. I'm hoping/expecting the motor shield will just rotate freely when disableOutputs() is called. This isn't a complicated library. What am I missing?

thanks! polarhb

#include <AccelStepper.h>
#include <AFMotor.h>
const int stepType = INTERLEAVE;
const int motorStepsPerRev = 400;

AF_Stepper afMotorA(motorStepsPerRev, 1);

void forwarda() { afMotorA.onestep(FORWARD, stepType); }
void backwarda() { afMotorA.onestep(BACKWARD, stepType); }
AccelStepper motorA(forwarda, backwarda);

void setup() {
  Serial.begin(57600);
  
  Serial.println("Engaging motors.");
  motorA.enableOutputs();
  motorA.setMaxSpeed(300);
  motorA.setAcceleration(100);
  motorA.runToNewPosition(motorA.currentPosition()+32);
  motorA.runToNewPosition(motorA.currentPosition()-32);
  
  delay(500);
  Serial.println("Disengaging motors. (should rotate freely?)");
  motorA.disableOutputs();
}
void loop() {
}
polarhb
Newbie
Posts: 11
Permalink
Post Re: motor disableOutputs not releasing motors
on: June 25, 2013, 19:27
Quote

hmm. it appears that if I hardcode a "AFmotorA.release()", it will actually release. So I have a work-around. I thought disableOutputs() would do that, but apparently not.

-polarhb

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: motor disableOutputs not releasing motors
on: June 25, 2013, 20:00
Quote

Yes, I think I put it down to the way accelstepper wraps the AFMotor objects. It does it well enough to actually use the motors, but because the accelstepper object doesn't have direct control over the pins that the AFMotor is manipulating, something gets lost in translation. I think the same thing happens with enable pins - I could never find a way to energise the motor at the current position, which is why it does a wriggle (a couple of steps either way) when you do a "set home".

sn

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.034 seconds.