Various issues getting started

I am using this code and motors spins fine without any load. however, with load is a different story. Where should I look to address the torque problem. Thanks

The motor run as soon as power supply is on. Beeps and then it moves on both directions. After pressing “s” on serial monitor, the motor seems it wants to move, and sometimes moves a little bit on one direction.
After spending sometime and increasing the values on two lines below, the motor started spinning on both directions. For instance 6.2831…was change to (6.2831…)*4 and 20000 was changed to 60000.
for (float ph = 0.0f; ph < 6.28318530718f; ph += 0.01f) {
float pos_m0 = 20000.0f * cos(ph);

I am not want to guess making random changes I rather to understand the reason behind the changes.


For both of the above issues, it looks like your encoder is not very rigidly attached to the motor.
Can you make sure that it’s not possible to make the rotating part of encoder slide or slip with respect to the rotor?

When we flashed the board for the first time, we assigned the wrong PPR value. We corrected the PPR value to 2048 and now is working much, much better.


Can you recommend to me what I should put in the documentation that would have helped you to get this right?

The problem was more on this side for not reading the documentation. I would suggest to newbies like me to:

  • Check the encoder’s DIP switches and datasheet against the PPR value on firmware.
    I am assuming those are the default settings, all DIP switches off.

Thanks a lot. Now heading to tuning.

I followed the instructions to calibrate the encoder and I wasn’t able to find the line below on MotorControl/low_level.c.

“Set .encoder.use_index = true and …”

Can you please tell me where is this line located and if is not there where exactly should I add it.


For motor 0 it’s located in line 123 of low_level.c. This is a fairly new feature so if you don’t see it there in your code you may have an old release. You can update your code by using git pull.

Thanks I updated the Odrive’s firmware. I typed in my_odrive.motor0.encoder.encoder_offset and seems like I am doing something wrong. Please, can anyone point me on the right direction? Highly appreciate all your help.

You need to run ipython -i, you forgot the -i part. Then after that command you can query the odrive.

Done and thanks. Now, we are heading towards to set homing up. I am able to calculate the distance run by my cart when my 30 teeth pulley turns one revolution;however, I don’t where in the firmware to place the parameters for homing.
Also, I asked before about a more in deep explanation of the lines below to get a better understanding of the code used.
The motion control gains are currently manually tuned:

.pos_gain = 20.0f, // [(counts/s) / counts]==>is this (counts/sec)/sec?
.vel_gain = 15.0f / 10000.0f, // [A/(counts/s)]==>Is this Amps/(counts/sec)?
.vel_integrator_gain = 10.0f / 10000.0f, // [A/(counts/s * s)]==> Amps/(counts/sec * sec)


Home switch inputs is a feature that is not implemented yet. I am going to work on that really soon though, so you can subscribe to the relevant issue in github, and you will get an email when we have updates regarding this.

Yes you have understood the units in the tuning parameters correctly, except the 1st one, it should be (counts/sec)/counts