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:使用 ADC 进行电感器电流检测

Guru**** 2321860 points
Other Parts Discussed in Thread: C2000WARE
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1523972/tms320f28379d-inductor-current-sensing-using-adc

部件号:TMS320F28379D
主题:C2000WARE 中讨论的其他器件

工具/软件:

您好团队:  

我们正在使用电流控制技术进行升压转换器的闭环控制。
目前、我们检测到三个数量
1. VIN
2.输出电压
3.

转换器的开关频率为65kHz、因此电感器电流波形也将具有65kHz 的频率。  
为了检测该信号、我们使用了 ePWM 来触发转换开始和转换结束。 下面是我用于检测电感器电流的所附代码。 我已将65kHz× 10作为 ADC 在每个周期中对电感器电流波形进行采样的采样频率。

但问题是当我在 DAC 上强制施加检测到的电感器电流信号并比较波形时、形状和斜率是不同的。  请查看代码或提供任何资源来解决问题

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);
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    我检查了您的配置、不知道为什么继续启用和禁用 ADC 触发器。 要检查 ADC SOC 的 ePWM 触发器的正确配置、请参阅 C2000Ware 示例 ADC_ex2_soc_pwm:  c:\ti\c2000\C2000Ware_5_04_00_00\driverlib\f2837xd\examples\cpu1\adc

     如果您还有其他问题、敬请告知。