No movement with rotor_mode = ROTOR_MODE_ENCODER


#1

I have a motor and encoder set up, but I cannot get any commands to rotate motor when using
rotor_mode = ROTOR_MODE_ENCODER

If I set
rotor_mode = ROTOR_MODE_SENSORLESS
Then I can get a current, velocity, or position command to turn the motor.

I have set the following and have verified that the encoder is properly counting using the ‘g 1 2’ command to get the rotor encoder state.
#define ENCODER_CPR (512*4)
#define POLE_PAIRS 12
static float brake_resistance = 0.0f; // [ohm]

I have played with the various pos & vel gain variables, but so far have not had any luck.
When using ROTOR_MODE_ENCODER the motor simply locks itself into the position and resists me manually turning it.

Does anyone have any ideas what could be my problem?


#2

My guess is that your ENCODER_CPR is incorrect. What encoder are you using?


#3

I’m using the CUI AMT10. I thought I had the PPR set to 512, but I will double check the dip switches and try again.

I’m wondering though, even if my PPR was incorrectly set to the lowest, 48, or the highest 2048, wouldn’t my motor still move, just not at the actual velocity? And shouldn’t it still respond to the current commands?


#4

So my guess is based on the fact that you describe that the motor gets stuck, which can happen when the motor is not commutated properly, which happens when the encoder has problems.

But now that I read your post again, I realize that you could also be talking about the motor doing correct position control (i.e. rejecting your hand disturbance), but simply ignoring commands. So just to check which one:
If you turn the motor by hand: does it at first resist, but then when you turn enough angle kind of jump to the next detent slot? Or does it keep wanting to go back to the same place?


#5

Yes it seems to jump to the next detent slot.


#6

I double checked encoder PPR and it was correct; I also changed it to 48 PPR and adjusted code, make and make flash. Same result with .rotor_mode = ROTOR_MODE_ENCODER.

I can also still rotate the motor and it will move, stopping in some detents along the way.

I can send a current command and the motor will just vibrate, stronger with the higher current I send.

Unfortunately I’m at a stand still until I can get this figured out so hoping someone can help me get through it.


#7

During encoder calibration, does the motor move like this (move a little one way, then back again)?


#8

Yes it does exactly that, and at a slow speed very much like your example.

I’ve also verified that my CPR (PPR * 4) is correct by manually rotating the motor in ~360 degree increments and checking encoder position after each rotation.


#9

And there are 24 magnets (not coils) in your motor?


#10

Good catch, there are only 6 pairs.

I adjusted that and flashed, now instead of hitting detents when I manually turn it appears to snap back to hold the original position, yet it won’t turn to go to a position still.

Furthermore, when I set
.control_mode = CTRL_MODE_CURRENT_CONTROL
It still appears to want to hold a position. The instant I apply ‘C 0 5’ for example, it goes to some position and holds it. I can then send ‘C 0 0’ and it rotates freely.
In sensorless mode the same command would have caused it to spin until I sent ‘C 0 0’.


#11

12 pole motors are not very common, but 14 pole motors with 12 slots are common. Can you try setting pole pairs to 7?


#12

I will try that tomorrow.

I’m using a TURNIGY AERODRIVE SK3 - 4250-350KV BRUSHLESS OUTRUNNER MOTOR.

I really thought I counted 12, but maybe I was wrong.

Edit: I did some research and realized I was counting the stators not the poles and that the number of each is different. Sorry for my newbness, but I suspect this will solve my issue.

Also, when you get the GitHub wiki enabled I’ve been saving some notes/instructions for total beginners such as myself that I would like to add. This would be another good example I could add.


#13

This was my problem. Thanks for all your help!