This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC sampling frequency or sampling period - Dave Wilson blog

Other Parts Discussed in Thread: CONTROLSUITE, MOTORWARE

Hello sir,

I have bought one BLDC whose specification is as following :--

Motor Condition : General
Rated Voltage : 60 V
Power Capability : 850W
Rated Speed : 3000 RPM
Number of poles : 8

I am following this blog by Mr Dave Wilson :--
https://e2e.ti.com/blogs_/b/motordrivecontrol/archive/2011/12/20/the-ten-commandments-of-digital-control-part-2

====================== Question 1 ===============================

Now i need to set the sampling time for my ADC :--
1> To run current loop to measure Iu & Iv for FOC. Please suggest what sampling frequency to use ?
2> To run position and velocity loops to measuring velocity & position. Please suggest what sampling frequency to use ?
3> For implementing FOC do motor angle have to calculated in sampling period(frequency) as of current loop ?

This blog by Mr Dave Wilson, states :--

It is common to find position and velocity loops running at sampling frequencies of around 2-5 KHz.  However, most motor control designs also include current loops.  The electrical poles are much higher than the mechanical poles, so sampling frequencies for the current loops are typically between 10-20 KHz.  For low inductance motors, this figure can be even higher!  As a general rule of thumb, you should set the sampling frequency for a particular control loop to be at least one order of magnitude higher than the unity gain frequency of that control loop’s open-loop response. 

So what exacty do you mean by electrical poles & mechanical poles ?
And how position velocity loop depends upon mechanical poles & current loop depends upon electrical poles.
What exaclty is the meaning of "For low inductance motors, this figure can be even higher!". What is the effect of motor Inductance on sampling rate ?

====================== Question 2 ===============================
Link also states that ADC samples should be sampled simultaneously at the middle of PWM.
As we know PWM is continously supplied from controller & at every current loop cycle duty is changed depending upon rotor position.
So my question is we should trigger the simultaneous measurement using ADC for Iu Iv current & Rotor position, once sample period starts ?
or these ADC measurement can go on continously at every center of PWM & when sampling period arrives we can take latest value & process motor control algorithm as per this ?

ISR_5_msec() //i.e sampling frequency of 2 KHZ
{
// start ADC measurement trigger & calculate rotor angle

}

Please suggest on this two questions from my side.

Regards,
Dinesh

  • I have not heared the terms mechanical poles & electrical poles. But yes this link use to state the relationship between electrical & mechanical angle of motor electronics.stackexchange.com/.../induction-motor-electrical-and-mechanical-angle.

    what exactly is mechanical or electrical poles ?
  • 1. The minimum would be 8x your max frequency. Max frequency = 3000 RPM * 8 poles / 120 = 200 Hz. 8 * 200 Hz = 1.6 KHz
    Adding in some buffer 4 KHz is a reasonable minimum and anything beyond 10-12 KHz doesn't provide any benefit (just more switching losses).
    2. This depends on the response that you require in your system and the resolution of the position sensors you are using. For most standard couple thousand line encoders outer loop frequencies of 1 KHz are usually ok. As you go into higher performance servo systems you may see outer loop frequencies of 10, 20, and now even 40 KHz. Of course you need the inner current loop(s) to run at least as fast if not twice as fast.
    3. Not necessarily but typically yes the angle is calculated for each current loop update. The angle is used by the IPARK module which feeds the SVPAM.

    in that blog the mechanical = velocity/position and electrical = current.

    the current loop is based on controlling the electrical flux position of the stator. The velocity/position loops are based on controlling the mechanical position of the rotor.

    In low inductance machines the short circuit current is extremely large so often you need to update the current regulation at even higher rates in an attempt to control the current better. Your machine is not low inductance based on the parameters you have shared.

    Q2
    If you are doing low-side current shunt measurements you should sample at timer = 0. This is when the high side PWMs are off and the low-side PWMs are in the center of their period. This allows for an average current at the farthest point from the switching edges.

    sampling both (or all 3 currents) simultaneously is nice, but not required for most motors. we just sample sequentially in InstaSPIN-FOC

    you don't need to create your own ISR. There are ISRs built into the hardware. The PWMs can trigger the ADC and the ADC conversions being done can then trigger the mainISR for the control loop.
  • Thanks Chris for your reply.

    >>1. The minimum would be 8x your max frequency. Max frequency = 3000 RPM * 8 poles / 120 = 200 Hz. 8 * 200 Hz = 1.6 KHz
    >>Adding in some buffer 4 KHz is a reasonable minimum and anything beyond 10-12 KHz doesn't provide any benefit (just more switching losses).

    So here you mean to say PWM frequency to be applied to this motor should be less than 10-12 KHz. Please correct me if i have got it wrong ?

    >>2. This depends on the response that you require in your system and the resolution of the position sensors you are using. For most standard couple thousand line encoders outer loop frequencies of 1 KHz are usually ok. As you go into higher performance servo systems you may see outer loop frequencies of 10, 20, and now even 40 KHz. Of course you need the inner current loop(s) to run at least as fast if not twice as fast.

    So here you mean to say that outer velocity loop & inner current loop should run at same frequency. Please correct me if i have got it wrong ?

    >>If you are doing low-side current shunt measurements you should sample at timer = 0. you don't need to create your own ISR. There are ISRs built into the hardware. The PWMs can trigger the ADC and the ADC conversions being done can then trigger the mainISR for the control loop.

    As per your comment this mainISR will trigger at the PWM switching frequency. Suppose my PWM switching frequency is 10 KHZ & i am running my velocity outer & current inner loop at same frequency of say 1KHZ
    SO mainISR will trigger at every time(as per 10 KHZ PWM switching frequency) of 1/10000 = 0.1 msec
    Also my velocity outer & current inner loop trigger time(as per 1 KHZ frequency) will be, 1/1000 = 1 msec
    So my C code will be as such :--

    //Global variable 
    unsigned int loop_counter = 0;
    
    void mainISR(void)
    {
    // loop counter increment every 0.1 msec
    loop_counter++;
    
    // check for 1 msec time expired
    if(loop_counter >= 10)
    {
    
    //run outer velocity loop software
    
    //run inner loop software
    
    // set SVM PWM registers value
    
    loop_counter = 0u;
    
    }
    
    }

    Please correct me if my code is wrong.

    Regards,
    Dinesh

  • 1. PWM max of 12 KHz is reasonable.
    2. No, your current loops typically run faster than your outer mechanical loops.
    3. I'm not going to review your code. I recommend you follow any of the hundred of control loop software examples we provide.
  • Thanks Chris, for your reply.

    >> I recommend you follow any of the hundred of control loop software examples we provide.
    Can you please suggest right link to these software examples which TI provides so that i can go through these examples ?

    Regards,
    Dinesh
  • controlSUITE

    is the application which holds all of the projects/docs/sw for C2000 EVMs. There are many for motor control.

    MotorWare

    is the application which holds all of the projects/docs/sw for InstaSPIN-FOC and -MOTION enabled C2000 EVMs.

  • Thanks, for sharing these useful details.


    Regards,
    Dinesh