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.

TMS320F28379D: Inductor current sensing using ADC

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hello Team, 

We are working on closed-loop control of the boost converter using a current control technique.
Currently, we are sensing three quantities
1. Vin
2. Vout
3. Iind

The converter's switching frequency is 65 kHz, so the inductor current waveform will also have a frequency of 65 kHz. 
So to sense that signal, we have used an EPWM to trigger the start of the conversion and the end of the conversion. Below is the attached code I have used to sense the inductor current. I have taken 65 kHz × 10 as the sampling frequency of the ADC for sampling the inductor current waveform in every cycle.

But the problem is when I am forcing my sensed inductor current signal on a DAC and compare the waveforms, the shape and slopes are different. Please review the code or provide any resources to fix the issue
.

void epwm2(){
    // Start ePWM2, enabling SOCA and putting the counter in up-count mode
    EPWM_enableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
    EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP);
 
    while(bufferFull == 0)
    {
    }
    bufferFull = 0;
 
    // Stop ePWM2, disabling SOCA and freezing the counter
    EPWM_disableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
    EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
 
 
}
 
 
void initADC(void)
{
    ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
    ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
    ADC_enableConverter(ADCA_BASE);
    DELAY_US(10000);
}
void initEPWM(void)
{
    // Disable SOCA
    EPWM_disableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
 
    // Configure the SOC to occur on the first up-count event
    EPWM_setADCTriggerSource(EPWM2_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
    EPWM_setADCTriggerEventPrescale(EPWM2_BASE, EPWM_SOC_A, 1);
 

    EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_A,76.92);
    EPWM_setTimeBasePeriod(EPWM2_BASE,153.84);
 
    // Set the local ePWM module clock divider to /1
    EPWM_setClockPrescaler(EPWM2_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);
 
    // Freeze the counter
    EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
}
 
 
void initADCSOC(void)
{
    // Configure SOC0 to SOC3 of ADCA to convert pins A0 to A3.
    // The EPWM2SOCA signal will be the trigger.
 
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN2, 15);
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN3, 15);
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM2_SOCA, ADC_CH_ADCIN4, 15);
    ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER4);
    ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}
__interrupt void adcA1ISR(void)
{
    adcResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2);
    adcResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER3);
    adcResult2 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER4);
 
  if (index >= RESULTS_BUFFER_SIZE)
    {
        index = 0;
        bufferFull = 1;
    }
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
    if (true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1))
        {
            ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
            ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
        }
 
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}

  • Hello,

    I checked your configuration, and I am not sure why you keep enabling and disabling ADC trigger. To check correct configuration for ePWM trigger for ADC SOC, please refer to C2000Ware example adc_ex2_soc_pwm:  C:\ti\c2000\C2000Ware_5_04_00_00\driverlib\f2837xd\examples\cpu1\adc

     Please let me know if you have more questions.