I'm building a robot using 4 UNO's w/ motor shields coordinated by a 2560, all talking over TWI. Its coming along nicely, but I've run into a snag on the UNO code and wondered if any of you out there...
If I compile a 'stepperTest.pde" using the Arduino IDE, it runs fine: both steppers step. (all the code does is alternate between motors, stepping forward and backward in the 4 different modes).
If I cut-and-paste the UNO code into Studio4, compile, load w/ avrdude, stepper 1 works but stepper2 does not. Stepper2 has no current, no latching...it turns by hand without the resistance a stepper should when engaged.
I've wandered the AFMotor.cpp code and found naught of the smoking gun.
Suggestions?
Yes, I can abandon using S4 for the UNO, but it would be nice to have the other tools at hand when things go awry.
It wasn't the delay. It was the library file for AFMotor.cpp. The enabling of the H bridges in AFStepper::AFStepper is followed by initialization of PWM, which disables the bridges. By copying the bridge enable lines, it works:
// enable both H bridges
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(5, HIGH); // copy this line
digitalWrite(6, HIGH); // and this line
// use PWM for microstepping support
// use PWM for microstepping support
initPWM3(1);
initPWM4(1);
setPWM3(255);
setPWM4(255);
digitalWrite(5, HIGH); // paste this line
digitalWrite(6, HIGH); // and this line
This is 'duh' code. Why did it work in the IDE? I will post this find to the folks who wrote the library file...