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.

CCS/TMDSSOLARPEXPKIT: Why a1 in 2p2z is _IQ26(1.0)

Part Number: TMDSSOLARPEXPKIT

Tool/software: Code Composer Studio

Hello. I wonder , why to make 2p2z work as PID you made  CNTL_2P2Z_CoefStruct_Vpnl.a1   =_IQ26(1.0);   ??

Min and Max are in _IQ(24) , Feedback and Reference are _IQ24.  But a1 is _IQ26.  But _IQ26(1.0)=_IQ24(4.0)  and that already will not be PID controller?

Where is my delusion?

Michael.

  • Hello Michael,

    It's the way the 2P2Z controller has been coded.  Input & output terminals have IQ24 format, but IQ26 is used for the internal calculations so the coefficients have to be in this format.  If you look at the Pgain, Igain, & Dgain values, they're all in IQ26 format.  The relevant library document is attached - see p.18 for this controller.

    I hope this helps.

    Regards,

    Richard

    2100.DPLib.pdf

  • So, I need to set coefficients in strongly in this way:

    // Initialize the Controller Coefficients

    CNTL_2P2Z_CoefStruct1.b2 = _IQ26(0.05);

    CNTL_2P2Z_CoefStruct1.b1 = _IQ26(-0.20);

    CNTL_2P2Z_CoefStruct1.b0 = _IQ26(0.20);

    CNTL_2P2Z_CoefStruct1.a2 = _IQ26(0.0);

    CNTL_2P2Z_CoefStruct1.a1 = _IQ26(1.0);

    CNTL_2P2Z_CoefStruct1.max =_IQ24(0.7);

    CNTL_2P2Z_CoefStruct1.i_min =_IQ24(-0.9);

    CNTL_2P2Z_CoefStruct1.min =_IQ24(0.0);

    //Initialize the net Variables/nodes

    Ref=_IQ24(0.0);

    Fdbk=_IQ24(0.0)

    Out=_IQ24(0.0);

    ???

    __________________________________________________________________________

    And another question. I found great defference in  CNTL_2P2Z.asm:

    in finish part ( from version f2803x_v3.3 and older):

    scale u(n):Q24, saturate (max>u(n)>min0), and save history

    MINL ACC, *XAR3++ ; saturate to < max (Q24)

    MAXL ACC, *XAR3 ; saturate to > min (Q24)

    ; write controller result to output terminal (Q24)

    MOVL *XAR2, ACC ; output control effort to terminal net

    ; Convert the u(n) to Q30 format and store in the data buffer

    LSL     ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}

    MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC

    _____________________________________________________________________

    And new one ( from f2803x_v3.5 :

    ; scale u(n):Q24, saturate (max>u(n)>min0), and save history

    MINL ACC, *XAR3++ ; saturate to < max (Q24)

    MAXL ACC, *XAR3++                    ; saturate to the internal min >internal min (-1.0, Q24)

    MOVL    @XAR1, ACC ; save this value temporaily in XAR1

    ; Convert the internal u(n) to Q30 format and store in the data buffer

    LSL     ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}

    MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC

    MOVL    ACC,@XAR1 ; load the temporaily saved value in Q24 from XAR1 to ACC

    MAXL ACC, *XAR3 ; saturate to > output min (Q24)

    (THis part gives me bad value of out. It seems that  this *XA3 point to nothing.  

    ; write controller result to output terminal (Q24)

    MOVL *XAR2, ACC ; output control effort to terminal net

    What is the sense of this changing?

  • Choosing a Q point was a decision made to optimize cycle count and improve resolution on the coefficient variables, the module is indeed coded that way and does need Q26 for the items described by you, 

    If you notice the comments in the code, we maintain the data buffers as Q30 and then if coeff is in Q26 a simple multiply will give Q24 directly.. no additional shift required. 

    THe change you have pointed out was done in version 3.4, the enhancement was done so the module can work under no-load type of conditions for which the output may have to go to zero and if the internal variables are not allowed to go a little negative this never happened. 

    Make sure you have the correct structure and have initialized all the variables

    CNTL_2P2Z_CoefStruct1.b2 = _IQ26(CNTL_3p3z_B2_1); // B2
    CNTL_2P2Z_CoefStruct1.b1 = _IQ26(CNTL_3p3z_B1_1); // B1
    CNTL_2P2Z_CoefStruct1.b0 = _IQ26(CNTL_3p3z_B0_1); // B0
    CNTL_2P2Z_CoefStruct1.a2 = _IQ26(CNTL_3p3z_A2_1); // A2
    CNTL_2P2Z_CoefStruct1.a1 = _IQ26(CNTL_3p3z_A1_1); // A1
    CNTL_2P2Z_CoefStruct1.max = CNTL_3p3z_Max_1; //Clamp Hi
    CNTL_2P2Z_CoefStruct1.min = CNTL_3p3z_Min_1; //Clamp Min
    CNTL_2P2Z_CoefStruct1.i_min = CNTL_3p3z_IMin_1; //Clamp IMin

    with the last line a change to the initialization routine..