External frequency reference

Is it possible to set up an odrive to lock the rotation of a motor (especially a motor running in sensorless mode) to some sort of external frequency reference - say, a square wave that corresponds to 1 pulse per revolution? Think along the lines of an optical chopper controller: https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=287 . I’m presuming this may require some firmware modifications, so does anyone have any idea how feasible something like this might be on an odrive, and what sort of accuracy might be achievable?

I think this should be quite doable. You can borrow some code we have for tracking the quadrature encoder pulses: make a PLL that can interpolate the velocity and phase of the incoming reference signal. This can be scaled by some factor (to set the speed ratio), and then feed the controllers position and velocity setpoint.

If you can run the motor with an encoder, or don’t need accurate phase tracking (just frequency tracking), you are good to go with that. If you need phase tracking on sensorless, we need to also add phase control to the controller. This should be quite straightforward, but just want to mention that it has to be added.

In terms of accuracy, there are two components: how accurate can you track the incoming pulses, and how accurate can you drive the motor. The pulse tracking should only be limited by the jitter of the ODrive’s main crystal oscillator: This should be less than 10ppm. The output tracking when using an encoder should be about 2-4 encoder counts if everything is tuned well, and there are low disturbances. When using sensorless I think a few electrical degrees is reasonable if running at a reasonable speed (it is less accurate when running slow, and there is a minimum speed beyond which it won’t work at all).

We’re going to be driving what amounts to a modified hard drive, so adding an encoder is not particularly straightforward. It may be possible to set up some sort of indexing setup with a mark on the center hub or disk coupled with a reflective optical sensor, but ideally sensorless would be the way to go, if it is likely to provide enough accuracy. This will be run at higher speeds, we’re hoping to be able to run at 7200 RPM. It would be nice to be able to slow it down significantly to maybe 100-200 RPM, but obviously this will depend on what the sensorless feedback can handle. And yes, we need precise phase tracking, frequency alone is not sufficient. I’m almost thinking that maybe running open loop is possible, at least once the motor is running at close to the right speed.

I pulled down a copy of the repo and managed to get the firmware to compile on my machine. Is there any decent documentation on the firmware internals? I found the sensorless estimator code, but it’s unclear how that’s integrated into the rest of the firmware. Maybe I just need to look in more of the source files.

The controller and the feedback are tied together in the Axis class, check here.