Open dcyoung opened 7 years ago
Considering the possibility that the erratic behavior is due to overheating drivers.
See motor manual for specs.
The motor has a phase resistance of 7.0 ohms. With only USB power (5V), it should try to pull ~0.714 amps. The motor is only rated for 0.65amps, but that difference seems relatively negligible and the behavior suggests more of a software related issue.
Tried speeding up the I2C bus on the Raspberry Pi using
sudo modprobe -r i2c_bcm2708 && sudo modprobe i2c_bcm2708 baudrate=400000
but that didn't seem to work.
I tried running the StepperTest.py
that comes with the Adafruit-Motor-HAT-Python-Library
examples.
The example sets up a stepper like this:
myStepper = mh.getStepper(200, 1) # 200 steps/rev, motor port #1
myStepper.setSpeed(30) # 30 RPM
I modified the parameters like so:
myStepper = mh.getStepper(400, 2) # 400 steps/rev, motor port #2
myStepper.setSpeed(30) # 30 RPM
and the motor wigged out, erratically twitching back and forth.
I tried reducing the speed to 5 RPM:
myStepper = mh.getStepper(400, 2) # 400 steps/rev, motor port #2
myStepper.setSpeed(5) # 5 RPM
And surprisingly, the MICROSTEP
mode looked relatively smooth in both directions. This is odd because the scanner_base.py
isn't going nearly that fast, and the movement isn't smooth at all.
Then I tried running the example at 1RPM
myStepper = mh.getStepper(400, 2) # 400 steps/rev, motor port #2
myStepper.setSpeed(1) # 1 RPM
Movement became more erratic and I couldn't kill the process. Shortly after the pi died from a dead battery, so it's possible the odd behavior was power related.
I'm still working through the MotorHAT library, and don't fully understand all the code yet. But wondering why this snippet is repeated twice... first on lines 89-91 and then again on lines 114-116.
Among other things, it seems that a bit of the erratic behavior and backwards jitter is a result of light counter torque applied to the motor shaft. This is evident when pinching the motor shaft by hand.
Commit 14a9f4385730414a4e8e05ece159fb8b8a330fe1 changes the CCW movements to use DOUBLE
stepping when resetting the base, rather than SINGLE
or MICROSTEP
modes. This increases torque to overcome any tension from the cable or limit switch. The movement is still rough, and this should not be considered a fix.
The Adafruit MotorHat seems to have issues driving the stepper motor in the CCW (counter-clockwise ) direction. The movement is smooth in the CW (clockwise) direction, but erratic when moving CCW. A simple test script shows it skips a microstep every 8th step or so, and even in single step mode it still produces erratic behavior and can even move backwards every few steps when being driven too quickly.
It seems many others have had similar issues with the Adafruit-Motor-HAT-Python-Library. Check out the issues and pull requests.
Currently the distributed image for the sweep-3d-scanner is using:
However, these solutions don't seem to remedy the issues with CCW stepper motion. Instead, the process of resetting the base of the scanner must be accomplished at a slow speed such that the erratic motor movement is manageable.
A proper solution would permit a much faster base reset.