2 Replies Latest reply on Feb 17, 2018 7:40 AM by user_342122993

    Discrete math question - derivatives, integrals, and real time motor control applications


      Greetings all!  This is a general question that involves engineering judgement (which I don't have a lot of in the field of motor controls).


      1. In discrete math for a real time application, I might code a time derivative as:

      y[n] = (x[n] - x[n - 1]) / T     Where x[n] is the current ADC sample, x[n-1] is the previous ADC sample, T is the sampling period, and y[n] is the "derivative"

      Similar equation for an integral:

      y[n] = y[n-1] + T*x[n]


      2. There are more "accurate" equations than the ones above, for instance:

      More accurate derivative:

      y[n] =    (4 / 3) * (x[n+1] - x[n-1]) / (2*T)   -   (1 / 3) * (x[n+2] - x[n-2]) / (4*T)



      Let's say I want to use the "more accurate" derivative equation in a 100kHz PWM control loop application (for instance, a dc-dc converter, or a motor control application).

      The "more accurate" derivative uses an x[n+2] term, which means that whenever I use the equation, I'm always 2 samples "behind".  In the world of 100kHz real time applications, is this 2 sample delay a "big deal", or can I get away with it?