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.

How is the current closed loop realized, from ad sampling to PID control, to the calculation and setting of the duty cycle?

Hi,

HV_SOLAR_DC_DC_Rev1,in the DPL_ISR function in the file Solar_DC_DC-DPL-ISR.asm,the following code:

;---------------------------------------------------------

.if(INCR_BUILD = 2)

ADCDRV_1ch 1 ; Ipfc

ADCDRV_1ch 2 ; Vpfc

ADCDRV_1ch 3 ; VL_fb

ADCDRV_1ch 4 ; VN_fb

 

CNTL_2P2Z 1

PWMDRV_1ch_UpDwnCnt 1 ; PWM1A

PWMDRV_1ch_UpDwnCnt 2 ; PWM2A

;PWMDRV_LLC_ComplPairDB 3 ;

MATH_EMAVG 1 ;

    

MATH_EMAVG 2

PWMDRV_1ch_UpDwnCnt 4 ; PWM4A

.endif

;----------------------------------------------

 

In build2 mode,first read the AD value of voltage and current,Next, control functions such as PID and data filtering are implemented by calling the CNTL_2P2Z function.The output of CNTL_2P2Z is stored in CNTL_2P2Z_Out(Q24) and CNTL_2P2Z_DBUFF(Q30).

_PWMDRV_1ch_UpDwnCnt_Duty and _PWMDRV_1ch_UpDwnCnt_Duty are input variables to the function PWMDRV_1ch_UpDwnCnt.

No relationship was found between the functions PWMDRV_1ch_UpDwnCnt and CNTL_2P2Z.

I don't know how the function PWMDRV_1ch_UpDwnCnt passes the output of CNTL_2P2Z is used to set the duty cycle.How is the current closed loop realized, from ad sampling to PID control, to the calculation and setting of the duty cycle?

Regards,

Ren

  • See the initialization code in BLPFC Main.c. There we connect these functions. Here is a snippets of initialization code.

    //----------------------------------------------------------------------
    #if (INCR_BUILD == 2) // Closed Current Loop DC-DC Boost, Open Volt Loop
    //----------------------------------------------------------------------
    // Lib Module connection to "nets"
    //----------------------------------------
    // Connect the PWM Driver input to an input variable, Open Loop System
    ADCDRV_1ch_Rlt1 = &IL_raw;//Raw ADC data which seems to have some non-zero offset
    ADCDRV_1ch_Rlt2 = &Vb_fb;
    ADCDRV_1ch_Rlt3 = &Vp_fb;
    ADCDRV_1ch_Rlt4 = &Ics;

    // Math_avg block connections - Instance 1
    MATH_EMAVG_In1=&IL_raw;//*****Change to this for testing with rev 2 board
    //MATH_EMAVG_In1=&IL;//Input instantaneous IL after offset correction (correction done is ISR)
    MATH_EMAVG_Out1=&IL_avg;//Output average IL after offset correction
    MATH_EMAVG_Multiplier1=_IQ30(0.030);

    // Math_avg block connections - Instance 2
    MATH_EMAVG_In2=&Vb_fb;
    MATH_EMAVG_Out2=&Vb_fb_Avg;
    MATH_EMAVG_Multiplier2=_IQ30(0.00025);

    //connect the 2P2Z connections, for the inner Current Loop, Loop1
    CNTL_2P2Z_Ref1 = &Boost_IL_cmd;
    CNTL_2P2Z_Out1 = &DutyA;
    CNTL_2P2Z_Fdbk1= &IL_raw;//*****Change to this for testing with rev 2 board
    //CNTL_2P2Z_Fdbk1= &IL;//Feedback instantaneous IL after offset correction (done is ISR)
    CNTL_2P2Z_Coef1 = &CNTL_2P2Z_CoefStruct1.b2;

    PWMDRV_1ch_UpDwnCnt_Duty1 = &DutyA;
    PWMDRV_1ch_UpDwnCnt_Duty2 = &DutyA;

    Shamim

  • Very grateful for your help!Passing values through pointer variables!