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.

Compiler/MSP430I2020: SD24 sampling result

Part Number: MSP430I2020
Other Parts Discussed in Thread: MSP-TS430RHB32A, , MSP-IQMATHLIB

Tool/software: TI C/C++ Compiler

hello,

- using development board: MSP-TS430RHB32A

I have using the sample code,"sd24_ex4_singleConversionSingleChannelPolling", but the results are different from my expected. Can you help? I expected that should be less than 10uV different

Info. A Info. B Info. C Info. D Info. E Info. F
Input Volt. (mV) ADC count (in hex) ADC count (in Dec)   ADC convert volt. (mV) diff between result and input voltage (mV)
0.01 572 1394 1394 0.207722187 0.197722187
98.47 ab65c 702044 702044 104.6127081 6.142708092
198.36 15960a 1414666 1414666 210.801661 12.44166101
298.53 207bd7 2128855 2128855 317.2241151 18.69411513
398.39 2b5599 2839961 2839961 423.1871665 24.79716645
499.63 36591a 3561754 3561754 530.7427049 31.11270487
599.5 4130bc 4272316 4272316 636.6246939 37.12469387
700.2 4c24a0 4990112 4990112 743.5846329 43.38463287
800 56fff9 5701625 5701625 849.6083319 49.60833192
897.6 61a044 6398020 6398020 953.3792734 55.77927341
997.4 6c7a65 7109221 7109221 1059.356481 61.95648084

 

Best regards,

T Hung

adctry3b.xlsx

  • Hello Hung,

    I've recently done a similar test, and without software oversampling, I could only get from 30uVp-p and 40uVp-p noise. With software oversampling (basically averaging a certain number of samples), I was able to get below 10uVp-p noise with the ADC differential inputs shorted. I used the 'msp430i20xx_sd24_03.c' code example. You want to make sure that you're toggling SD24LSBACC bit too to capture all 24 bits too.

    Also, remember that when you exceed the recommended differential input voltage VID for a specific GAIN, the ADC may not have the specified performance. For example, the recommended max VID for the MSP430i2020 is +/-928mV for GAIN = 1. You can find this value and others on page 24 in the datasheet.

    Regards,

    James

    MSP Customer Applications
  • Hi James,

    where can find 'msp430i20xx_sd24_03.c'? Could you send to me? my sample code is modified by "sd24_ex4_singleConversionSingleChannelPolling" attached

    The setting as below:

    - Gain = 1,

    - using the function of "SD24_getResults" (with toggle SD24LSBACC bit)

    8272.main.c
    /* --COPYRIGHT--,BSD
     * Copyright (c) 2016, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430i20xx SD24 Example 04 - SD24, Single Conversion on a Single Channel, Poll IFG
    //
    //  Description: This program uses the SD24 module to perform a single
    //  conversion on a single channel. The SD24 interrupt flag for CH0 is polled
    //  to determine when a conversion has completed.
    //
    //  Test by applying a voltage to the input channel and setting a breakpoint
    //  at the indicated line. Run program until it reaches the breakpoint, then use
    //  the debugger's watch window to view the conversion results.
    //
    //  Results (upper 16 bits only) are stored in the variable "results"
    //
    //  ACLK = 32kHz, MCLK = SMCLK = Calibrated DCO = 16.384MHz, SD_CLK = 1.024MHz
    //  * Ensure low_level_init.c is included when building/running this example *
    //
    //  Notes: For minimum Vcc required for SD24 module - see datasheet
    //         100nF cap btw Vref and AVss is recommended when using 1.2V ref
    //
    //               MSP430i20xx
    //             -----------------
    //         /|\|                |
    //          | |                |
    //          --|RST             |
    //            |                |
    //   Vin1+ -->|A0.0+      VREF |---+
    //   Vin1- -->|A0.0-           |   |
    //            |                |  -+- 100nF
    //            |                |  -+-
    //            |                |   |
    //            |           AVss |---+
    //
    //  T. Witt
    //  Yang Lu
    //  Texas Instruments, Inc
    //  June 2014
    //  Built with Code Composer Studio v5.5
    //******************************************************************************
    #include "common.h"
    
    #include "adc.h"
    
    void main(void) {
        // Stop WDT
        WDT_hold(WDT_BASE);
    
        // Internal ref
        SD24_init(SD24_BASE, SD24_REF_INTERNAL);
    
        //Ch0 single mode
        SD24_initConverterAdvancedParam param = {0};
        param.converter = SD24_CONVERTER_0;
        param.conversionMode = SD24_SINGLE_MODE;
        param.groupEnable = SD24_NOT_GROUPED;
        param.inputChannel = SD24_INPUT_CH_ANALOG;
        param.dataFormat = SD24_DATA_FORMAT_2COMPLEMENT;
        param.interruptDelay = SD24_FOURTH_SAMPLE_INTERRUPT;
        param.oversampleRatio = SD24_OVERSAMPLE_256;
        param.gain = SD24_GAIN_1;
        SD24_initConverterAdvanced(SD24_BASE, &param);
    	P1DIR |= P_LED_Pin;                   // LED Output
    
        // Delay ~200us for 1.2V ref to settle
        __delay_cycles(3200);
    	
    	uc_adc_startcnt = 0;
    	uc_adc_cnt = 0;
    
        while(1)
        {
            // Start conversion
            SD24_startConverterConversion(SD24_BASE, SD24_CONVERTER_0);                         // 
            // Poll IFG until conversion completes
            while(!SD24_getInterruptStatus(SD24_BASE, SD24_CONVERTER_0,
                                           SD24_CONVERTER_INTERRUPT))
            {
                ;
            }
            
            // Save SD24 conversion results		
    	if(uc_adc_startcnt >= C_ADC_CNT_TRY)	
    	{
    		uc_adc_cnt += 1;
    		if(uc_adc_cnt > C_ADC_CNT_MAX)
    		{
    			uc_adc_cnt = 1;				
    		}
    		l_result[uc_adc_cnt] = (long)SD24_getResults(SD24_BASE, SD24_CONVERTER_0);
    		
    		if(uc_adc_cnt >= C_ADC_CNT_MAX)
    		{
    			l_result[0] = avg_adc();
                P1OUT ^= P_LED_Pin;                 // Toggle P1.4 using exclusive-OR
                __no_operation();                   // SET BREAKPOINT HERE                               
    		}			
    	}
        else
    	{
    		uc_adc_startcnt++;
    		l_result[1] = (long)SD24_getResults(SD24_BASE, SD24_CONVERTER_0);
    	}
    	
        __no_operation();                   // SET BREAKPOINT HERE
    	
        }
    }
    

    Any calculation need to apply until I can get the correct result. For example, for 499.39mV , but from the adc of 430i2020, it get the 509.157mV.=> 9.767mV error.

    Best regards,

    Hung

    adc_TIb.xlsx

  • Dear James,

    Any suggestion. Please advice

    Best regards,
    Hung
  • Anyone know how to convert the ADC to actual voltage? Thanks!

    Best regards,
    Hung
  • Hello Hung,

    I suspect that you're observing the ADC gain offset. To adjust for this, we perform what's called gain calibration. Calibration can be done once or multiple times for various input ranges. To keep things simple, we'll use single-point calibration. Using your shared spreadsheet, I plotted the difference between your applied input voltage and the ADC converted (measured) voltage. As you can see, the difference across the input voltages scales linearly. Thus, a linear scaling factor should resolve this observed difference.

    To calculate the scaling factor, I just divided the input voltage by the ADC measured voltage. Since we're doing single-point calibration and not multi-point calibration, I averaged the scaling factors. Then, scaled all the ADC measured voltages by this average scaling factor. The result? A difference no greater than 0.3mV across all the inputs.

    Info. A Info. E Info. F Info. G Info. H Info. I
    Input Volt. (mV) ADC convert volt. (mV) diff between result and input voltage (mV) Scaling Factor Adjusted ADC convert volt. (mV) diff between result and input voltage (mV)
      0 0 =Cxx/Gxx

    =Gxx*AVG_SCALING_FACTOR

     
    98.44 100.5037308 2.063730774 0.979466128 98.56090404 0.120904041
    198.25 202.2053719 3.955371857 0.980438839 198.2965617 0.046561717
    298.39 304.2909622 5.900962219 0.980607501 298.4087466 0.01874659
    398.17 405.9941769 7.824176865 0.980728352 398.1459474 -0.02405259
    499.39 509.1570854 9.767085419 0.980817147 499.314625 -0.075375046
    599.3 610.918808 11.61880798 0.98098142 599.1092027 -0.190797317
    700 713.5622978 13.56229782 0.980993534 699.7685023 -0.231497663
    799.9 815.370512 15.47051201 0.981026402 799.608673 -0.291327035
    897.4 914.8156643 17.41566429 0.980962652 897.1314618 -0.268538219
      0.980669108
      AVG_SCALING_FACTOR

    In your code, you'll want to multiply the result by this average scaling factor. After more testing, you may be able to find a better scaling factor to further reduce the difference inaccuracy. For optimizing the floating point multiplication, you may want to convert the float (decimal) into fixed point math. Take a look at the Fixed Point Math Library for MSP (MSP-IQMATHLIB) and its user's guide for more details.

    adc_TIb_edited_on_8-21-18.xlsx

    I hope this helps answer your question.

**Attention** This is a public forum