I'm driving a NEMA 17 stepper from ADAfruit with an arduino motor shield (first time) using AFTMotor.h library. When I tell it to go 20 rpm for one rev it goes one rev but is about 3 sec longer than it should be. Other speeds are similar up to about 200 rpm and then it gets even slower. All this time the serial monitor is printing out step numbers? (0,8,16,24) but not all of them. Is my motor being slowed down by all this serial printing. How do I turn it off. Are there instructions for this code. This is my first Arduino project. I'm driving the motor at 12v and there is no load so I don't think I have a power problem.
Looking at the AFTMotor library, all of the serial.print()ing is enclosed with #ifdef statements like so:
#ifdef MOTORDEBUG Serial.print("steps = "); Serial.println(steps, DEC); #endif
What this means is that the particular line of code will only be included in the program if MOTORDEBUG is #defined. An example:
#define MOTORDEBUG 1
In other words, eliminate any line with a #define of MOTORDEBUG to stop the printing.
Yes, this would have an effect on the stepper’s speed.
Push your baud rate upto 115200 if you haven't already done so to mitigate the effects of waiting for serial output, or just disable it!
Is my motor being slowed down by all this serial printing.
Yes. Why use a library you have no control over, just manipulate the outputs directly in your own code.