Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Motor Control in CCW direction #14

Open
dcyoung opened this issue May 12, 2017 · 5 comments
Open

Issues with Motor Control in CCW direction #14

dcyoung opened this issue May 12, 2017 · 5 comments

Comments

@dcyoung
Copy link

dcyoung commented May 12, 2017

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:

  • a modified version of Adafruit_Python_GPIO library, which attempts to remedy a potential issue with i2c traffic
  • a modified version of Adafruit-Motor-HAT-Python-Library, which attempts to fix a possible issue with the library not using custom stepper parameters which are passed in during construction

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.

@dcyoung
Copy link
Author

dcyoung commented May 13, 2017

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.

@dcyoung
Copy link
Author

dcyoung commented May 13, 2017

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.

@dcyoung
Copy link
Author

dcyoung commented May 13, 2017

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.

@dcyoung
Copy link
Author

dcyoung commented May 13, 2017

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.

https://github.com/scanse/Adafruit-Motor-HAT-Python-Library/blob/124db6c26dbd0ab3c47231c5093dd279e09b9031/Adafruit_MotorHAT/Adafruit_MotorHAT_Motors.py#L114:L116

@dcyoung
Copy link
Author

dcyoung commented May 18, 2017

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 14a9f43 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant