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.

ADC values change as time goes on ( after the fix ). Floating pin or code issue?

Other Parts Discussed in Thread: CC3200, LM35, TMP006

Hi everyone,

I am aware of the error in the ADC example where the indexing does not get reset between reads.  It has been edited.

My situation is unique, maybe...

Setup:

CC3200 powered by either battery (stand aloine) and debug (direct usb)

Project connects to AP and starts HTTP server task. 

Webpage has a GET token that when executed reads an ADC routine that computes a value that gets pushed to the webpage.

LM35 temperature sensor with it's output voltage hooked to pin 59 which is an ADC line.  With this reading, my function then collects samples from the ADC, converts to a voltage, then does the appropriate calculations.

Problem:

Over the course of time(30+ min) my result raises (around)~30 degrees or so.  The room in which the sensor and the board are  placed in, the temperature rises gradually from cold to warm by a heating element that heats the room.  With this said, the temperature measurement should change in very small increments until max room temp given by the heaters has been reached. My sensor correctly measures room temperature correct until after 70/71/72/73+.  I've never seen it 80-90.  During testing, without having the resistor soldered between Vout and Gnd, it ran fine but I only ran it for no long than an hour.

In a nutshell, after about 30-90 minutes of my program being active the temperature reading jumps about 30 degrees off target and does not come back down to the expected temp.  Either this is a software or hardware problem.  My primary pin is PIN_59 for adc readings.

My prototype phase included the Vcc and Gnd of the cc3200 as outputs to a breadboard along with PIN58's coming from the breadboard, meaning my LM35's Vout was being router to the breadboard.  During this phase my temperature reading was fine.

I went to a final phase by soldering a 10k resistor in-between the Vout and Gnd lines of the sensor because a pull-down was required to get accurate measurement to the CC3200 ADC.  The pull-down ran from Gnd to PIN59.

Even changing ADC pins (58 or 60), I get even worse readings.  Source code is below.

The first section is my readADC routine which takes samples and does calculations.

In summary, device kicks on after being powered off for 12+ hours, acts normal for 1-3 hours, then raises 30 degree.

float readADC()
{
    //unsigned long pulAdcSamples[4096];

    unsigned long uiAdcInputPin;
    unsigned int  uiChannel;
    unsigned long ulSample;

    float samplesAveraged;
    float voltageResult;

    float celsiusTemp;
    float fahrenheitTemp;
    unsigned int uiIndex = 0;

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

    //
    // Convert pin number to channel number
    //
    uiChannel = ADC_CH_2;

    //
    // Enable ADC channel
    //
    MAP_ADCChannelEnable(ADC_BASE, uiChannel);

    //
    // 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);

    fahrenheitTemp = 0.0f; //compilier complains
	celsiusTemp = 0.0f;
	fahrenheitTemp = 0.0f;
	samplesAveraged = 0.0f;
	uiIndex = 0;
	ulSample = 0;

    while(uiIndex < 4096)
    {
        if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel))
        {
            ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel);
            ulSample = (ulSample & 0x3ffc)>>2; //get bits [13:2]
//pulAdcSamples[uiIndex++] = ulSample; //store
//sample was 647 with voltage result at 443 but multimeter voltage was 201

samplesAveraged += (float)ulSample; //sum up all of the reading uiIndex++; } } samplesAveraged = ( samplesAveraged/ 4096.0f ); //get average voltageResult = ( (1400.0f/ 4095.0f ) * samplesAveraged ); //calculate mV //UART_PRINT("\n\r voltageResult = %d \n\r", voltageResult); celsiusTemp = (voltageResult / 10.0f); //calculate celsius temp fahrenheitTemp = (1.8f * celsiusTemp) + 32.0f; celsiusTemp = 0.0f; samplesAveraged = 0.0f; uiIndex = 0; ulSample = 0; return
fahrenheitTemp 
; }

I did the weird resetting towards the end because I wasn't sure if the compiler optimized it away.  If I wanted to hardcore test I could put it inside an if statement of some sort.

Below here is my callback routine for the http server.  This has potential problems since there is some casting/converting involved.

void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent,
                                SlHttpServerResponse_t *pSlHttpServerResponse)
{
    switch (pSlHttpServerEvent->Event)
    {
        case SL_NETAPP_HTTPGETTOKENVALUE_EVENT:
        {
        	unsigned char *ptr;
        	ptr = pSlHttpServerResponse->ResponseData.token_value.data;
        	pSlHttpServerResponse->ResponseData.token_value.len = 0;

            if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data,
                       GET_token, strlen((const char *)GET_token)) == 0)
            {
                float fTemp;
                fTemp = 0.0f;
                fTemp = readADC();
                char realTemp = (char)fTemp;
                short fTempLen = itoa(realTemp,(char*)ptr);
                pSlHttpServerResponse->ResponseData.token_value.len += fTempLen;
            }
        }
    }
}

The above is a copy of a combination of demo code, I think the out_of_box demo.  This code in summary is in this order :

Connect to AP,

Start HTTP server,

When event occurs - readADC and update value on webpage.

Is my device faulty or is there a software problem?

Any advice or suggestions I will be willing to try.

Thank you all,

JT

  • Hi Jon,

    We need to try to reproduce this with our SDK example, we will get back to you

    Thanks and Regards,
    Siddaram
  • Hi Siddaram,

    If needed, I can e-mail you my project if that would help.  

    I also wanted to note just now :

    The application ran fine for over 12 hours during debug mode with all accurate ADC readings.  I checked every couple hours to see the behavior.

    I just powered off and switched to battery powered and the my ADC values instantly started acting benign.

    Another thing to consider is these 2AA (they are engergizer) batteries are also powering a 15k resistor and TI LM35 sensor.  Could these components cause voltage drop belong threshold?

    Thanks again,

    JT

  • I just tried accessing the page and the reading was off.  I closed and reopened a few minutes later and it was back to normal. This has never happened.

    Maybe this helps?

    JT

  • JT
    I see that in the battery mode you are powering off a 2xAA energizer battery which will produce a nominal voltage of 3V. While this is OK for the CC3200, the LM35 might just not operate optimally. It requires a minimum of 4V to work. At the start of your testing the batteries may be fresh, so it may work fine but after some time the LM35 will behave strangely. Could you try to use some other temp sensor or an I2C based one like TMP006. Not sure what is your application but the LM35 is not suited for 2xAA application. you could try with 3xAA and then step down the voltage to 3.3V for the CC3200 using an LDO.
  • Hey Prajay,

    I assumed it was something to do with the system being powered by batteries.

    I would use an I2C based sensor but the part I have is already setup for my needs.

    An alternative idea - What if I powered the board off of one of those USB portable power banks?

    JT