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.

TMS320F28065: ADC measurement & ISR timings

Part Number: TMS320F28065


I'm facing issues in full-wave converters, where the ADC initialization file has been attached. The ADC ISR is triggered at first instant from ePWM used for switching at 20 kHz. The value which I have measured by averaging as shown below doesn't show linear variation with multimeter for 0 to 100 % output. 

ADC ISR:

//========================================

volatile Uint16 read_adc ;

Uint32 buf_read_adc  = 0 ;

Uint16 count_avg=0;

float dc_avg =0;

//========================================

read_adc = AdcResult.ADCRESULT8;

//========================================

buf_read_adc  += read_adc ;

count_avg++;

if(count_avg >  100)
{

dc_avg = ((float)buf_read_adc  ) / (count_avg* conversion_factor); 

buf_read_adc  = 0;

count_avg = 0;

}

//========================================

Please can I get expert advice on how to improve the measurement techniques of signal switched at high frequency ripple and having 3 phase (50 Hz) rectified ripple.

I using ADC ISR at the same rate as switching i.e. ePWM. Should ADC ISR have higher frequency?

Please suggest me improvements and implementation techniques in ISR timings/ ADC initializations/ ADC measurement improvements or software filter.

I also read floating values at ADC pins even if the ADC isn't having any voltage at its pins.

    AdcRegs.ADCCTL1.all = 0x00E4;       
    AdcRegs.ADCCTL2.all = 0x0001;     
    DELAY_US(1000);                      
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 0;     
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2 = 0;     
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4= 0;     
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN6= 0;     
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN8 = 0;    
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN10 = 0;    
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN12 = 0;    
    AdcRegs.ADCSAMPLEMODE.bit.SIMULEN14 = 0;     

    AdcRegs.ADCSOC0CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC1CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC2CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC3CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC4CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC5CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC6CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC7CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC8CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC9CTL.bit.TRIGSEL      = 5;        
    AdcRegs.ADCSOC10CTL.bit.TRIGSEL     = 5;        
    AdcRegs.ADCSOC11CTL.bit.TRIGSEL     = 5;        
    AdcRegs.ADCSOC12CTL.bit.TRIGSEL     = 5;        
    AdcRegs.ADCSOC13CTL.bit.TRIGSEL     = 5;        
    AdcRegs.ADCSOC14CTL.bit.TRIGSEL     = 5;        
    AdcRegs.ADCSOC15CTL.bit.TRIGSEL     = 5;        

    AdcRegs.ADCSOC0CTL.bit.CHSEL        = 0x0;    
    AdcRegs.ADCSOC1CTL.bit.CHSEL        = 0x1;    
    AdcRegs.ADCSOC2CTL.bit.CHSEL        = 0x2;    
    AdcRegs.ADCSOC3CTL.bit.CHSEL        = 0x3;    
    AdcRegs.ADCSOC4CTL.bit.CHSEL        = 0x4;    
    AdcRegs.ADCSOC5CTL.bit.CHSEL        = 0x5;    
    AdcRegs.ADCSOC6CTL.bit.CHSEL        = 0x6;    
    AdcRegs.ADCSOC7CTL.bit.CHSEL        = 0x7;    
    AdcRegs.ADCSOC8CTL.bit.CHSEL        = 0x8;    
    AdcRegs.ADCSOC9CTL.bit.CHSEL        = 0x9;    
    AdcRegs.ADCSOC10CTL.bit.CHSEL       = 0xA;    
    AdcRegs.ADCSOC11CTL.bit.CHSEL       = 0xB;    
    AdcRegs.ADCSOC12CTL.bit.CHSEL       = 0xC;    
    AdcRegs.ADCSOC13CTL.bit.CHSEL       = 0xD;    
    AdcRegs.ADCSOC14CTL.bit.CHSEL       = 0xE;    
    AdcRegs.ADCSOC15CTL.bit.CHSEL       = 0xF;    

    AdcRegs.ADCSOC0CTL.bit.ACQPS        = 9;       
    AdcRegs.ADCSOC1CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC2CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC3CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC4CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC5CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC6CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC7CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC8CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC9CTL.bit.ACQPS        = 9;     
    AdcRegs.ADCSOC10CTL.bit.ACQPS       = 9;     
    AdcRegs.ADCSOC11CTL.bit.ACQPS       = 9;     
    AdcRegs.ADCSOC12CTL.bit.ACQPS       = 9;     
    AdcRegs.ADCSOC13CTL.bit.ACQPS       = 9;       
    AdcRegs.ADCSOC14CTL.bit.ACQPS       = 9;       
    AdcRegs.ADCSOC15CTL.bit.ACQPS       = 9;       

    AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 0;        

    AdcRegs.SOCPRICTL.bit.SOCPRIORITY = 0;     

    AdcRegs.INTSEL1N2.bit.INT1CONT = 0;        
    AdcRegs.INTSEL1N2.bit.INT1E = 1;           
    AdcRegs.INTSEL1N2.bit.INT1SEL = 15;          

    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;         
    IER |= 0x0001;                             

    AdcRegs.ADCCTL1.bit.ADCENABLE = 1; 
    asm(" EDIS");                      

  • Ravi,
    There is no issue in reading a voltage on floating pins, this is an artifact of the ADC's sample and hold capacitor having some residual charge from an internal node when it is not sampling.

    If you are having issues with noise coupling onto you ADC inputs from the external FET switching you can change the compare value that generates the ADC trigger to be slightly before or after the ePWM switches. You can experiement with different values to see how far or close the ADC trigger can be before it picks up any ripple.

    In your code I noticed that you are sampling every channel when the ADC SOC trigger comes from the PWM. Another techinque you could use is to try and over sample the signal of interest(since you mentioned there are floating ADC channels, so I assume that means they are un-used), and then use a simple averaging filter to reduce the noise floor further.

    Please also take a look at the errata for this device, and make sure you are observing the first sample advicement; basically any first sample from IDLE will be out of spec from the datasheet.

    Best,
    Matthew