Continue to Site

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.

[51] interfacing lm35 with 8051 using adc0804 to display temp. In 2 seven-segment displays

Status
Not open for further replies.

manjunathreddy036

Newbie level 3
Joined
May 10, 2018
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
39
interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment display

Here I am using the lm35 temperature sensor with 8051 using adc0804 to display 2 digits temperature data in 2 seven segment display.

i coulnot find the error either in the circuit or the source code. can u plz help me out with correction in circuit and code in c language..?

Code:
program:
#include<reg51.h>
#define adcport P1

sbit cs=P3^7;
sbit rd=P3^6;
sbit wr=P3^5;
sbit intr=P3^4;
sbit en1=P3^0;
sbit en2=P3^1;

void conv();
void read();
unsigned char adcvalue;


void main()
{

en1=1;
en2=1;
while (1)
{
conv();
read();

if(P1=0x06)
{P0=0x06;
P2=0x4f;}

if(P1=0x07)
{P0=0x06;
P2=0x66;
}

if(P1=0x08)
{
P0=0x06;
P2=0x6d;}

if(P1=0x09)
{
P0=0x06;
P2=0x07;}

if(P1=0x0a)
{
P0=0x06;
P2=0x6f;}

if(P1=0x0b)
{
P0=0x5b;
P2=0x06;}

if(P1=0x0c)
{
P0=0x5b;
P2=0x4f;}

if(P1=0x0d)
{
P0=0x5b;
P2=0x6d;}

if(P1=0x0e)
{
P0=0x5b;
P2=0x07;}

if(P1=0x0f)
{
P0=0x5b;
P2=0x6f;}

if(P1=0x10)
{
P0=0x4f;
P2=0x3f;}

if(P1=0x11)
{
P0=0x4f;
P2=0x5b;}

if(P1=0x12)
{
P0=0x4f;
P2=0x66;}

if(P1=0x13)
{
P0=0x4f;
P2=0x7d;}

if(P1=0x14)
{
P0=0x4f;
P2=0x7f;}

if(P1=0x15)
{
P0=0x66;
P2=0x3f;}

if(P1=0x16)
{
P0=0x66;
P2=0x5b;}

if(P1=0x17)
{
P0=0x66;
P2=0x66;}

if(P1=0x18)
{
P0=0x66;
P2=0x7d;}

if(P1=0x19)
{
P0=0x66;
P2=0x7f;}

if(P1=0x1a)
{
P0=0x6d;
P2=0x3f;}

if(P1=0x1b)
{
P0=0x6d;
P2=0x5b;}

if(P1=0x1c)
{
P0=0x6d;
P2=0x66;}

if(P1=0x1d)
{
P0=0x6d;
P2=0x7d;}

if(P1=0x1e)
{
P0=0x6d;
P2=0x7f;}

if(P1=0x1f)
{
P0=0x7d;
P2=0x3f;}

}
}

void conv()
{
cs = 0;
wr = 0;
wr = 1; 
cs = 1; 
while (intr); 
}
	 
void read() 
{
cs = 0; //Make CS low
rd = 0; //Make RD low
adcvalue= adcport; //Read ADC port
rd = 1; //Make RD high
cs = 1; //Make CS high
}

the circuit image is attached, plz rectify me the error in circuit and the code.
if the code is wrong plz provide me the correct code to the circuit. IMG-20180601-WA0004.jpg
 
Last edited by a moderator:

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

All 'if' conditions should have ==, not =
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Hi,

you don´t provide an error description, thus we don´t know what´s going wrong. This makes helping difficult.
Please add some documentation to your code.

It seems you didn´t try to do a forum search for your problem.
There are a lot of discussions about C51, ADC0804 and LM35.
Just see the box below "Similar threads"

Klaus
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Hello,


is it a LM35DZ ? 10mV/°C 0 °C -> 0mv 20°C -> 200mV
With 8 bits resolution 256 points for 5000mV
you will get only +-2°C per points

you can use a switch() case function instead of a lot of if

Code:
switch(p1)
{
  case 6 :
    {
       P0=0x06;
       P2=0x4f;
       break;
      }
case 7: 
  {
      P0=0x06; 
      P2=0x66;
      break;
    }
...etc
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Thank you for the response.

sir,

I didn't find the threads related to displaying the measured temperature on the 7 segment display.
The problem is tat whatever the change in temperature in the lm35dz, there is no change in the adc0804 output and the display on the 7 segments. The image which I have attached is same simulated in proteus with the c program.
plz rectify me, where the problem might have occured.
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Thank you for response

sir,

I have tried with the == in if condition, the warnings are cleared but there is no correct display in the 7 segments.
The output at adc0804 is same for all values of the temperature and the display too. What might be the problem ?
I am working on proteus software.
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Hi,

still we don´t have much chance to help, because you didn´t provide useful informations.

Give useful descriptions:
there is no change in the adc0804 output
--> so please tell us what´s the ADC_ouptut.

there is no correct display in the 7 segments.
--> tell us what the display shows.

simulated in proteus
--> If you use a simulator, it should be easy for you to find out where the problem lies:
Just follow the signal flow:
* microcontroller generates the signals for the ADC --> ADC sends back conversion results --> microcontroller reads in conversion results --> microcontroller processes conversion results --> microcontroller generates the display signals --> microcontroller outputs the display signals --> display shows the result.

Work from left to right and check step by step if the values are as expected. (don´t go the the next step until the one before works as desired)
On the first mismatch try to debug it, if you don´t have success in debugging, then give us useful informations (Your debugging test: generated signals, expected signals, wrong signals).

Mind: We can only help you if you give use useful informations.

Klaus
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

I think if you go for some micro controller with built-in adc life will be easy.for example AT89c2051.
many years back I made it for 7-segment display.
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Hi,

True. Or a temperature sensor with digital interface. It will reduce hardware effort significantly...while improving noise, resolution, accuracy..

Klaus
 

Re: interfacing lm35 with 8051 using adc0804 to display temp. in 2 seven segment disp

Just use ICL7106 and there no microcontroller will be needed
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top