Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Inconsistent motor behaviour using Motor Hat 2348
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Inconsistent motor behaviour using Motor Hat 2348

by arampante on Thu Jul 16, 2020 10:16 am

Hello. I recently purchased the Motor Hat ID 2348 to control a couple stepper motors. I am using motor model 14HS13-0804S which has the following specs:

* Manufacturer Part Number: 14HS13-0804S
* Motor Type: Bipolar Stepper
* Step Angle: 1.8 deg.
* Holding Torque: 18Ncm(25.5oz.in)
* Rated Current/phase: 0.8A
* Phase Resistance: 6.8ohms
* Inductance: 10mH+/-20%(1KHz)

These are the issues: I am using the motorkit library to control the motor. With the motor WITHOUT any load, I ask it to move back and forth, for example, 50 steps forward, 50 steps backward with a 1ms pause between steps.

1. The motor doesn't come back to the same location after a round trip. The amount of error and the direction seems to be random. It is almost as if the motor was randomly skipping steps (but remember there is no load). I tried different motors and same result so I don't think the problem is a defective motor. Additionally, I tried using a DRV8833 and the motors move fine!

2. When the motor moves, the first few steps (don't know exactly how many) occur fast, but then the motor slows down quite a bit (Maybe half speed or so). This is reproducible. It seems to me that the controller can't keep up with the commands? Even if I increase the pause between steps, this behavior persist.

I am using an external 5V 4A power supply (different from the power supply feeding the RB-Pi), so I don't think power is an issue. Again, when using DRV8833 motors work fine...

Please provide any suggestions you might have to diagnose or fix the problem. Thank you!

arampante
 
Posts: 4
Joined: Thu Jul 16, 2020 9:51 am

Re: Inconsistent motor behaviour using Motor Hat 2348

by dherrada on Fri Jul 17, 2020 1:47 pm

I've encountered something similar using the featherwing with a nema-17. Personally, I believe it has to do with the chip in that hat being designed specifically for DC motors but the library having a software implementation for stepper motors. I think it's probably fixable, but I don't know enough about that sort of thing to fix it. I may open an issue on the library itself if I were you. https://github.com/adafruit/Adafruit_Ci ... tor/issues

dherrada
 
Posts: 99
Joined: Thu Jan 04, 2018 4:59 pm

Re: Inconsistent motor behaviour using Motor Hat 2348

by adafruit_support_mike on Sun Jul 19, 2020 2:22 am

The symptoms you describe sound like a condition called 'cogging': the PWM signals telling the motor to step from one position to another happen faster than the rotor can keep up, so the rotor hits whatever positions it can based on the signals it can see at the time.

Steppers are subject to cogging when they're under load, but it can also happen without a load. In the no-load situation, it's a combination of the power supply's current capacity, the voltage across the coils, the impedance of the coils, and the rate at which the control signals change.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Inconsistent motor behaviour using Motor Hat 2348

by arampante on Mon Jul 20, 2020 10:29 am

Thank you for your responses. Regarding cogging: I tried a 9V power supply instead of 5V to help with the motor lag (If I understand currectly, you need higher voltage to fight back the EMF). The results were the same. Maybe 4V is not enough to solve this issue? Unfortunately this board can't go much higher.. I am trying to understand why the DRV8833 would work but not the TB6612. Both are MOSFET devices, so I would expect similar behavior... I am leaning more towards @dherrada suggestion that the problem might be an issue with the PCA9685 implementation (maybe a signal phase issue?).

I think for this project I will just build my own motor hat using the DRV chips, but since I already spent $22 on this product, I would like to understand how to make it work better.

adafruit_support_mike wrote:The symptoms you describe sound like a condition called 'cogging': the PWM signals telling the motor to step from one position to another happen faster than the rotor can keep up, so the rotor hits whatever positions it can based on the signals it can see at the time.

Steppers are subject to cogging when they're under load, but it can also happen without a load. In the no-load situation, it's a combination of the power supply's current capacity, the voltage across the coils, the impedance of the coils, and the rate at which the control signals change.

arampante
 
Posts: 4
Joined: Thu Jul 16, 2020 9:51 am

Re: Inconsistent motor behaviour using Motor Hat 2348

by adafruit_support_mike on Wed Jul 22, 2020 11:42 pm

Cogging without a load is more of a signal speed issue than a power issue (though there is some overlap with power if you're going fast). How many steps per second are you doing?

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Inconsistent motor behaviour using Motor Hat 2348

by arampante on Thu Jul 23, 2020 3:45 pm

Normally I have tried 1ms pause between steps. Assuming there are no additional delays in the thread, 1,000 steps/second or 5 rpm, but I have seen the same behavior even at 100Hz.

adafruit_support_mike wrote:Cogging without a load is more of a signal speed issue than a power issue (though there is some overlap with power if you're going fast). How many steps per second are you doing?

arampante
 
Posts: 4
Joined: Thu Jul 16, 2020 9:51 am

Re: Inconsistent motor behaviour using Motor Hat 2348

by gromain on Sat Aug 29, 2020 3:33 pm

On a Raspberry Pi 4, I measured an overhead of roughly 3ms per step. So at most, 300 steps per second with the CircuitPython library.

The more I look at it, the more I think this motor hat (and its CircuitPython library) should not be used to drive steppers if you need repeatability over steps or precision on the steps number.
gromain
 
Posts: 6
Joined: Mon Jul 04, 2011 10:32 am

Re: Inconsistent motor behaviour using Motor Hat 2348

by adafruit_support_mike on Thu Sep 03, 2020 9:36 pm

You're probably seeing the effects of time-slicing.

Linux simulates multiprocessing by giving each program about 10ms of CPU time then suspending it and giving the next process a turn. That's fine for batch processing and things that work at human speed, but doesn't work for things that require millisecond timing or better. The RasPi is notoriously unstable at controlling steppers directly, which is why the Motor Hat uses a PCA9685 PWM generator.

You can still run into timing problems if you want to control step timing at the millisecond level. Not only will you have jitter from time slicing, you'll have to consider the time it takes the RasPi to send commands to the PCA9685 over the I2C bus (100kbps).

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Inconsistent motor behaviour using Motor Hat 2348

by arampante on Thu Sep 10, 2020 9:02 am

So, I think I figured out the origin of the behavior observed:
[*] As I mentioned in a previous post, since I needed to get going with my project, I decided to purchase different driver boards. At the end I decided to use Pololu's DRV8834, which are Step/Dir input drivers. These little boards simplify quite a bit the wiring. I soldered these guys to an "Adafruit Perma-Proto HAT for Pi Mini Kit - No EEPROM - PRODUCT ID: 2310" and started the programming.
[*] Initially I used the RPIO library to generate the pulses and the performance was good, but then I added code to use an "Automation HAT" and things started to misbehave just like it did initially with the Motor Hat. The Automation HAT uses I2C for communication.
[*] I suspected that it would be a timing issue, so I decided to instead use the PiGPIO library since it uses hardware timing. With this library, the motors move smoothly even when the I2C line is being used.

With the observations above, I am basically concluding what "adafruit_support_mike" suggested: It is a time slicing problem. I don't know the exact reason, but it seems that I2C uses a big (and variable?) slice of time and therefore any other commands that require specific timing don't work accurately.

I would recommend that Adafruit puts a warning paragraph in the motor hat website stating the limitations of the board (maybe a couple hundred steps/second max?). Depending on the hardware used, this is only 1-5mm/s which is not really fast. For many projects this could be enough, but I think most projects require faster step rates than this.

arampante
 
Posts: 4
Joined: Thu Jul 16, 2020 9:51 am

Please be positive and constructive with your questions and comments.