Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ADC and LM35 temperature sensor

Status
Not open for further replies.

gozilaz88

Newbie level 3
Joined
Feb 7, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
I doing a small project, i am newbie with programming. I need my temperature sensor to give me an output in the range of temperature 30 to 40 degree. when the temperature sense this certain level of temperature, it will trigger my dc motor, how do i write this programming using ASM.
 

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,165
Helped
161
Reputation
396
Reaction score
191
Trophy points
1,353
Location
India
Activity points
10,575
If You want to do this in C...Language
Then post here..

I will give you my Code to Read the Temperature from Temperature Sensor.. and then u can modify your code..

Only if you want to do this in C Language...
And Don't worry..

Someone Other will help u in assembly..

Which Controller are u using
 

gozilaz88

Newbie level 3
Joined
Feb 7, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
If You want to do this in C...Language
Then post here..

I will give you my Code to Read the Temperature from Temperature Sensor.. and then u can modify your code..

Only if you want to do this in C Language...
And Don't worry..

Someone Other will help u in assembly..

Which Controller are u using



---------- Post added at 00:22 ---------- Previous post was at 00:21 ----------

If You want to do this in C...Language
Then post here..

I will give you my Code to Read the Temperature from Temperature Sensor.. and then u can modify your code..

Only if you want to do this in C Language...
And Don't worry..

Someone Other will help u in assembly..

Which Controller are u using

Thanks for your resources, between i using pic 16f84a
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,420
between i using pic 16f84a

The LM35 is an analog device which outputs a voltage proportional to the sensed temperature, however the PIC16F84A does not have the ADC module required to interface with the LM35.

You will either need to use an external ADC device or select a different PIC for your design with an ADC module.

BigDog
 

gozilaz88

Newbie level 3
Joined
Feb 7, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
The LM35 is an analog device which outputs a voltage proportional to the sensed temperature, however the PIC16F84A does not have the ADC module required to interface with the LM35.

You will either need to use an external ADC device or select a different PIC for your design with an ADC module.

BigDog

i will be using an external ADC device, the point is how the programming works if i need to get a digital output. For example: if the temperature in the range of 30 to 40 degree, will give a digital signal "1", goes "high". If not will give digital signal of "0", LOW"
 

gozilaz88

Newbie level 3
Joined
Feb 7, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
Why not change PIC16F84A to PIC that have ADC Module. Not costly.
This example read LM35.

I planning to change a pic which have ADC module, but the main things how do i write the programming in order to get my requirement.
 

jackrude

Newbie level 6
Joined
Mar 22, 2012
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
United State
Activity points
1,374
Hello there, I am doing about similar project in C language with LM35, ADC0804, so wondering can you email me the code or post in here, thank you very much
 
Last edited:

jackrude

Newbie level 6
Joined
Mar 22, 2012
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
United State
Activity points
1,374
If You want to do this in C...Language
Then post here..

I will give you my Code to Read the Temperature from Temperature Sensor.. and then u can modify your code..

Only if you want to do this in C Language...
And Don't worry..

Someone Other will help u in assembly..

Which Controller are u using

hey there, wondering can u email me the code of C language, I am doing a similar project with LM35, At89s51, and ADC0804.
Thank you
 

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,165
Helped
161
Reputation
396
Reaction score
191
Trophy points
1,353
Location
India
Activity points
10,575
Hello!!
Have a look at this link....

https://sites.google.com/site/coolembeddedlaboratory/home/atmega-8/adc-interfacing
It will help you...

---------- Post added at 07:18 ---------- Previous post was at 07:14 ----------

Code:
#include <REGX51.H>
#include<stdio.h>
#include<string.h>

sbit INTR = P3^5;
sbit RD_ADC = P2^4;
sbit WR_ADC = P2^3;
sfr MYDATA = 0x80;        //Port-0
sfr LcdData = 0x90;        //Port-1
sbit RS =  P2^5;
sbit RW =  P2^6;
sbit EN =  P2^7;
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void lcdstr(unsigned char msg[]);
void Delay(unsigned int itime);
void SerTX(unsigned char x);
void SerTX_str(unsigned char msg[]);
unsigned char msg[] = "TEMPERATURE --->";
void main()
{
    unsigned int temp;
    int hundreds,tens,ones;
    unsigned char buffer[10];
    TMOD = 0x20;    //Timer-1, 8-Bit Auto Reload Mode
    TH1 = 0xFD;        //9600 Baud Rate When Crystal Used is 11.0592MHZ
    SCON = 0x50;
    TR1 = 1;        //Start Timer
    MYDATA = 0xFF;    //Making P1 as Input Port
    INTR = 1;
    RD_ADC = 1;        //Set RD high
    WR_ADC = 1;        //Set WR high
    lcdcmd(0x38);
    Delay(1);
    lcdcmd(0x0E);
    Delay(1);
    lcdcmd(0x01);
    Delay(1);
    lcdcmd(0x80);
    lcdstr("Temperature");
    lcdcmd(0x0C);
    while(1)
    {     
        lcdcmd(0xC0);                                                               
        WR_ADC = 0;        //Send WR Pulse
        Delay(1);
        WR_ADC = 1;        //Low-High Pulse means Start of Conversion
        while(INTR == 1);    //Wait until End of Conversion
        //When Conversion Gets Completed the INTR Pin Goes Low we get out of the Loop
        RD_ADC = 0;        //Send RD Pulse
        temp = MYDATA/2; 
        //Conversion Process Starts Here       
            ones = temp%10;
            temp = temp/10;
            tens = temp%10;
            hundreds = temp/10;
            ones = 0x30 | ones;
            tens = 0x30 | tens;
            hundreds = 0x30 | hundreds;
            lcddata(hundreds);
            lcddata(tens);
            lcddata(ones);
            SerTX_str(msg);
            SerTX(hundreds);
            SerTX(tens);
            SerTX(ones);
            SerTX(13);
            SerTX(13);
            Delay(10);
            Delay(10);
            RD_ADC = 1;
    }
}
void lcdcmd(unsigned char value)
{
    LcdData = value;
    RS = 0;
    RW = 0;
    EN = 1;
    Delay(1);
    EN = 0;
}
void lcddata(unsigned char value)
{
    LcdData = value;
    RS = 1;
    RW = 0;
    EN = 1;
    Delay(1);
    EN = 0;
}
void Delay(unsigned int itime)
{
    unsigned int i,j;
    for(i=0;i<1275;i++)
    for(j=0;j<itime;j++);
}
void lcdstr(unsigned char msg[])
{
    unsigned short int len,i;
    len = strlen(msg);
    for(i=0;i<len;i++)
    {
        lcddata(msg[i]);
        Delay(1);
    }
}
void SerTX(unsigned char x)
{
    SBUF = x;
    while(TI == 0);
    TI = 0;
}
void SerTX_str(unsigned char msg[])
{
    unsigned short len,i;
    len = strlen(msg);
    for(i=0;i<len;i++)
    {   
        SerTX(msg[i]);
    }
}

Hope this works.. i haven't tested this code..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top