[Solved] - Encoding hooverboard motors with rotary encoder

The rotary encoder has a 3D printed piece which is connected to it, and the 3D printed piece then connects to the back of the motor.

They where bought on the official Odrive website.

Okay, I see. Can you try connecting the motor and encoder to the M1 power and encoder inputs, and using axis1 instead of axis0? Do you have an oscilloscope or similar?

And can you post the entire setup commands you use in Anaconda/ODrivetool?

I’ve connected the motor to M1 and switched over the rotary encoder wires to M1 also. I used the command “odrv0.axis1.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE” and the motor moves and then stops. When I dump the errors, the error on the axis is the same, but on the encoder the error is “EncoderError.CPR_POLEPAIRS_MISMATCH”. This is for axis1 by the way. Do you know how I can fix this error?

For the entire setup commands, I just used a Youtube video: https://www.youtube.com/watch?v=K4QkISL9Rqo&t=249s

Hello

You have entered the incorrect cpr and/or polepairs. What values did you enter for these variables?

Cheers

I’ve solved the problem concerning the encoder. But when I use “odrv0.axis1.controller.input_pos = 3” the motor moves but then stops. When I dump the errors, the main error is with the controller which is “ControllerError.OVERSPEED”. Do you know how to fix this?

Hi there,

That means the ODrive exceeded the velocity limit when moving from point to point. You can increase vel_limit_tolerance to allow more margin for exceeding the velocity limit without throwing an error. Alternatively (and better), you can use filtered position mode or trapezoidal trajectory mode to smoothly move from setpoint to setpoint. Note if using pos_filter you’ll need to tune input_filter_bandwidth to get the desired response, and if using trap_traj you’ll need to tune trap_traj.config.vel_limit, trap_traj.config.accel_limit, and trap_traj.config.decel_limit.

I solved the controller error, but I’m having some issues connecting an arduino uno/mega to the odrive to make the motor move. Do you know how to configure the odrive so that it connects to the arduino? Also, could you provide me with an arduino sketch that makes the motor move?

You can see our Arduino library for the code and example. Details on setting up the UART interface are here, and information on the protocol used is here. Are there specific issues you’ve been having?

When I type in “odrv0.config.enable_uart_a = False” I get “Attributeerror : Attribute enable_uart_a not found”

What firmware is the ODrive running? Can you show the output of odrv0.fw_ver_major, odrv0.fw_ver_minor, and odrv0.fw_ver_revision?

All these commands only give me AttributeErrors and the odrivetool can’t recognize the objects.

When you start ODrivetool, what does the version number say here?

And if your ODrive shows the firmware version when it connects (like mine does, in blue), what does that show?

The version is v0.6.7 for me.

Can you update the ODrive using the firmware update process? odrivetool — ODrive Documentation 0.5.6 documentation. You may have to force DFU, depending on your ODrive firmware version.

Which version of the firmware do I need, in order to use the arduino tools? Because when I use the command odrivetool dfu, the only available version is 0.5.6.

0.5.6 is fine and the most recent for v3.6.

Can you update to that and then try the odrv0.config.enable_uart_a = True again?

If I update the firmware, does the configuration stay intact?

No, it’ll be erased unfortunately. You can try saving and restoring it with odrivetool backup-config config.json before the update and then odrivetool restore-config config.json after the update, but as it seems your ODrive may be running some very old firmware, it won’t necessarily restore everything, so I’d expect to have to go through some of the configuration steps again, as well as motor/encoder calibration.