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.

MSP430 ADC12_A SNR checking

Other Parts Discussed in Thread: MSP430F5438A

hi to all,

       I am working with msp430f5438a microcontorller with your experimenter board MSP-EXP430F5438. In that i am working with ADC12_A(varaious resolution 8,10,12 bit) my problem is,

  * For 8-bit adc Ideal SNR = 48dB around whereas we are getting around 42dB for a sinusoidal input. But, the SNR reaches to 48dB ie. below 20 HZ of input signal frequency. When increse in Frequency the SNR is deteriorating.

The operating condition of the ADC12_A

ADC12CLK = ADC12OSC (5MHZ)

SAMPLING TIME CLK CYCLES ADC12SHT0_0 = 4 ADC12CLK CYCLES

REFERENCE : Vr+ = VREF+ 2.5V ; Vr- = AVSS    i.e ADC12SREF_1

I will attach my code below, and tell me the possible ranges to get Perfect SNR Ratio. If there is any parameter have to change let me know.

* I am using function generator as a analog input source with the external impedence (50 ohm - 1 M ohm), normally i am using 10 kohm;

My program :

#include "msp430f5438A.h"
#include <stdio.h>
void adc_function(void);

void main(void)
{

WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
adc_function();

__bis_SR_register(LPM4_bits + GIE); // Enter LPM4, Enable interrupts
__no_operation(); // For debugger

}

void adc_function(void)
{
P6SEL |= 0x80; // Enable A/D channel A7
PBDIR = PBDIR | 0xFFFF;

REFCTL0 = REFMSTR + REFON + REFVSEL_2 + REFTCOFF;

ADC12CTL0 = ADC12ON+ADC12SHT0_0+ADC12MSC;

ADC12CTL1 = ADC12CSTARTADD_7 + ADC12SHP + ADC12SHS_0 + ADC12DIV_0 + ADC12SSEL_0 + ADC12CONSEQ_2;

ADC12CTL2 = ADC12RES_0;

ADC12MCTL7 = ADC12SREF_1 + ADC12INCH_7;
ADC12IE = ADC12IE7;

ADC12CTL0 |= ADC12ENC;
ADC12CTL0 |= ADC12SC;
}

// INTERRUPT VECTORS FOR MSP430 ////////////////////////////////////////

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{

switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: break; // Vector 6: ADC12IFG0
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12: break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: // Vector 20: ADC12IFG7
PBOUT = ADC12MEM7;
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}

  • PRASANTH S said:
    When increse in Frequency the SNR is deteriorating.

    When increase frequency is it just SNR deteriorating, or amplitude also goes down compared to 20Hz signal? - If amplitude gets smaller, then you are losing ADC resolution, thus SNR. What is maximum signal freq you want to measure? What is sampling frequency?

    PRASANTH S said:
    * I am using function generator as a analog input source with the external impedence (50 ohm - 1 M ohm), normally i am using 10 kohm;

    You shall read User's Guide, chapter "Sampling Time Considerations". 10K seems too much, especially if you are looking for higher frequencies. Do you have same SNR behaviour while using 50ohm signal source?

  • Hi Ilmars, good morning

    The mentioned below details according to my knowledge, if there is any mistake kindly forgive me. And make me to understand well enough. Thank you
    Question 1 : When increase frequency is it just SNR is deteriorating or Amplitude is changing?

    When incresing the frequency of Input signal the SNR only deteriorating, there is no change in its Amplitude. Which means Amplitude is reaching its maximum value (255) for 8-bit.

    Question 2 : What is Sampling frequency?
    According to my program the sampling frequency is,
    Sampling frequency = 1/(Sampling time + Conversion time);
    Sampling time = Sampling period clock cycles/ADC12CLK frequency
    => 8(ADC12CLK cycles)/4.2MHZ(min clock frequency ADC12OSC)
    => 1.9us; 2us approximately (It is greater than minimum sampling time required for 50ohm & 1kohm)
    Conversion time = Conversion period clock cycles/ADC12CLK frequency
    => 9(ADC12CLK cycles for 8-bit resolution)/4.2Mhz
    => 2.14 us ; 2 us Approximately

    Sampling Frequency = 250 khz
    Sampling rate is = 250 ksps

    Question 3 : What is maximum Signal you want to measure ?
    According to Nyquist theorem
    Fs > 2 Fin

    In our case, minimum and maximum input signal frequency range is,
    0.1Hz to 10Khz
    Question 4 : I have gone through the "Sample Timing Considerations"
    For example they have given,
    Minimu sampling time for 12-bit resolution is , If Rs = 10kohm
    tsample > 3.46us

    Our calculation :
    1 => for 50ohm , 8-bit
    tsample > 1us
    2 => 1kohm, 8-bit
    tsample > 1.22us
    3 => 10kohm, 8-bit
    tsample > 2.5us
    4 => 1 megaohm(High Impedence), 8-bit
    tsample > 151us or 0.15ms
    I am getting same SNR behaviour from 50ohm to high impedance (1Megaohm).

    Once again i will attach my code :

    #include "msp430f5438A.h"
    #include <stdio.h>
    void adc_function(void);

    void main(void)
    {

    WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
    adc_function();

    __bis_SR_register(LPM4_bits + GIE); // Enter LPM4, Enable interrupts
    __no_operation(); // For debugger

    }

    void adc_function(void)
    {
    P6SEL |= 0x80; // Enable A/D channel A7
    PBDIR = PBDIR | 0xFFFF;

    REFCTL0 = REFMSTR + REFON + REFVSEL_2 + REFTCOFF;

    ADC12CTL0 = ADC12ON+ADC12SHT0_1+ADC12MSC;

    ADC12CTL1 = ADC12SHP + ADC12SHS_0 + ADC12DIV_0 + ADC12SSEL_0 + ADC12CONSEQ_2;

    ADC12CTL2 = ADC12RES_0;

    ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_7;
    ADC12IE = ADC12IE0;

    ADC12CTL0 |= ADC12ENC;
    ADC12CTL0 |= ADC12SC;
    }

    // INTERRUPT VECTORS FOR MSP430 ////////////////////////////////////////

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt void ADC12ISR (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch(__even_in_range(ADC12IV,34))
    {
    case 0: break; // Vector 0: No interrupt
    case 2: break; // Vector 2: ADC overflow
    case 4: break; // Vector 4: ADC timing overflow
    case 6: // Vector 6: ADC12IFG0
    PBOUT = ADC12MEM0;
    case 8: break; // Vector 8: ADC12IFG1
    case 10: break; // Vector 10: ADC12IFG2
    case 12: break; // Vector 12: ADC12IFG3
    case 14: break; // Vector 14: ADC12IFG4
    case 16: break; // Vector 16: ADC12IFG5
    case 18: break; // Vector 18: ADC12IFG6
    case 20: break; // Vector 20: ADC12IFG7

    case 22: break; // Vector 22: ADC12IFG8
    case 24: break; // Vector 24: ADC12IFG9
    case 26: break; // Vector 26: ADC12IFG10
    case 28: break; // Vector 28: ADC12IFG11
    case 30: break; // Vector 30: ADC12IFG12
    case 32: break; // Vector 32: ADC12IFG13
    case 34: break; // Vector 34: ADC12IFG14
    default: break;
    }
    }
  • Hi! If you say that signal reaches 255 for 8-bit conversion, you most likely are getting ADC clipping or saturation in the input circuit. Never exploit min/max of input circuit or ADC if you care about SNR. Try to decrease signal amplitude by at least few ADC counts and see how then SNR differs between 10Hz and 10KHz. Any chance to do FFT on digitized waveforms? - Most probably you will see your problem there, in form of harmonics.

  • I really don't understand:
    - how can you get parallel digital data from MCU without synchronization information?
    - why do you need to test 8-bit SNR for 12-bit ADC?

    TI's theoretical and practical knowledge in analog and digital signal processing is one of the finest in the world with more than 60 years of experience. Why do you think that they missed something in ADC conversion?

  • I recommend to study such documentation:
    Read this TI's brochure. It contains info for ADC/DAC SNR: http://www.ti.com/lit/slyw038
    Watch this TI's video course training.ti.com/ti-precision-labs-op-amps

    Additional topics such as 'dithering' you can learn later.
    Then do your practical research. You'll save a huge amount of time later by doing this before. It is free.
  • Alexey Bagaev said:
    - how can you get parallel digital data from MCU without synchronization information?

    Right. Very good question.

    Alexey Bagaev said:
    - why do you need to test 8-bit SNR for 12-bit ADC?

    If particular ADC12 have 8-bit mode (giving higher sample rates), then why not?

    Alexey Bagaev said:
    Why do you think that they missed something in ADC conversion?

    IMHO he just wants to understand why he is not getting expected results. You have no reason to get jumpy here and advocate TI :D

  • Ilmars said:
    You have no reason to get jumpy here

    Yes, I should not be so punchy.

  • Dear Alexey Bagaev,
    Thank you for your informations. Let me discuss about my problems.
    MSP430F5438A has 12-bit ADC with 200Ksps. My project demands, to specify Min I/P & Max I/P freq.
    When we tried to get Maximum frequency, we are not able to produce more than 10hz without missing codes.
    Actually out applications demands up to 5Khz I/P signal needs to be handled. But we are not able to reproduce 5Khz I/P signal after the ADC converting.
    What we are doing,
    1 => Giving signal from function generator to ADC.
    2 => O/P of ADC we are displaying via UART in PC using Python program(which will take Data and Calculate FFT).

    My test is to reproduce I/P signal through ADC in Python.
    Please suggest us what to do?
    If I get solution, I need not do all kinds of SNR Calculations,
    Looking forward to hear from you a solution.

    Thank you.
  • PRASANTH S said:
    My test is to reproduce I/P signal through ADC in Python.

    Python is your problem (bottleneck) why you cant produce more than 10hz without missing codes. DMA could be solution, whou I am not sure that it is available in python.

  • Hi,
    Based on the information you provided about your demands, your code does not fulfill it at all. I recommend to research sample codes provided by TI directly from Code Composer Studio v.6.
    Technically speaking ADC on the chip you mentioned can do conversion tasks without any main CPU intervention and carry up to 16 ADC samples on it without any main data bus usage. Preconfigured DMA can also transfer ready-to-go data from ADC to external interface, in your case an UART. So, practically you can have up to 80*16 clock cycles to handle such transfer from source to destination in ADC rate up to 200k samples. DMA do it in 2 cycles per transfer. This means that it is possible to transfer up to 100kHz of signal bandwidth for further calculations.

    The code you've provided don't have any configuration for UART. So, how did you get any data though UART?
    I will not provide you any raw code. I just can show you a vector where to go.

    Alexey

**Attention** This is a public forum