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/CC3200: Not happening the proper calibration for LM35 with cc3200

Part Number: CC3200
Other Parts Discussed in Thread: LM35,

Tool/software: Code Composer Studio

Hi,

I have attached the LM35 DZ with cc3200 Launchpad as well as my custom board. I am giving the supply to sensor 5.14V. After that, I have the voltage divider circuit to reduce the voltage from 5v to 1.4v of sensor for ADC pin of cc3200 because cc3200 ADC pin voltage is 1.45. But, when the environmental temperature is varying, i can not any see any major changes in my sensor. Can I know why, what am I doing wrong?

I have taken the reference from ADC note and ADC demo also. But, i did not get any result. Please  check the code for this and please tell me the alternative steps to find out the solution.

// Standard includes
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

// Driverlib includes
#include "utils.h"
#include "hw_memmap.h"
#include "hw_common_reg.h"
#include "hw_types.h"
#include "hw_adc.h"
#include "hw_ints.h"
#include "hw_gprcm.h"
#include "rom.h"
#include "rom_map.h"
#include "interrupt.h"
#include "prcm.h"
#include "uart.h"
#include "pinmux.h"
#include "pin.h"
#include "adc.h"

#include "adc_userinput.h"
#include "uart_if.h"

#define USER_INPUT
#define UART_PRINT         Report
#define FOREVER            1
#define APP_NAME           "ADC Reference"
#define NO_OF_SAMPLES 		128
#define MAXTIMINGS	85
unsigned long pulAdcSamples[4096];
int dht11_dat[5] = { 0, 0, 0, 0, 0 };
//*****************************************************************************
//                      GLOBAL VARIABLES
//*****************************************************************************
#if defined(ccs)
extern void (* const g_pfnVectors[])(void);
#endif
#if defined(ewarm)
extern uVectorEntry __vector_table;
#endif

/****************************************************************************/
/*                      LOCAL FUNCTION PROTOTYPES                           */
/****************************************************************************/
static void BoardInit(void);
static void DisplayBanner(char * AppName);

//*****************************************************************************
//
//! Application startup display on UART
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
static void
DisplayBanner(char * AppName)
{
    Report("\n\n\n\r");
    Report("\t\t *************************************************\n\r");
    Report("\t\t       CC3200 %s Application       \n\r", AppName);
    Report("\t\t *************************************************\n\r");
    Report("\n\n\n\r");
}

//*****************************************************************************
//
//! Board Initialization & Configuration
//!
//! \param  None
//!
//! \return None
//
//*****************************************************************************
static void
BoardInit(void)
{
/* In case of TI-RTOS vector table is initialize by OS itself */
#ifndef USE_TIRTOS
    //
    // Set vector table base
    //
#if defined(ccs)
    MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
#endif
#if defined(ewarm)
    MAP_IntVTableBaseSet((unsigned long)&__vector_table);
#endif
#endif
    //
    // Enable Processor
    //
    MAP_IntMasterEnable();
    MAP_IntEnable(FAULT_SYSTICK);

    PRCMCC3200MCUInit();
}

static void delay(unsigned int d)
{
    unsigned int i;
    for (i=0;i<d*100;i++){}
}

//*****************************************************************************
//
//! main - calls Crypt function after populating either from pre- defined vector
//! or from User
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
void
main()
{
    unsigned long  uiAdcInputPin;
    unsigned int  uiChannel;
    unsigned int  uiIndex=0;
    unsigned long ulSample;

    //
    // Initialize Board configurations
    //
    BoardInit();

    //
    // Configuring UART for Receiving input and displaying output
    // 1. PinMux setting
    // 2. Initialize UART
    // 3. Displaying Banner
    //
    PinMuxConfig();
    InitTerm();
    DisplayBanner(APP_NAME);

    while(FOREVER)
    {
        //
        // Initialize Array index for multiple execution
        //
        uiIndex=0;

        //
        // Read inputs from user
        //
//        if(!ReadFromUser(&uiAdcInputPin))
//        {
//          UART_PRINT("\n\rInvalid Input. Please try again. \n\r");
//          continue;
//        }

#ifdef CC3200_ES_1_2_1
        //
        // Enable ADC clocks.###IMPORTANT###Need to be removed for PG 1.32
        //
        HWREG(GPRCM_BASE + GPRCM_O_ADC_CLK_CONFIG) = 0x00000043;
        HWREG(ADC_BASE + ADC_O_ADC_CTRL) = 0x00000004;
        HWREG(ADC_BASE + ADC_O_ADC_SPARE0) = 0x00000100;
        HWREG(ADC_BASE + ADC_O_ADC_SPARE1) = 0x0355AA00;
#endif

        uiAdcInputPin= PIN_60;
        //
        // Pinmux for the selected ADC input pin
        //
        MAP_PinTypeADC(uiAdcInputPin,PIN_MODE_255);

        //
        // Convert pin number to channel number
        //
        switch(uiAdcInputPin)
        {
            case PIN_58:
                uiChannel = ADC_CH_1;
                break;
            case PIN_59:
                uiChannel = ADC_CH_2;
                break;
            case PIN_60:
                uiChannel = ADC_CH_3;
                break;
            default:
                break;
        }

        //
        // Configure ADC timer which is used to timestamp the ADC data samples
        //
        MAP_ADCTimerConfig(ADC_BASE,2^17);

        //
        // Enable ADC timer which is used to timestamp the ADC data samples
        //
        MAP_ADCTimerEnable(ADC_BASE);

        //
        // Enable ADC module
        //
        MAP_ADCEnable(ADC_BASE);

        //
        // Enable ADC channel
        //

        MAP_ADCChannelEnable(ADC_BASE, uiChannel);
        float samplesAveraged;
        while(uiIndex <10)
        {
            if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel))
            {
                ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel);
                ulSample = (ulSample & 0x3ffc)>>2; //get bits [13:2]
                           //pulAdcSamples[uiIndex++] = ulSample;
                           samplesAveraged += (float)ulSample; //sum up all of the reading
                           uiIndex++;
            }
        }

        MAP_ADCChannelDisable(ADC_BASE, uiChannel);

        uiIndex = 0;

        //UART_PRINT("\n\rTotal no of 32 bit ADC data printed :4096 \n\r");
        //UART_PRINT("\n\rADC data format:\n\r");
        //UART_PRINT("\n\rbits[13:2] : ADC sample\n\r");
        //UART_PRINT("\n\rbits[31:14]: Time stamp of ADC sample \n\r");

        //
        // Print out ADC samples
        //

//        while(uiIndex < NO_OF_SAMPLES)
//        {
//            UART_PRINT("\n\rVoltage is %f\n\r",(((float)((pulAdcSamples[4+uiIndex] >> 2 ) & 0x0FFF))*1.4)/4096);
//            uiIndex++;
//        }
        float voltageResult;
        samplesAveraged = ( samplesAveraged/ 10.0f ); //get average
        voltageResult =  (float)(( (1.4f/ 4096.0f ) * samplesAveraged) ); //calculate mV
        UART_PRINT("\n\r voltage = %f",voltageResult);
        float temperature;
       // UART_PRINT("\n\rVoltage is %f\n\r",((float)((pulAdcSamples[4] >> 2 ) & 0x0FFF)*1.457)/4096);
       // output_voltage=((float)((pulAdcSamples[4] >> 2 ) & 0x0FFF)*1.457)/4096;
        temperature=((voltageResult)*100);
        UART_PRINT("\n\r temperature = %f",temperature);
        UART_PRINT("\n\r");
        delay(90000);


    }
}

  • Hi Black_Robot,

    Can you share a schematic of how you have the LM35 wired?

    How are you varying the environmental temperature? And what is the temperature reading at room temperature (25C)?

    Jalen

  • Dear Black Robot - 

    did you use Pin Mux Tool already to set up the ADC? here is the example for you to use to make sure all hardware is correctly working 

    Also, is there a reason you are using CC3200 vs CC3220 or CC3235 here? The LaunchPads and firmware for these devices are designed a bit better so you can use the ADC of the CC32xx a little easier. 

  • Hi,

    I am varying the temperature through Air Conditioners and taking the device with sensor outside of home or room.

    The temperature reading at 25 degree temperature is 18 and 19 degree. But, when the room temperature reduce, the temperature reading doesn't reduce or doesn't increase on increment of temperature.

    Please find the attachment of circuit.

  • Hi,

    I am using only CC3200 Launchpad as well as my custom board. I am using only the ADC demo application to to get the voltage. I have just modified the code according to sensor as you can see the code in my above post. 

    Thanks

  • Dear Black Robot -

    The LM35 will output between -550mV (@-55C) and 1500mV (@150C), so the voltage divider you added is not helping you here. Would suggest wiring it like the datasheet shows with just a pulldown. You should be able to check this out with DVM before connecting to CC3200

    the other issue I foresee then you will have is that the CC3200 ADC does not measure below 0V. I think a circuit (may involve more than one op amp, etc.) will need to be designed to handle that for you. Let us know if you need help with that and we can try to assist. 

  • Dear Black Robot-  

    In anticipation of you asking for the op amp ckt - I spent some time simulating one for this use case. You may have to play around with the values for R3 and R4, but this is for sure in the ballpark of what is needed. hope this helps you out