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.

dsp28035中2p2z(或者3p3z)的使用问题



你好,我想问一下,2p2z、3p3z这种应该如何使用?我最近写的一个程序,需要使用4个pid,所以我在原有的2p2z(只能定义两个,定义到CNTL_2P2Z_Ref3开始报错)基础上,参照2p2z的使用方法,使用了3p3z,但是发现3p3z控制器并没有工作,只是按照最小占空比输出。

// CONTROL_2P2Z
extern volatile long *CNTL_2P2Z_Ref1; // instance #1
extern volatile long *CNTL_2P2Z_Out1; // instance #1
extern volatile long *CNTL_2P2Z_Fdbk1; // instance #1
extern volatile long *CNTL_2P2Z_Coef1; // instance #1
extern volatile long CNTL_2P2Z_DBUFF1[5];
// CONTROL_2P2Z
extern volatile long *CNTL_2P2Z_Ref2; // instance #2
extern volatile long *CNTL_2P2Z_Out2; // instance #2
extern volatile long *CNTL_2P2Z_Fdbk2; // instance #2
extern volatile long *CNTL_2P2Z_Coef2; // instance #2
extern volatile long CNTL_2P2Z_DBUFF2[5];

// CONTROL_3P3Z1, Output Current Regulation Loop
extern volatile long *CNTL_3P3Z_Ref1; // instance #1
extern volatile long *CNTL_3P3Z_Out1; // instance #1
extern volatile long *CNTL_3P3Z_Fdbk1; // instance #1
extern volatile long *CNTL_3P3Z_Coef1; // instance #1
extern volatile long CNTL_3P3Z_DBUFF1[5];
// CONTROL_3P3Z1, Output Voltage Regulation Loop
extern volatile long *CNTL_3P3Z_Ref2; // instance #2
extern volatile long *CNTL_3P3Z_Out2; // instance #2
extern volatile long *CNTL_3P3Z_Fdbk2; // instance #2
extern volatile long *CNTL_3P3Z_Coef2; // instance #2
extern volatile long CNTL_3P3Z_DBUFF2[5];

  • Solar_DC_DC-DPL-ISR.asm中:
    _DPL_Init:
    ZAPA
    MOVL XAR0, #ZeroNet
    MOVL *XAR0, ACC

    ; Initialize all the DP library macro used here
    ;---------------------------------------------------------
    ; ADCDRV_1ch_INIT 0 ; IL2
    ; ADCDRV_1ch_INIT 1 ; IL
    ; ADCDRV_1ch_INIT 2 ; Vb
    ; ADCDRV_1ch_INIT 3 ; Vp
    ; ADCDRV_1ch_INIT 4 ; Vp2

    MATH_EMAVG_INIT 1
    MATH_EMAVG_INIT 2
    MATH_EMAVG_INIT 3

    CNTL_2P2Z_INIT 1
    CNTL_2P2Z_INIT 2

    CNTL_3P3Z_INIT 1
    CNTL_3P3Z_INIT 2

    PWMDRV_DualUpDwnCnt_INIT 2 ; PWM1A

    ;PWMDRV_LLC_ComplPairDB_INIT 3;
    LRETR

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

    ; Digital Power library - Interrupt Service Routine

    .sect "ramfuncs"
    ; label to DP ISR Run function
    .def _DPL_ISR

    _DPL_ISR:
    ; full context save - push any unprotected registers onto stack
    PUSH AR1H:AR0H
    PUSH XAR2
    PUSH XAR3
    PUSH XAR4
    PUSH XAR5
    PUSH XAR6
    PUSH XAR7
    PUSH XT
    SPM 0 ; set C28 mode
    CLRC AMODE
    CLRC PAGE0,OVM
    ; CLRC INTM ; clear interrupt mask - comment if ISR non-nestable
    ;-----------------------------------------------------------------------------------------
    ; call DP library modules
    ;---------------------------------------------------------
    ; ADCDRV_1ch 0 ; IL2
    ; ADCDRV_1ch 1 ; IL
    ; ADCDRV_1ch 2 ; Vb
    ; ADCDRV_1ch 3 ; Vp
    ; ADCDRV_1ch 4 ; Vp2
    ;----------------------------------------------------
    ;Subtract IL CS amplifier offset and calculate IL
    ********
    采样标定部分程序
    ********

    ;---------------------------------------------------------
    ; Run the control laws
    ;---------------------------------------------------------
    MATH_EMAVG 1
    MATH_EMAVG 2
    MATH_EMAVG 3

    CNTL_2P2Z 1
    CNTL_2P2Z 2 ;Volt loop controller
    CNTL_3P3Z 1
    CNTL_3P3Z 2 ;Volt loop controller

    PWMDRV_DualUpDwnCnt 2 ; PWM1A
    ;PWMDRV_1ch_UpDwnCnt 2 ; PWM2A
    ;PWMDRV_LLC_ComplPairDB 3 ;
    ;-----------------------------------------------------------------------------------------
    ; Interrupt management before exit

    MOVW DP,#_EPwm2Regs.ETCLR
    MOV @_EPwm2Regs.ETCLR,#0x01 ; Clear EPWM2 Int flag

    MOVW DP,#_PieCtrlRegs.PIEACK ; Acknowledge PIE interrupt Group 3
    MOV @_PieCtrlRegs.PIEACK, #0x4

    ;-----------------------------------------------------------------------------------------
    ; full context restore
    ; SETC INTM ; set INTM to protect context restore
    POP XT
    POP XAR7
    POP XAR6
    POP XAR5
    POP XAR4
    POP XAR3
    POP XAR2
    POP AR1H:AR0H
    IRET ; return from interrupt
    .end

    ; end of file