Bizarre errors on ODrive v3.6 (position mode)

Hey guys,

I’m currently using an ODrive v3.6 in position mode and am receiving extremely bizarre errors. Right now, I am communicating to my board via UART and command it position changes of 0.05 in a loop, so that the motor oscillates between two values. Ex. the loop commands the ODrive += input_pos of 0.05 until it reaches 20, after which it commands the ODdrive -= input_pos of 0.05 until it goes back to 0. When I do this, it oscillates correctly a few times, then the motor suddenly stops and I get this error:

Note, we are only using one motor on axis0. Any help would be appreciated! Thanks

I think you must have a mismatch between odrive firmware and odrivetool version.

In the newer firmware, ODrive itself can handle this kind of trajectory generation - if you set controller.config.input_mode = INPUT_MODE_TRAP_TRAJ for example, then the position setpoint will follow the accel/decel/velocity limits set in axis.trap_traj.config.

Then you can just set input_pos = new_position directly with the UART command, and ODrive will smoothly move to the new position.

1 Like

Hi Towen, thanks for your response. We are incrementing like that because our goal is to use the ODrive on a small vehicle so that when you press the accelerator, the motor turns in small increments while you press down. Then when you let go of the pedal, the motor stops spinning. We don’t want to use velocity mode for this, which is why we are incrementing in position mode. If I am following your suggestion correctly, I don’t think this would work in the TRAP_TRAJ mode right because we don’t have a set end point? (We just want to spin the motor as long as the user is pressing the pedal down)

EDIT: I think I misread your suggestion and it might do the trick. I will implement it and let you know if it fixes it. Thanks a lot!

If you are using ODrive for a manually-driven vehicle, I would recommend torque mode. This should feel a lot smoother and more natural than position mode.
In the newer firmware versions, you can also set a velocity limit in torque mode.

EDIT: But of course, you need to be in position mode to take it back to zero after it reaches 20 revs.
Position mode with TRAP_TRAJ should be a good bet, as it will smooth out that last move rather than taking a violent step input to the position controller.
You can also switch between torque and position modes on the fly if you want, i.e. when you get to 20, switch to position and move to 0, then back to torque. But you wouldn’t be able to hold position between steps which maybe you need to do.

1 Like

Yeah, I think trap_traj is the move because we need to hold steps throughout the movement. Also, when I used trap_traj and moved the motor to a change of 1 position higher, it did the rotation but very slowly. Is there a way to increase the speed for 1 turn only? (I tried increasing vel and accel limits)

Also, for the appropriate ASCII command, would that be t or p for controlling position in this mode?

Use t for trapezoidal. What firmware version are you on? odrv0.config.fw_version_xxx

1 Like

When i run that command i get:

am i doing something wrong?

… I didn’t think anyone would type xxx lol. Type fw_version_ and then press tab, like a normal human being :wink:

odrv0.config.fw_version_major
odrv0.config.fw_version_minor
odrv0.config.fw_version_revision
odrv0.config.fw_version_unreleased

yeah I figured those would need to be replaced but when I looked in odrv0.config it didnt have any of those. When I run them individually I get:

What did you need this version number for too?

Oh sorry, it’s odrv0.fw_version_major etc, remove the config. part

See ODrive | High performance motor control

yeah that works thanks! Here are the versions. Is there a reason you asked when I inquired about the t command?

Screen Shot 2021-07-08 at 2.23.23 PM

Ah ok you’re on a bit older version (0.5.1). If your version of odrivetool (the python program) and your version of the firmware (0.5.1) don’t match, then you end up with “UNKNOWN ERROR”

Ok thanks. I think my python program is 5.2 bur as you said it looks like the firmware is 5.1. Do you know how I would update this?

odrivetool dfu, if you get lucky. Otherwise you can use one of the other modes of flashing. ODrive Tool | ODrive