Closed loop control with gimbal motor

Hi all,

I have an ODrive3.6 connected to a GM6208 brushless DC gimbal motor and an AS5048A encoder.
When calibration is performed the motor spins slowly and no errors occur. Just once in a while I get ENCODER_ERROR_CPR_POLEPAIRS_MISMATCH. The problem is that I can not get the motor running in closed loop control. I have made following observtions:

  • I get phase inductance and phase resistance values of 0. Is this coming as a result of the gimbal mode because there is no current control and those values are not necessary?
  • For one turn is roughly 15000 instead of 16384 as given in the data sheet (2**14). Is this possible with this type of encoder? Could it be a reason for the control problems?
  • In velocity control mode the motor spins occasionally for high velocity gains when started manually. However, it often stops after one turn. If it spins more often it gets slower at a certain point each turn.
  • I also tried torque control mode to try the inner most control loop but I do not get any reaction from the motor (no torque, no motion) - vel_limit and vel_gain were set to 2 and 0.2.

I would be very happy if anyone had any ideas on a solution.

Thanks in advance!

No this is wrong, it should be exactly 16384 per turn, and your encoder.config.cpr must be set to 16384.
Maybe you have the wrong number for motor.config.pole_pairs ?

I think that should not be the cause of the problem: The pole pair number is set to 14 (the motor is 24N28P) and cpr is set to 16384.

Ok, try setting your cpr to 16384, zero the position, and turn the motor 10 turns by hand. What now is the value of encoder.shadow_count and encoder.pos_estimate? (it should be ~ 163840 of course, and certainly not 150000)

Also try increasing encoder.config.calib_scan_distance - this means it takes a bit longer at calibration but it should be more accurate.

Ok, the encoder seems to be correct. Indeed it gives roughly 163800 counts for 10 turns. I set the calibration scan distance to 600, but the closed loop control still doesn’t work. If it is not turning in the torque control mode, does that mean that the problem is still somewhere in the calibration?

Hmm, I’m not sure. Have you tried normal non-gimbal mode?

Also, no I don’t think getting a phase_resistance and phase_inductance of 0 is right, even for gimbal mode. But I may be wrong there.

The other thing is, in gimbal mode there is a parameter that affects the maximum voltage it ill apply, which is a bit like the equivalent of motor.config.current_lim (might even be the same thing with volts mapped to amps)

Then I get
motor: Error(s):
MOTOR_ERROR_PHASE_RESISTANCE_OUT_OF_RANGE
As I understood for this motor type (datasheet 32Ohm phase resistance) the current noise is too high to measure resistance.
I thought that not setting phase resistance and inductance (or setting it 0) in gimbal mode could make sense because there is current control loop (in my understanding the values are used in high current mode for tuning the current loop)

It’s true that there is no current loop, but ODrive still needs to know the resistance (and maybe the inductance too) to map voltage (PWM duty) to current.
Try manually setting motor.config.phase_resistance to 32 and see if that helps.

1 Like

Nah, in Gimbal mode “current” commands are actually voltage commands. It doesn’t know anything about current.

Using a hand-set phase_resistance would make more sense, true.

1 Like

I set the phase resistance to 16 Ohm (assuming a star connection - measured 32Ohm between motor wires). Still the problem remains.
For MOTOR_TYPE_HIGH_CURRENT I still get MOTOR_ERROR_PHASE_RESISTANCE_OUT_OF_RANGE during AXIS_STATE_FULL_CALIBRATION_SEQUENCE.

Have you tried increasing motor.config.current_lim ? in gimbal mode
From what wetmelon says, this is effectively motor.config.voltage_lim :stuck_out_tongue:

So if that were set to 2, the limit is not 2 Amps, bit 2 volts. That might explain why it doesn’t move.

The current limit is set to 5. In velocity control mode there is also a quite strong torque feelable. The motor is just locked to certain positions. If pushed it can happen that it turns once.

Ok that sounds more like you have a problem with your encoder then.

Is there any chance it could be slipping on the shaft or going out of position somehow? Is there any load on the motor during calibration?

Is it possible that the Encoder somehow distorted within one turn? I mean the evaluation of 10 turns showed that the cpr value is more or less correct.

Yes that’s possible. Try using the liveplotter
If you find that the position is not linear with actual angle, then maybe your magnet is at the wrong height or is off centre.
I’d be very surprised if it was distorted enough to cause such a commutation failure inside of one turn though.

Is the encoder connected over SPI? Or A/B/Z ?

I checked that using the liveplotter during the calibration sequence and everything looks quite linear. A very slight waviness is observable but that seems to come from the slight speed changes during the turn.
The encoder is connected over SPI using ENCODER_MODE_SPI_ABS_AMS

Would it make sense to manually change the encoder offset? It seems that the encoder is working and also odrive is able to turn the motor without feedback (in calibration mode) so the problem should be in the commutation.