Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need help (lm35-->adc0808-->at89s51)

Status
Not open for further replies.

limzhengtong

New Member
Im new to microcontroller and i face some problem in it. Currently, I noe how LM35 detect temperature and send the corresponding temperature to the AT89S51. Since ADC0808 output is 8 bit binary number, what should i do to include decimal point of a temperature?
For example, if LM35 detect 26.4 Celcius, it is ezy to let AT89S51 to read 26 celcius thru ADC0808, but what shud i do to read 26.4 Celcius?
Plz help me....thx...:)
 
hi,
You need to convert the 8 bit binary value into 3 ASCII digits, save the ascii digits in a buffer and then send the ascii MSD to the display, then the next and then a decimal point followed by the LSD.
 
Hi, thx for ur idea. Btw, can u gve me some example? Izit means that the microcontroller will read the data digit by digit? Also, izit i hve to manipulate the source code (im using assembly code)?
Actually i need the microcontroller to read temperature data (for example 26.4 celcius) and then select a speed for fan....
 
hi,
This link is in PIC asm, but may help you solve the problem in the AT

**broken link removed**
 
Do you really need to measure temperature to a fraction of a degree? There is likely to be a wide and partly random variation of temperature (perhaps several degrees) beween one part of the fan environment and another, making such accuracy irrelevant. That variation does mean that positioning the sensor suitably may be of greater importance. Also, any fan speed control will probably need to have some hysteresis (1 degree or so?).
 
Hi,
Thx for the link but currently im learning microcontroller 8051 and i cnt understand PIC asm :'(
Can u provide some idea or code in using 8051? My main problem is:
1.Izit possible that the ADC0808 convert decimal/floating point into binary number?
2.What is the 8 bit binary output of the ADC0808? Izit it include decimal/floating point value e.g. 26.4?
3.If canot, what shud i do to get decimal/floating point in the microcontroller 8051?
I hve been google this few question whole day but found nothing.... Hopefully u can hlp me...Thx in advance :)
 
Do you really need to measure temperature to a fraction of a degree? There is likely to be a wide and partly random variation of temperature (perhaps several degrees) beween one part of the fan environment and another, making such accuracy irrelevant. That variation does mean that positioning the sensor suitably may be of greater importance. Also, any fan speed control will probably need to have some hysteresis (1 degree or so?).

Thx for ur comment. Btw, actually i hve to use microcontroller 8051 to control auto mode fan speed. At the same time, i hve to display current temperature e.g 26.4 Celcius in the LCD. Now, im stuck in conversion of 8 bit binary code to decimal value. Do you hve any idea? :)
 
Thx ericgibbs for ur suggestion. It solve part of my problem. Now, im facing a problem before the conversion in 8051.
As mentioned, im using LM35 to ADC0808 to AT89S51. Now, my design is like follow:
Step Size = (Vref+ - Vref-)/256=(2.56 - 0)/256= 10 mv.
Dout = Vin /step Size.
For example, let Vin=0.253V (which represent 25.3 Celcius in LM35)
Therefore, Dout=0.253V/10mV=25.3 But due to 8 bit binary conversion, it will oni output decimal 25 which is 0001 1001 binary into the 8051 microcontroller.
Thus, what shud i do to get 25.3 instead of 25 in the microcontroller (Because after that i hve to display it on LCD)? Anyone can hlp me? Thx in advance!! :)
 
Thx ericgibbs for ur suggestion. It solve part of my problem. Now, im facing a problem before the conversion in 8051.
As mentioned, im using LM35 to ADC0808 to AT89S51. Now, my design is like follow:
Step Size = (Vref+ - Vref-)/256=(2.56 - 0)/256= 10 mv.
Dout = Vin /step Size.
For example, let Vin=0.253V (which represent 25.3 Celcius in LM35)
Therefore, Dout=0.253V/10mV=25.3 But due to 8 bit binary conversion, it will oni output decimal 25 which is 0001 1001 binary into the 8051 microcontroller.
Thus, what shud i do to get 25.3 instead of 25 in the microcontroller (Because after that i hve to display it on LCD)? Anyone can hlp me? Thx in advance!! :)

hi,
With only 8 bit resolution [0 to 255 states] from the ADC, you have to decide over temperature you wish to measure.
You know that the LM35 outputs 10mV/Cdeg.
Example say the temperature range was 0C thru 50C, this would be an LM35 output of 0V thru 0.5V
For a +Vref of +2.5v, the maximum number of states would be [0.5v/2.5v]* 256 = 51,,, which is 1Cdeg resolution/bit

To increase the resolution you could use a 5Vref and amplify the output of the LM35 by times 10 to give 5V input to the adc
This would give 256 states over the 50C range.

Let me know what is the temperature range and the resolution you require and will help work out the answers.

EDIT:
https://piratebirds.blogspot.com/p/interfacing-adc-0808-with-8051.html
 
Last edited:
Thx ericgibbs!! So izit means that i hve to connect LM35 to op-amp in order to amplify the output voltage? If i wish to set the temperature range from 0-100 Celcius and the resolution is 0.1 Celcius, is that possible to do so? Can you provide an example calculation? Thanks a lot! :)
 
Thx ericgibbs!! So izit means that i hve to connect LM35 to op-amp in order to amplify the output voltage? If i wish to set the temperature range from 0-100 Celcius and the resolution is 0.1 Celcius, is that possible to do so? Can you provide an example calculation? Thanks a lot! :)

hi,
For a tempr range of 100C , with a resolution of 0.1C requires 1000 output states from the ADC, this means at least a 10bit ADC!.
With only 8 bits [ 256 states] for 100.0C means the resolution is only approx 0.4C/bit.
I would set the Vref to give +/-0.5C steps, it will be easier to do the maths ie: 20.0 , 20.5, 21.0 etc ...
 
Thx again ericgibbs!! I think i can understand what u mean...
Izit i shud read the ADC0808 output as follow?
0.0C ---- 0000 0000
0.5C ---- 0000 0001
1.0C ---- 0000 0010
1.5C ---- 0000 0011
till
100.0C ---- 11001000

Can u teach me how to do so? Lets take an example, 26.5C which i shud read ADC0808 output as 0011 0101 (53 decimal). How can i do it using LM35 into ADC0808?
 
Thx again ericgibbs!! I think i can understand what u mean...
Izit i shud read the ADC0808 output as follow?
0.0C ---- 0000 0000
0.5C ---- 0000 0001
1.0C ---- 0000 0010
1.5C ---- 0000 0011
till
100.0C ---- 11001000

Can u teach me how to do so? Lets take an example, 26.5C which i shud read ADC0808 output as 0011 0101 (53 decimal). How can i do it using LM35 into ADC0808?


Well, i hve think an idea. Can gve me some comment? I will connect LM35 to an op amp which multiply the output voltage by 2, then connect to ADC0808.
For example, LM35 will gve out 0.265V for 26.5C. Then i multiply by 2 which get 0.53V. Thru the ADC0808 which hving a step size of 10mV, it will gve out 53 in binary form. Is my idea correct?
 
Well, i hve think an idea. Can gve me some comment? I will connect LM35 to an op amp which multiply the output voltage by 2, then connect to ADC0808.
For example, LM35 will gve out 0.265V for 26.5C. Then i multiply by 2 which get 0.53V. Thru the ADC0808 which hving a step size of 10mV, it will gve out 53 in binary form. Is my idea correct?

hi,
The way would use is this, amplify the LM35 output so that 100Cdeg [1V from the LM35] to say 2.45V, set the Vref to +2.5V.

This would then give and ADC out state of 250decimal for a 2.45Vinput.
The 250decimal would represent 100C, multiply the 250 by 4 [ use two left shifts] so it becomes 1000decimal.
Convert the 1000d [03E8h] to 1000 Ascii in a buffer, output the buffer with the MSD first, then the next two Ascii digits, followed by a decimal point, then the LSD.
This will display 100.0
so for a tempr of 26.5C , LM35 is 0.265V *2.45 = 0.649 to the ADC input, which will give 66 *4 =26.4C

Do you follow OK.?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top