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/BOOSTXL-DRV8301: When should I read currents if I use Direct torque control approach?

Part Number: BOOSTXL-DRV8301
Other Parts Discussed in Thread: MOTORWARE, , CONTROLSUITE

Tool/software: Code Composer Studio

Hello,

I am trying to implement direct torque control on a PMSM. I have used ADC interrupt, and an EPwm triggers EOC interrupt. In my ISR, I read the current and voltage values, as well as encoder values for speed and position calculation and implement the DTC approach. My Epwm configuration for interrupt and ADC configurations are as follows:

void ConfigureEPWM(void)
{
    EALLOW;

    EPwm4Regs.TBCTL.bit.CTRMODE = 3;            // Freeze counter
    EPwm4Regs.TBCTL.bit.HSPCLKDIV = 0;          // TBCLK pre-scaler = /1
    EPwm4Regs.TBCTL.bit.CLKDIV = 0;          // TBCLK pre-scaler = /1
    EPwm4Regs.TBPRD = 2500;                   // Set period to 2000 counts (50kHz)
    EPwm4Regs.TBCTR = 0x0;
    EPwm4Regs.TBCTL.all=0x1C;
    EPwm4Regs.ETSEL.bit.SOCAEN  = 0;            // Disable SOC on A group
    EPwm4Regs.ETSEL.bit.SOCASEL =1;           
    EPwm4Regs.ETSEL.bit.SOCAEN = 1;             // Enable SOCA
    EPwm4Regs.ETPS.bit.SOCAPRD = 1;             // Generate pulse on 1st event

    EDIS;
}

void SetupADCEpwm(void)
{
    EALLOW;


    AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2;
    AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2;
    AdccRegs.ADCSOC0CTL.bit.CHSEL = 2;
    AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3;
    AdcbRegs.ADCSOC1CTL.bit.CHSEL = 3;
    AdccRegs.ADCSOC1CTL.bit.CHSEL = 3;
    AdcaRegs.ADCSOC2CTL.bit.CHSEL = 0xE;



    AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14;         
    AdcbRegs.ADCSOC0CTL.bit.ACQPS = 14;         
    AdccRegs.ADCSOC0CTL.bit.ACQPS = 14;        
    AdcaRegs.ADCSOC1CTL.bit.ACQPS = 14;        
    AdcbRegs.ADCSOC1CTL.bit.ACQPS = 14;         
    AdccRegs.ADCSOC1CTL.bit.ACQPS = 14;         
    AdcaRegs.ADCSOC2CTL.bit.ACQPS = 14;         

    AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C
    AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C
    AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C
    AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C
    AdcbRegs.ADCSOC1CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C
    AdccRegs.ADCSOC1CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C
    AdcaRegs.ADCSOC2CTL.bit.TRIGSEL = 0xB;        // Trigger on ePWM4 SOCA/C


    AdcaRegs.ADCCTL1.bit.INTPULSEPOS  = 1;  // 1 = INT at the end of conversion
    AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 2;      // End of SOC2 will set INT1 flag
    AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;        // Enable INT1 flag
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;      // Make sure INT1 flag is cleared


    EDIS;
}

So the ISR appears each 25uS and the ADC values are read and the algorithm is implemented and if the ISR finishes before 25uS, there is an infinite loop in "main". I am able to run the motor but it is not smooth, I have checked the algorithm and it is fine. The question is that is there any specific time that I should read the currents? because I think maybe the current readings are not correct.

Thank you for your help.

Regards,

Ata