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.

C2000-DIGITAL-CONTROL-LIBRARY: Use of pre-computation digital compensators

Part Number: C2000-DIGITAL-CONTROL-LIBRARY
Other Parts Discussed in Thread: TIDM-02000

Hi,

What is the purpose of subtracting a pre-computation form of a digital compensator from the main digital compensator, such as in the examples given in DCL User's Guide.pdf (ti.com)

The difference of the controllers is fed back to the main C file (CPU1), and I assume this would then be the result which modulates the duty cycle and/or frequency of a PWM signal in the digital compare modules. But if we are passing back to the main function the difference between two filters, is this representative of the error of the input signal, or the error between two different compensators which may be different depending on their constants?

I may need to brush up on my digital control - does having this precomputation features improve control speed/accuracy? 

Or is it purely used as a way to examine the difference between two different, separate controllers - of which the user should choose the one which works best in their application - or is it best practice to always included a normal and pre-computation digital compensator for best results?

Thanks!
Joel

  • Hi Joel,

    The pre-computation form of control law split the control law calculation into two pieces. The pre-computation part of the implementation can be done before taking the sample of the current sample and be calculated after the controller finish updating the output control variable of the previous cycle. There will only be a small portion of the calculation that requires the current sample result needs to be calculated after the current sample being captured. This will reduce the calculation time and enable "immediate update" control scheme for sample-to-output delay reduction.

    Han

  • Hi Han, 

    Thanks, this makes sense. In some examples, there is even three forms of the controller that are ran, one after a clamp function, see below:


    /* control ISR: triggered by CPU timer 0 */
    interrupt void control_Isr(void)
    {
    // clear timer flag & acknowledge interrupt
    CpuTimer0Regs.TCR.bit.TIF = 1;
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    // read data & run controllers
    if (eBuf.dptr < eBuf.lptr)
    {
    // read input data
    ek = DCL_readLog(&eBuf);

    // run full controller
    u1k = DCL_runDF22_C1(&controller1, ek);

    // run pre-computed controller
    u2k = DCL_runDF22_C2(&controller2, ek);
    v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
    if (0U == v)
    {
    DCL_runDF22_C3(&controller2, ek, u2k);
    }

    // compute difference
    dk = u1k - u2k;

    // store results
    DCL_writeLog(&u1Buf, u1k);
    DCL_writeLog(&u2Buf, u2k);
    DCL_writeLog(&dBuf, dk);

    Is there a reason why the third controller is ran after the clamp?

    In calculations of my duty cycle or frequency for controlling my PWM modules, should I utilize the u1k, u2k, or the dk variable? 

    One would assume the dk variable, which holds the difference between the controller results, would be the control result?

  • The DCL_runDF22_C1 has all controller calculation in one function and the DCL_runDF22_C2 and DCL_runDF22_C3 works together as pre-computation format. This example contains two controllers.

    U1k and u2k are the control signal output of the two controllers respectively, and dk is the difference.

  • Hi Han,

    Okay, thank you for your input. But the mystery remains, why do we hold all this information in such large arrays? It is my understanding that to compute the next controller output, we only need information on the previous couple of samples, not the last thousand or so like is in the code.

    Which element in the controller output array, should we send back to the CPU, to actually modulate the duty cycle? And would we use U1k, U2k, or dk to modulate the duty cycle?

    If we do not use dk to calculate the duty cycle, what is the purpose of calculating the difference? Is it just for observational purposes? If so, can one just not use it?

    Regards,
    joel

  • This example is only to show how the DCL library function works. You should not need to record the output values or calculate dk in real control application. You only need to pick on from the two form of implementation.

  • Hi Han,

    Thanks for the reply. So if we do not record the output values, how does the DCL library function have knowledge of the previous samples?

    I thought the point of the pre-computation was to IMPROVE the performance of the standard control laws - but now you mention that we do not use them both. So, what is the point of using pre-computation method on it's own? Or does the "pre-computation" method include a standard implementation alongside some additional pre-computation parts that are included in it by default?

    In the examples we calculate the standard part and then a pre-computed part and sum them - there is no mention that the pre-computed version can be used on it's own.

    I am still confused about how to use the functions then in a real application. Mostly to do with the arrays or lack thereof - without arrays, there is no knowledge of past controller results, and therefore surely the control law cannot be applied!

    Please do get back in touch to clear this up.

    Joel

  • Joel,

    The calculation result of full controller and pre-computed controller should be be the same. The code below shows you how it should be used in real system.

    // run pre-computed controller
    u2k = DCL_runDF22_C2(&controller2, ek);
    v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
    if (0U == v)
    {
    DCL_runDF22_C3(&controller2, ek, u2k);
    }

    For a system example, you can look at TIDM-02000. The software is distributed in C2000 Digital Power SDK. Thanks.

    Han

  • Hi Han, 

    It seems even within the TIDM-02000 example it is "MUCH" more complicated than what you have proposed there. Is there some kind of pseudocode that I can follow? For example, you mentioned I do not need a buffer for past results, however in the example:

    PSFB_vBusSensedBuff[PSFB_vBusSensedBuffIndex++] = PSFB_vLVBus_sensed_pu;
    if(PSFB_vBusSensedBuffIndex >= 10)
    {
    PSFB_vBusSensedBuffIndex = 0;
    }

    PSFB_vBus_sensedFiltered_pu = 0;

    for(k = 0; k < 10; k++)
    {
    PSFB_vBus_sensedFiltered_pu += PSFB_vBusSensedBuff[k];
    }

    PSFB_vBus_sensedFiltered_pu = PSFB_vBus_sensedFiltered_pu * 0.1;

    This seems to be storing 10 results in a buffer. Why?

    It doesn't even look like these buffered results are used in the calculations of the control variables - so my questions remain. What is the purpose of the buffers? If we do not need buffers for the actual computation of the control laws, how exactly does the compensator know about previous control inputs for the delay line? Since the digital implementation requires knowledge of the previous N samples to calculate the next controller output, where does it store this information for the computations?

    trying to get my head around  it! Thanks for your replies thus far!

    Joel

  • A few things from the example TIDM I do not understand:

    PSFB_icommand_Set_pu seems to be the control effort, which can be computed in either the CPU or the CLA. However, the CLA does not define this variable in it's code, and the CPU does not define it as an external variable nor does it define any place in the RAM for communications between CLA and CPU to allow it to be used as a variable in both cores... am I missing something?

    The current set-point calculated from the control effort, is used to set the control ramp value in the following code:

    if(PSFB_icommand_Set_pu < 0)
    {
    PSFB_irampmax_Set = 0;
    }
    else
    {
    PSFB_irampmax_Set = PSFB_icommand_Set_pu * (PSFB_IRAMPMAX_SET_RATIO);
    }
    CMPSS_setMaxRampValue(PSFB_PCMC_OCP_CMPSS_BASE, (int16_t)PSFB_irampmax_Set);

    How would one do something similar, with the direct register access method, in the ePWM module itself - assuming I am doing average current mode and do not want to use the comparators as seen in peak current mode control?

    Would I just use this scaled 0-1 value and multiply it by the maximum CMPA value, assuming the maximum CMPA value can be programmed?

  • In this reference design, the control variable is not PWM duty cycle. Instead, the control variable for voltage loop of the design is the CMPSS set voltage for peak current mode control current loop. Hence, there is no scaling to PWM in this design.

    Han