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.

problem in sensing temperature

Other Parts Discussed in Thread: LM3S6965, LM35

Hello Sir/Mam,

I  want to sense the temperature with Lm35.I have purchased the kit EKS LM3S6965.

For this i take guideline from the folder enet_io which is provided as sample program with this kit. it control the LED & PWM through web page(CGI Script).

Now i connect the LM35 TO THE BOARD such that vcc=+5v, o/p to AIDCO pin of board.

For that i make some changed in file io.c& io_cgi file as

io.c file

//*****************************************************************************

 

#include "inc/hw_ints.h"

#include "inc/hw_memmap.h"

#include "inc/hw_pwm.h"

#include "inc/hw_types.h"

#include "driverlib/gpio.h"

#include "driverlib/pwm.h"

#include "driverlib/sysctl.h"

#include "utils/ustdlib.h"

#include "io.h"

#include "driverlib/adc.h"

 

 

 

#define SIZE_VALUEC_BUFFER 32

 

//*****************************************************************************

//

//*****************************************************************************

unsigned long g_ulFrequency;

unsigned long g_ulDutyCycle;

 

//*****************************************************************************

//

// Initialize the IO used in this demo

// 1. STATUS LED on Port F pin 0

// 2. PWM on Port D Pin 1 (PWM1)

//

//*****************************************************************************

void

io_init(void)

{

    unsigned long ulPWMClock;

   

    //

    // Enable GPIO bank F to allow control of the LED.

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

   

      SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

      ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

      ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE |

                             ADC_CTL_END);

 

    //

    // Since sample sequence 3 is now configured, it must be enabled.

    //

    ADCSequenceEnable(ADC0_BASE, 3);

 

    //

    // Clear the interrupt status flag.  This is done to make sure the

    // interrupt flag is cleared before we sample.

    //

    ADCIntClear(ADC0_BASE, 3);

 

    //

    // Configure Port F0 for as an output for the status LED.

    //

    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_0);

 

    //

    // Initialize LED to OFF (0)

    //

    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);

 

    //

    // Enable Port D1 for PWM output.

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    GPIOPinTypePWM(GPIO_PORTD_BASE,GPIO_PIN_1);

 

    //

    // Enable the PWM generator.

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);

 

    //

    // Configure the PWM generator for count down mode with immediate updates

    // to the parameters.

    //

    PWMGenConfigure(PWM_BASE, PWM_GEN_0,

                    PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);

 

    //

    // Divide the PWM clock by 4.

    //

    SysCtlPWMClockSet(SYSCTL_PWMDIV_4);

 

    //

    // Get the PWM clock.

    //

    ulPWMClock = SysCtlClockGet()/4;

 

    //

    // Intialize the PWM frequency and duty cycle.

    //

    g_ulFrequency = 440;

    g_ulDutyCycle = 50;

 

    //

    // Set the period of PWM1.

    //

    //PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulPWMClock / g_ulFrequency);

 

    //

    // Set the pulse width of PWM1.

    //

    PWMPulseWidthSet(PWM_BASE, PWM_OUT_1,

                     ((ulPWMClock * g_ulDutyCycle)/100) / g_ulFrequency);

 

    //

    // Start the timers in generator 0.

    //

    PWMGenEnable(PWM_BASE, PWM_GEN_0);

 

}

 

//*****************************************************************************

//

// Set the status LED on or off.

//

//*****************************************************************************

void

io_set_led(tBoolean bOn)

{

    //

    // Turn the LED on or off as requested.

    //

    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, bOn ? GPIO_PIN_0 : 0);

}

 

//*****************************************************************************

//

// Turn PWM on/off

//

//*****************************************************************************

void

io_set_pwm(tBoolean bOn)

{

    //

    // Enable or disable the PWM1 output.

    //

    PWMOutputState(PWM_BASE, PWM_OUT_1_BIT, bOn);

}

 

//*****************************************************************************

//

// Set PWM Frequency

//

//*****************************************************************************

/*void

io_pwm_freq(unsigned long ulFreq)

{

    unsigned long ulPWMClock;

 

    //

    // Get the PWM clock

    //

    ulPWMClock = SysCtlClockGet()/4;

 

    //

    // Set the global frequency

    //

    g_ulFrequency = ulFreq;

 

    //

    // Set the period.

    //

    PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulPWMClock / g_ulFrequency);

 

    //

    // Set the pulse width of PWM1

    //

    PWMPulseWidthSet(PWM_BASE, PWM_OUT_1,

                     ((ulPWMClock * g_ulDutyCycle)/100) / g_ulFrequency);

 

}

*/

//*****************************************************************************

//

// Set PWM Duty Cycle

//

//*****************************************************************************

void

io_pwm_dutycycle(unsigned long ulDutyCycle)

{

    unsigned long ulPWMClock;

 

    //

    // Get the PWM clock

    //

    ulPWMClock = SysCtlClockGet()/4;

 

    //

    // Set the global duty cycle

    //

    g_ulDutyCycle = ulDutyCycle;

 

    //

    // Set the period.

    //

    PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulPWMClock / g_ulFrequency);

 

    //

    // Set the pulse width of PWM1

    //

    PWMPulseWidthSet(PWM_BASE, PWM_OUT_1,

                     ((ulPWMClock * g_ulDutyCycle)/100) / g_ulFrequency);

 

}

 

//*****************************************************************************

//

// Return LED state

//

//*****************************************************************************

void

io_get_ledstate(char * pcBuf, int iBufLen)

{

    //

    // Get the state of the LED

    //

    if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0))

    {

        usnprintf(pcBuf, iBufLen, "ON");

    }

    else

    {

        usnprintf(pcBuf, iBufLen, "OFF");

    }

 

}

 

//*****************************************************************************

//

// Return LED state as an integer, 1 on, 0 off.

//

//*****************************************************************************

int

io_is_led_on(void)

{

    //

    // Get the state of the LED

    //

    if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0))

    {

        return(1);

    }

    else

    {

        return(0);

    }

}

 

void io_get_temp()

{

char pcValueC[SIZE_VALUEC_BUFFER];

 

   // RIT128x96x4Init(1000000);

 

 

   unsigned long ulADC0_Value[1];

 

    //

    // These variables are used to store the temperature conversions for

    // Celsius and Fahrenheit.

    //

    unsigned long ulTemp_ValueC;

   // unsigned long ulTemp_ValueF;

 

 

    //

    // Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL.  When

    // using the ADC, you must either use the PLL or supply a 16 MHz clock

    // source.

    // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the

    // crystal on your board.

    //

   // SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |

                 //  SYSCTL_XTAL_8MHZ);

 

 

 

    //

    // The ADC0 peripheral must be enabled for use.

    //

   

   // SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

 

    //

    // Enable sample sequence 3 with a processor signal trigger.  Sequence 3

    // will do a single sample when the processor sends a singal to start the

    // conversion.  Each ADC module has 4 programmable sequences, sequence 0

    // to sequence 3.  This example is arbitrarily using sequence 3.

    //

   

   // ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

 

    //

    // Configure step 0 on sequence 3.  Sample the temperature sensor

    // (ADC_CTL_TS) and configure the interrupt flag (ADC_CTL_IE) to be set

    // when the sample is done.  Tell the ADC logic that this is the last

    // conversion on sequence 3 (ADC_CTL_END).  Sequence 3 has only one

    // programmable step.  Sequence 1 and 2 have 4 steps, and sequence 0 has

    // 8 programmable steps.  Since we are only doing a single conversion using

    // sequence 3 we will only configure step 0.  For more information on the

    // ADC sequences and steps, reference the datasheet.

    //

   

   /* ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE |

                             ADC_CTL_END);

 

    //

    // Since sample sequence 3 is now configured, it must be enabled.

    //

    ADCSequenceEnable(ADC0_BASE, 3);

 

    //

    // Clear the interrupt status flag.  This is done to make sure the

    // interrupt flag is cleared before we sample.

    //

    ADCIntClear(ADC0_BASE, 3);*/

 

    //

    // Sample the temperature sensor forever.  Display the value on the

    // console.

    //

  //  while(1)

  //  {

        //

        // Trigger the ADC conversion.

        //

        ADCProcessorTrigger(ADC0_BASE, 3);

 

        //

        // Wait for conversion to be completed.

        //

        while(!ADCIntStatus(ADC0_BASE, 3, false))

        {

        }

 

        //

        // Read ADC Value.

        //

        ADCSequenceDataGet(ADC0_BASE, 3, ulADC0_Value);

 

        //

        // Use non-calibrated conversion provided in the data sheet.  Make

        // sure you divide last to avoid dropout.

        //

       

       

      ulTemp_ValueC = ((1475 * 1023) - (2250 * ulADC0_Value[0])) / 10230;

      

       //usnprintf(pcValueC,SIZE_VALUEC_BUFFER,"%d",ulTemp_ValueC);

      usnprintf(pcValueC,SIZE_VALUEC_BUFFER,ulTemp_ValueC);

                  

      //RIT128x96x4StringDraw(pcValueC,10, 24, 15);

      //if(pcValueC<=24)

      // RIT128x96x4StringDraw("TURN OFF THE FAN!", 10, 44, 15);

      //else if((pcValueC>=25) &&(pcValueC<=35))

      //RIT128x96x4StringDraw("MEDIUM SPEED FOR FAN!", 10, 44, 15);

      //else

      //RIT128x96x4StringDraw("HIGH SPEED FOR FAN!", 10, 44, 15);

 

        //

        // This function provides a means of generating a constant length

        // delay.  The function delay (in cycles) = 3 * parameter.  Delay

        // 250ms arbitrarily.

        //

        SysCtlDelay(SysCtlClockGet() / 12);

    }

 

//*****************************************************************************

//

// Return PWM state

//

//*****************************************************************************

void

io_get_pwmstate(char * pcBuf, int iBufLen)

{

    //

    // Get the state of the PWM1

    //

    if(HWREG(PWM_BASE + PWM_O_ENABLE) & PWM_OUT_1_BIT)

    {

        usnprintf(pcBuf, iBufLen, "ON");

    }

    else

    {

        usnprintf(pcBuf, iBufLen, "OFF");

    }

 

}

 

//*****************************************************************************

//

// Return PWM state as an integer, 1 on, 0 off.

//

//*****************************************************************************

int

io_is_pwm_on(void)

{

    //

    // Get the state of the PWM1

    //

    if(HWREG(PWM_BASE + PWM_O_ENABLE) & PWM_OUT_1_BIT)

    {

        return(1);

    }

    else

    {

        return(0);

    }

}

 

//*****************************************************************************

//

// Return PWM frequency

//

//*****************************************************************************

/*unsigned long

io_get_pwmfreq(void)

{

    //

    // Return PWM frequency

    //

    return g_ulFrequency;

 

}

*/

//*****************************************************************************

//

// Return PWM duty cycle

//

//*****************************************************************************

unsigned long

io_get_pwmdutycycle(void)

{

    //

    // Return PWM duty cycle

    //

    return g_ulDutyCycle;

 

}

 

Io_cgi.shtml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><head>

<meta content="text/html;charset=ISO-8869-1" http-equiv="content-type"><title>I/O Control Demo 2</title>

 

<script type="text/javascript">

<!--

function SetFormDefaults()

{

document.iocontrol.LEDOn.checked = ls;

document.iocontrol.TEMPSense.value=ts;

document.iocontrol.PWMOn.checked = ps;

document.iocontrol.PWMFrequency.value = pf;

document.iocontrol.PWMDutyCycle.value = pd;

}

//-->

</script>

<style type="text/css">

body

{

font-family: Arial;

background-color: white;

margin: 10px;

padding: 0px

}

h1

{

color: #7C7369;

font-family: Arial;

font-size: 24pt;

font-style: italic;

}

h2

{

color: #000000;

font-family: Arial;

font-size: 18pt;

font-style: bold;

}

h3

{

color: #7C7369;

font-family: Arial;

font-size: 12pt;

font-style: bold;

}

    .style1

    {

        width: 4%;

    }

    .style2

    {

        width: 359px;

    }

    .style3

    {

        width: 241px;

    }

    .style4

    {

        width: 339px;

    }

    .style5

    {

        width: 875px;

        height: 171px;

    }

</style>

</head>

<body onload="SetFormDefaults()">

<!-- Copyright (c) 2009-2010 Texas Instruments Incorporated.  All rights reserved. --><!--#FormVars-->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td align="left"  valign="center">

 

</td>

<td align="center" valign="center">

<h1>CGI Demo</h1>

</td>

</tr>

</table>

<table width="100%">

<tbody>

<tr>

<td align="left" valign="top" class="style1">

<br>

 

</td>

<td align="left" valign="top" width="75%">

<center>

<h2 align="center"></h2>

</center>

<hr size="2" width="100%">

<ul>

</ul>

 

<table align="center" border="1" width="80%">

<tbody>

<tr>

<td class="style5">

<form method="get" action="iocontrol.cgi" name="iocontrol">

<table align="center" border="0" cellpadding="2" cellspacing="2"

    style="width: 105%">

<tbody>

<tr>

<td align="left" valign="top" class="style2"><b>Control</b></td>

<td align="center" valign="top" class="style3"><b>Current</b></td>

<td align="center" valign="top" class="style4"><b>New</b></td>

</tr>

<tr>

<td align="left" valign="top" class="style2">LED

State</td>

<td align="center" valign="top" class="style3"><!--#LEDtxt--></td>

<td align="center" valign="top" class="style4"><input name="LEDOn" value="1" type="checkbox"></td>

</tr>

 

<tr>

<td align="left" valign="top" class="style2">Temperature(Degree Celcius)

</td>

<td align="center" valign="top" class="style3"><!--#TEMPSen--></td>

<td align="center" valign="top" class="style4"><input maxlength="4" size="4" name="TEMPSense" value=" "></td>

</tr>

<tr>

<td align="left" valign="top" class="style2">PWM

State</td>

<td align="center" valign="top" class="style3"><!--#PWMtxt--></td>

<td align="center" valign="top" class="style4"><input name="PWMOn" value="1" type="checkbox"></td>

</tr>

<tr>

<td align="left" valign="top" class="style2">PWM

Duty Cycle (%)</td>

<td align="center" valign="top" class="style3"><!--#PWMduty--></td>

<td align="center" valign="top" class="style4"><input maxlength="3" size="3" name="PWMDutyCycle" value=""></td>

</tr>

<tr>

<td colspan="3" rowspan="1" align="center" valign="middle">

<input name="Update" value="Update Settings" type="submit"></td>

</tr>

</tbody>

</table>

</form>

</td>

</tr>

</tbody>

</table>

<ul>

</ul>

<br>

 

<br>

</td>

</tr>

</tbody>

</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tbody>

<tr>

<td align="right" valign="center">

<h1><br>

</h1>

</td>

<td align="right" valign="center">

<h3></h3>

</td>

</tr>

</tbody>

</table>

</body></html>

After building, debug it give following page in which temp value is not display.it give the o/p as

Temperature (degree celcius)        ***Unknown tag TEMPSen***

with the correct o/p for LED & PWM .

What is solution for that ? I think i have done any mistake while sending temp. to web page.

Thank You in advance

Waiting  for replay.