Linear Encoder Support



I apologize if this has already been answered, I was not able to find an answer.

Does ODrive support using a linear encoder?
We have some high resolution linear encoders we’d love to use with it.



This depends a bit. If you can make sure the mechanical connection between the linear actuation and the motor doesn’t flex more than about 10 electrical degrees at the max, I think you should be okay to use it directly. In that case you can substitute the rotary incremental encoder with a linear one. The interface should be the same: quadrature incremental.

Note electrical degrees are a factor of “rotor pole pairs” different from mechanical degrees.


Thanks so much for the quick reply!

Would you mind explaining this in a bit more detail?
We have a pretty solid extruded aluminum frame, similar to the pick and place machine in your demo videos.
How would I got about checking the flex our system has?

I really appreciate the help, sorry, I’m a bit new to this :smiley:


I think for most applications it shouldn’t be a problem, the flex is likely small enough.
I don’t know what other kind of problems you may get, since I haven’t had a report of anyone trying linear encoders yet, but I expect no major issues. I’d encourage you to try it.


Okay great!

I’ll give it a try and post my results.
Won’t be able to test for about a month though.

Thanks again for the help!


I’m very curious about this too. I would like to use the Odrive with glass encoders in a CNC machine I’m building. It would be perfect to compensate for cheap C7 ballscrews without mapping the screw.


Like I mentioned before, it will depend on how stiff the connection between the motor and the linear axis is. If the flex is small, then I think it will be doable. Here are some things you should keep in mind:

  • Make sure you provision for an accurate home switch
  • For now it will only work out of the box with the current firmware if your effective Counts Per Revolution is an integer. So make sure that counts_per_mm * screw_pitch_in_mm / reduction is an integer, where reduction is any additional reduction you have between the motor and the screw.


Thanks for the reply and also making this great project. The CNC machine is still in the early design phase (Deflection vibration analysis) before buying hardware. The stiffness would certainly not be a problem.
The goal is to build an open source high accuracy CNC mill capable of machining iron with ease.
For the Odrive to be able to work in such a machine for example for the Z axis it would be necessary to start the system with a load on the motor. I hope features like this will come in future firmware updates though :slight_smile:

And not the intention to hijack the topic here, I’m very interested in the optical linear encoder.


In the case where there is some play, but no vibration issues, eg. a laser, then I wonder if the most basic step is to modify the trajectory planner output so that the regular closed loop motion is conducted on the servo encoder and then the end point is cleaned up with a check against the linear encoder. At least the errors are not cumulative accross the entire job. Rough but potentially functional… Beyond this, is there a recognised method for combining the two encoders to generate a control signal such as sensor fusion using a Kalman filter?


It’s possible to use a 4-state kalman filter to track the position/velocity of both the moving mass and the rotor. You can even make a fancy model to try to infer all 4 of these states using only a single encoder, though I don’t know how well it would work, but it’s theoretically possible.