Odrive PID update frequency?

I’m trying to find the PID update frequency of the odrive. How fast does the PID loop run?

It runs at 8kHz for all loops (position, velocity, current).

Is 8kHz chosen for a specific reason and not much faster eg 100-200kHz? The STM runs at 168Mhz (210 DMIPS) and you would think a PID loop is only the sum of 3 multiply accumulates.

Isn’t a 12bit encoder position = 4096 counts per revolution at 60,000 rpm = 1000 rps => 4Mhz update?

  1. The motor doesn’t respond that fast (mechanical bandwidth is low)
  2. Nobody’s encoder at this price point is rated to 60krpm or anything near it
  3. It’s true that we could run the PID that fast but you can only run the PID as fast as your switching frequency since your output can’t change fast enough, and 24kHz is about as high as we want to go on switching frequency - it’s not audible, but it also reduces switching losses. A 200kHz switching frequency would be extremely inefficient.

The PID is close to just 3 macs but the FOC itself is significantly harder to process (although it’s not SUPER heavy load).

1 Like
  • There’s no point in running the position loop faster than the velocity loop
  • There’s no point in running the velocity loop faster than the current loop
  • There’s no point in running the current loop faster than the half PWM frequency
  • You don’t want to run the PWM too fast or you will warm up the FETs and lose efficiency and current capacity, and will also cause excess EM noise
  • There’s no point in running the current loop faster than the current-sense bandwidth
  • The current loop (FOC) is relatively expensive to compute, and it’s nice to have spare CPU cycles for things like USB communications
1 Like

Although you are correct on a continuous-time control theory basis, you are missing something important in the discretized-time control practice: phase delay

If the current sensor analogue bandwidth happens to be 8kHz, and you run the current control loop at 8kHz, then it means that you can get up to 360 degrees of phase delay; it’s still 180 degrees of error at 4kHz and 90degrees at 2kHz, and still a whopping, and pretty bad 45 degrees at 1kHz. Any continuous-time control algorithm that has to endure 45 degrees of phase delay at its control bandwidth will tell you that the situation is quite bad.

Hence, it absolutely does make sense to run the discrete-time current control loop at higher than 8kHz.

Although an advanced audiophile will tell you that you can get a correct waveform representation in the discrete-time domain up to (but not equal) the Nyquist frequency, – and he will be correct – the matter gets much more complicated when you want to talk about IIR filters. And PID is inherently an IIR filter. It absolutely does make sense to run it at at least 5x the analogue bandwidth to get good phase performance.