Set Custom User Reference Frame via CAN bus Arduino

Hi, I’m using the ODrive Pro board, which communicates with an Arduino via CAN bus. I already did all the configuration and calibration of the board via odrivetool, but since I am also using the anti-cogging calibration, I had to turn on the absolute_setpoints to use the onboard encoder. Because of this, every time I reboot the board I have to set the pos_estimate as such:

odrv0.axis0.pos_estimate = odrv0.onboard_encoder0.raw

Otherwise I get MISSING_ESTIMATE error when the Arduino tries to send the commands to the ODrive. Is there a way to send this command via CAN bus with the Arduino? That way the ODrive can work without having to be using a computer nearby.

I saw you can use the function setAbsolutePosition(), but I don’t know how to get the odrv0.onboard_encoder0.raw.

Thanks in advance!

You would have to modify the Arduino code to use arbitrary parameter access.

However, there’s a much easier way to do this :slight_smile:

Using the absolute encoder reference frame, the ODrive will automatically initialize pos_estimate to the load encoder’s output – I’m assuming you’re using the onboard encoder as both commutation and load.

Does this mean that I have to do the anti-cogging calibration again?

Hmm, I don’t believe you do, since setting those parameters will have the same effect as odrv0.axis0.pos_estimate = odrv0.onboard_encoder0.raw

1 Like