Calibration with AS5047P

Hi there,

I have a problem getting started with my ODrive and the AS5047P encoder. I have tried both SPI and ABI, with different errors. I guess I would prefer to have it working over SPI (higher CPR, hence higher resolution?), so let’s start from there.

I have ODrive v3.6.56 with firmware 0.5.4 (ODriveTool running on Ubuntu 18.04 LTS)

I have tested the encoder with an Arduino and it works fine. It seems to work fine also with the ODrive. I have set it up following the user guide, and shadow_count increases of ~16384 with a full turn. Hence, I have set the CPR to 16384. The spi_error_rate is very low, i.e. spi_error_rate: 1.992866409976392e-27 (float).

After setting the encoder, I have increased to 15 A the calibration_current and saved the configuration.

At this point, if I do odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION, nothing happens.

In [51]:  odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION

In [52]:  odrv0.axis0.error
Out[52]: 1

In [53]: dump_errors(odrv0)
system: no error
axis0
  axis: Error(s):
    AXIS_ERROR_INVALID_STATE
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  sensorless_estimator: no error
  encoder: no error
  controller: no error

Side question: I have set up the number of pole pairs to 7, as I counted 14 permanent magnets in the rotor. Is that correct?

I don’t know if I’m doing something wrong. Any help is appreciated!
Cheers

You probably haven’t completed the motor calibration?

In [2]: odrv0.axis0.motor.is_calibrated
Out[2]: False

Did you try:

In [3]: odrv0.axis0.requested_state  = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

Or:

In [3]: odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION

Yeah, so that was failing too, and I tried to do encoder calibration before (I was a bit confused).

After many trials, I figured the encoder was mounted poorly. I was able to debug the encoder readings thanks to this great example of this Arduino library for the AS5047P: BasicReadAngleAndDebugInfo

Basically, the main issue was that I was getting MAG TO LOW = True, and that was probably causing poor accuracy/stability of the angle readings from the encoder. I re-mounted it on the motor and double-checked everything, and I was to successfully complete the AXIS_STATE_FULL_CALIBRATION_SEQUENCE!

Now, I finally have:

In [6]: odrv0.axis0.motor.is_calibrated
Out[6]: True
2 Likes