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/LAUNCHXL-F28027F: ADC Configuration - Oversampling/Three-phase Measurement/Normalization

Part Number: LAUNCHXL-F28027F

Tool/software: Code Composer Studio

Dear TI members,

I am working on the implementation of a three-phase inverter that operates synchronized to the grid (via a PLL algorithm), and I have some questions related to the configuration of the ADC for a three-phase input. I have described my questions below:

1) When I connect a single-phase ac signal ranging between 1-to-3V to ports ADCINA0 (v_ref_hi) and GRD of LAUNCHXL-F28027F, my ADCRESULT0, ADCRESULT1, and ADCRESULT2 are all displaying ac signals, but I expected only the first one to display values, while the other 2 should be reading nothing. Am I connecting the signal to wrong ports? Where should I connect the ground of the input signal? Should I use one of the ADC ports to receive the ground, and subtract the other ADC values from that? 

 

2) When reading the input of the system for my DLOG_4CH, I apply a bitshift (dval1= AdcResult.ADCRESULT0<<3;); however, the signal is only positive. What is the most appropriate way to normalize this signal and make it range from +vpeak to -vpeak?

 

3) I am using my ePWM2 to trigger the ISR, in which I read the ADC results, call the PLL algorithm, and save it in buffers for visualization (it worked for a 1ph system). But now I am trying to optimize my ADC to be as fast and precise as possible. Could I apply oversampling to all 3 input signals (by using more SOC) to make the sampling better? How should I improve my ADC speed while keeping in mind how long it takes for the ISR to be completed?

 

4) Is the fastest sampling rate possible directly related to the value I set to (EPwm2Regs.TBPRD = ADC_SAMPLE_PERIOD;)? At the moment I am using a sampling rate of 50kHz, but since the clock is 60MHz I was hoping I would be able to push it up to 250-300kHz or more.

 

I apologize for the excess of questions, but it would be very helpful if I could get some guidance at this point since this is the first time I am working with ADCs and ISRs.

Thank you,

Victor

  • Victor -Graduate student said:
    1) When I connect a single-phase ac signal ranging between 1-to-3V to ports ADCINA0 (v_ref_hi) and GRD of LAUNCHXL-F28027F, my ADCRESULT0, ADCRESULT1, and ADCRESULT2 are all displaying ac signals, but I expected only the first one to display values, while the other 2 should be reading nothing. Am I connecting the signal to wrong ports? Where should I connect the ground of the input signal? Should I use one of the ADC ports to receive the ground, and subtract the other ADC values from that?

    The conversion behavior is determined by your software programmable ADC SOC configurations.  You can find the register definitions in the TRM

    Victor -Graduate student said:
    2) When reading the input of the system for my DLOG_4CH, I apply a bitshift (dval1= AdcResult.ADCRESULT0<<3;); however, the signal is only positive. What is the most appropriate way to normalize this signal and make it range from +vpeak to -vpeak?

    This ADC only supports positive input voltages so you would need to use external circuitry to condition the input signals into the supported ADC input range. Once in the digital domain, normalization is typically performed through post-processing with IQ math (or native floating point where available).

    Victor -Graduate student said:
    3) I am using my ePWM2 to trigger the ISR, in which I read the ADC results, call the PLL algorithm, and save it in buffers for visualization (it worked for a 1ph system). But now I am trying to optimize my ADC to be as fast and precise as possible. Could I apply oversampling to all 3 input signals (by using more SOC) to make the sampling better? How should I improve my ADC speed while keeping in mind how long it takes for the ISR to be completed?

    It is best to limit the ISR to servicing real-time critical tasks like saving profiling data to buffers or updating control actuation. Lower priority tasks like analyzing profiling data for debug should be performed in the background loop. Here's an article about the philosophy.

    Victor -Graduate student said:
    4) Is the fastest sampling rate possible directly related to the value I set to (EPwm2Regs.TBPRD = ADC_SAMPLE_PERIOD;)? At the moment I am using a sampling rate of 50kHz, but since the clock is 60MHz I was hoping I would be able to push it up to 250-300kHz or more.

    The ADC conversion throughput and system sampling rate are two distinct characteristics. The maximum ADC conversion throughput is 4.6MSPS. The system sampling rate is determined by your ADC trigger source (ex: EPWM SOCA). For each trigger, the ADC will burst the associated SOCs at a conversion throughput of up to 4.6MSPS (where the actual throughput is determined by the ADC software configuration).

  • Dear tlee,  

    I appreciate the quick reply, it was very helpful!

    About the first question:

    --I understand that the manual explains the ports of the ADC, and I did follow it when connecting them to the microcontroller (the ports were also available in this quick startguide (http://www.ti.com/lit/ml/sprz413/sprz413.pdf). One of the things I am having trouble to understand is why when connecting the input signal between ADCINA0 and GRD I am finding the input signal in all three ADC.RESULT registers? Maybe I am misunderstanding what the GRD port is for, and where I should connect the ground from my three-phase signal (I am adding my ADC code to the end of this reply just in case it is a problem in the code)

    About the second question:

    --I see. I will need to adjust my sensors to operate between 0 and 3.3V. What would be the post-processing function that we would apply for the normalization?

    About 3rd:

    -- Would the oversampling with 2SOC for each ADCRESULT be useful, or would it just consume more time?

    About 4th:

    --Does that mean that I could set up the ePWM to up to 4.6MHz to obtain an SOC operating at 4.6MHz?

    Thank you for you assistance in this matter,

    Victor

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ADC CODE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    /**********************************************************************
    * File: Adc.c -- File for Lab 3 and 4 (not used in Lab 2)
    * Devices: TMS320F2802x
    * Author: Technical Training Organization (TTO), Texas Instruments
    * History:
    *   03/30/09 - original
    **********************************************************************/
    
    #include "Lab.h"				// Main include file
    
    
    /**********************************************************************
    * Function: InitAdc()
    *
    * Description: Initializes the ADC on the F2802x
    **********************************************************************/
    void InitAdc(void)
    {
    	asm(" EALLOW");						// Enable EALLOW protected register access
    
    //--- Reset the ADC module
    // Note: The ADC is already reset after a DSP reset, but this example is just showing
    // good coding practice to reset the peripheral before configuring it as you never
    // know why the DSP has started the code over again from the beginning).  
    	// Must wait 2 ADCCLK periods for the reset to take effect.
    	// Note that ADCCLK = SYSCLKOUT for F2802x/F2803x devices.
    	AdcRegs.ADCCTL1.bit.RESET = 1;		// Reset the ADC
    	asm(" NOP");
    	asm(" NOP");
    	
    //--- Power-up and configure the ADC
    	AdcRegs.ADCCTL1.all = 0x00E4;		// Power-up reference and main ADC
    // bit 15        0:      RESET, ADC software reset, 0=no effect, 1=resets the ADC
    // bit 14        0:      ADCENABLE, ADC enable, 0=disabled, 1=enabled
    // bit 13        0:      ADCBSY, ADC busy, read-only
    // bit 12-8      0's:    ADCBSYCHN, ADC busy channel, read-only
    // bit 7         1:      ADCPWDN, ADC power down, 0=powered down, 1=powered up
    // bit 6         1:      ADCBGPWD, ADC bandgap power down, 0=powered down, 1=powered up 
    // bit 5         1:      ADCREFPWD, ADC reference power down, 0=powered down, 1=powered up 
    // bit 4         0:      reserved
    // bit 3         0:      ADCREFSEL, ADC reference select, 0=internal, 1=external
    // bit 2         1:      INTPULSEPOS, INT pulse generation, 0=start of conversion, 1=end of conversion
    // bit 1         0:      VREFLOCONV, VREFLO convert, 0=VREFLO not connected, 1=VREFLO connected to B5
    // bit 0         0:      Must write as 0.
    
    	DelayUs(1000);						// Wait 1 ms after power-up before using the ADC
    
    //--- SOC0 configuration
    	AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 0;		// SOC0 in single sample mode (vs. simultaneous mode)
    
    	//trigger ADC
    	AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 7;			// Trigger using ePWM2-ADCSOCA
    	AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 7;			//page  428. For now, ePWM is fine
    	AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 7;
    
    	//Sets ADC channels
    	AdcRegs.ADCSOC0CTL.bit.CHSEL = 0;			// Convert channel ADCINA0 (ch0)
    	AdcRegs.ADCSOC1CTL.bit.CHSEL = 1;			// Convert channel ADCINA1 (ch1)
    	AdcRegs.ADCSOC2CTL.bit.CHSEL = 3;			// Convert channel ADCINA3 (ch2)
    
    	//acquisition window duration
    	AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;			// Acquisition window set to (6+1)=7 cycles
    	AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
    	AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
    
    
    	AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 0;			// No ADCINT triggers SOC0.  TRIGSEL field determines trigger. (?)
    	AdcRegs.SOCPRICTL.bit.SOCPRIORITY = 0;		// All SOCs handled in round-robin mode (?)
    
    //--- ADCINT1 configuration
    	AdcRegs.INTSEL1N2.bit.INT1CONT = 1;			// ADCINT1 pulses regardless of ADCINT1 flag state
    	AdcRegs.INTSEL1N2.bit.INT1E = 1;			// Enable ADCINT1
    	AdcRegs.INTSEL1N2.bit.INT1SEL = 0;			// EOC0 triggers ADCINT1
    
    	PieCtrlRegs.PIEIER1.bit.INTx1 = 1;			// Enable ADCINT1 in PIE group 1
    	IER |= 0x0001;								// Enable INT1 in IER to enable PIE group
    
    //--- Finish up
    	AdcRegs.ADCCTL1.bit.ADCENABLE = 1;	// Enable the ADC
    	asm(" EDIS");						// Disable EALLOW protected register access
    
    } // end InitAdc()
    
    
    //--- end of file -----------------------------------------------------
    

  • Victor -Graduate student said:
    I understand that the manual explains the ports of the ADC, and I did follow it when connecting them to the microcontroller (the ports were also available in this quick startguide (http://www.ti.com/lit/ml/sprz413/sprz413.pdf). One of the things I am having trouble to understand is why when connecting the input signal between ADCINA0 and GRD I am finding the input signal in all three ADC.RESULT registers? Maybe I am misunderstanding what the GRD port is for, and where I should connect the ground from my three-phase signal (I am adding my ADC code to the end of this reply just in case it is a problem in the code)

    The sample code that you shared has three conversions enabled per trigger.

    The F2802x technical reference manual covers more than simple channel mapping. I recommend reading over the ADC chapter because the ADC behavior is highly configurable through software. It will be very difficult create an application without understanding what the modules doing. I also recommend reviewing the errata document.

    This might be a good time to also point out that LAUNCHXL-F28027F is not isolated so you may need to take precautions to avoid damage.

    Victor -Graduate student said:
    I see. I will need to adjust my sensors to operate between 0 and 3.3V. What would be the post-processing function that we would apply for the normalization?

    It would be up to you to determine what post processing is required to make the ADC conversions usable for your application. The input conditioning circuitry and signal processing requirements are both factors.

    Victor -Graduate student said:
    Would the oversampling with 2SOC for each ADCRESULT be useful, or would it just consume more time?

    Yes to both. It will take more time and it is often useful. The usefulness can be determined through modeling as they pertain to your specific setup or you can determine it through experimentation.

    Victor -Graduate student said:
    Does that mean that I could set up the ePWM to up to 4.6MHz to obtain an SOC operating at 4.6MHz?

    This is possible, but the ADC throughput may outpace your ability to use the results.

  • Ok! Thank you, I will read the manual to better understand the ADC.