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.

TMS320F28335:PI conversion delay is too long(60ms)

Other Parts Discussed in Thread: TMS320F28335

部件號: TMS320F28335

Hello, TI engineer:

Why is the switching delay of the BOOST circuit too long (60ms) during PI control? Is it the interrupt interval or the adc sampling frequency is not set? Please see the boost output voltage (red circle) I circled in the diagram.

ADCsetup.c (code)

The yellow line is the input voltage.

The blue line is the output voltage.

The pink wire is the input current.

thank you very much!

  • Which TI example code are you using? Or your own code? If you are using own code, please share information to help us understand your question. For example, how do you call the PI code? The control and program execution flow? 

  • The code I used was rewritten from the data on the Internet.

    Call pi code: write the pi code in the void Vout_PI(void) subroutine, call it in the __interrupt void epwm1_isr(void) subroutine.

    The configuration parameters of main() and void InitEPwm1Example() are roughly the same as reference articles on the Internet

    I suspect it’s the interruption part

  • You might check if the PWM frequency is right as your setting. 

    And are there any other interrupt enabled in your project?

    Please post your codes in the thread directly. We can't download the compressed files from this forum for reviewing the code.

  • Hello, I confirmed on the oscilloscope that the pwm frequency is set to 50KHz, which is correct. I checked the interrupt setting, but I can’t find the wrong setting. The following is my code


    void InitEPwm1Example()// 初始化ePWM1


    {

    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // 計數模式設置爲向上計數
    EPwm1Regs.TBPRD = SP; // 頻率
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // 禁止計數計時器裝載相位寄存器
    EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // 相位設置爲0
    EPwm1Regs.TBCTR = 0x0000; // 計數器清零
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2; // TBCLK = SYSCLKOUT / (HSPCLKDIV * CLKDIV);

    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV2; //時基時鐘分頻 2倍分頻
    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;

    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; //CMPA使用影子寄存器
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; //CMPB使用影子寄存器
    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; //當產生CTR = 0時間時從影子寄存器加載CMPA的值到活動寄存器
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; //當產生CTR = 0時間時從影子寄存器加載CMPB的值到活動寄存器

    // Set Compare values
    EPwm1Regs.CMPA.half.CMPA =du; // 設定整個週期長度
    EPwm1Regs.CMPB =0 ; // 設置CMPB的值

    EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // 計數器0時ePWMA輸出1
    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // 計數器上升至CMPA時ePWMA輸出0

    EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET; // 計數器0時ePWMB輸出1
    EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR; // 計數器上升至CMPB時,ePWMB輸出0

    // 中斷我們將更改比較值的位置
    EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;; // (事件觸發選擇暫存器)-(ePWM中斷選擇條件)- (1:當TBCTR=0時)
    EPwm1Regs.ETSEL.bit.INTEN = 1; // (事件觸發選擇暫存器)-(允許ePWM中斷產生位)- (1:允許中斷)
    EPwm1Regs.ETPS.bit.INTPRD = 3; // (事件觸發分頻暫存器)-(中斷產生條件)- (3:在第三個事件時,產生SOC訊號,SOCBCNT=11)

    EPwm1Regs.ETSEL.bit.SOCAEN = 1; // (事件觸發選擇暫存器)-(允許ePWMxSOCA訊號產生位)- (1:允許ePWMxSOCA訊號產生)
    EPwm1Regs.ETSEL.bit.SOCASEL = 1; // (事件觸發選擇暫存器)-(PWMxSOCA訊號產生條件) - (1:當 TBCTR = 0時)
    EPwm1Regs.ETPS.bit.SOCAPRD = 1; // (事件觸發分頻暫存器)-(ePWMxSOCA訊號產生條件)-(1:在第一個事件時,產生SOC訊號:SOCACNT=01)
    }

    _

  • I added two lines of GPIO flip program at the beginning and end of the main program main.

    GpioDataRegs.GPATOGGLE.bit.GPIO2 = 0;
    GpioDataRegs.GPATOGLE.bit.GPIO2 = 1;



    Measure the pin of .GPIO2 on the oscilloscope and get this picture. Can I confirm that the running time of my program is correct?

  • I used example is Example_2823xAdcToDMA.

  • What data type are these variables for the PI functions? Do you enable the FPU of F28335 within CCS for floating point functions? And did you mean that you used the GPIO to test the frequency for epwm1_isr()? Is the correct as your settings?

  • 1.Variables of PI functions are floating point numbers.

    2.I checked the FPU function and it was already turned on, as shown in the attached picture.

    3.It is not the measurement frequency. The method I used to query the running time of the measurement program in TI E2E seems to be like this.

  •  Chen,

    Yanming asked me to look at this from the ADC perspective; let me summarize the expected sample time from your earlier code and we can see if this is what you want or it is causing the long processing times.

    The HSPCLK is set at 25MHz(assuming you are running the main CPU at 150MHz).  You have the CLKPS = 2(would be div 4) and the  CPS bit is set(another div 2).

    At this point the ADC Clock would be 25MHz/(4*2) = 3.125MHz(320ns)

    The ACQPS(acquisition window) is set to 15, which means 16 ADC Clocks for each sample = 320ns *16 = 5.12us.

    The total conversion time would be 5.12us + 4*ADCCLK = 6.4us from the trigger of the 1st conversion to its result coming available in the ADC Result register.

    I also see the the MAXCONV = 1, which would make the ADC take 2 samples when each trigger comes in.  The next sample would come ready slightly faster, 5.76us after the 1st. 

    So the total time from the SOC trigger to the ADCINT would be ~12.16us

    Can you comment if this aligns to the time you are seeing between PWM updates?  We can reduce this significantly by changing the clock dividers(this design supports up to 25MHz ADC Clock) or reducing the ACQPS.  This would be limited by the external circuit that feeds the ADC, and how accurately it can settle the sampling cap.

    Let me know if you have further questions.

    Best,

    Matthew

  • Hello Matthew

    Thank you for your answer, so would you suggest me to change the adc sampling frequency part and try again?

    I changed it to the frequency shown in the photo, which is faster in terms of settings, right? But I get the same delay result (20ms)
    The settings are as follows

    AdcRegs.ADCTRL1.bit.CPS=1;

    AdcRegs.ADCTRL3.bit.ADCCLKPS = 0;  

    AdcRegs.ADCTRL1.bit.ACQ_PS = 0;  

    Finally, I measured the interval between the pwm cycle and the cycle to be 20us, which seems to be inconsistent with 12.16us

    Do you have any better suggestions for me? What I want to improve is the boost output voltage, which can finally reach the voltage I want when the load changes, but there is a 20ms delay in the middle of the pi control time. Hope it can be shortened

  • I solved the problem

    (1) EPwm1Regs.ETPS.bit.INTPRD = 3; 3 is changed to 1, 60ms can be changed to 20ms, I think it is because of the triple time
    (2) The inductance of my boost circuit design is too small, I will increase the inductance to solve this problem

    Thanks for Matthew and Yanming!