I am currently doing a mini-project on temperature sensor using 8051 micro-controller. The 8051 micro-controller will receive 8bit temperature data from Analogue-to-Digital Converter which is connected to a temperature sensor(eg. LM35) I have a problem in translating the 8bit data from ADC to a temperature reading (eg. 38 celcius)in keil. I hope to understand the structure or the procedure in carrying out this step. Thank you!
The data sheet http://www.national.com/pf/LM/LM35.html says that the part produces a linear +10 mV per degree C. So, take the voltage measurement from the ADC and divide to get a temperature. You might need to add a constant to account for the "zero" point of the device. Or, to look at it another way, you have an 8-bit ADC, which 8 bits have to cover the whole temperature range. So you could just scale the 0-255 value to the range of temperatures for the LM35. It should be a nice, simple, one-line calculation. What problem are you having, exactly?
Thank you for the overview, I appreciate it. Now I am having a problem on how to convert the incoming 8-bit data from ADC to a temperature reading by using the keil Software. Futhermore, I am using AT89C52 micro-controller. I am aware that 8-bit data would have 256 combination from 0000 0000 to 1111 1111. Each step from 0000 0000 to 0000 0001 contribute to a certain degree C. However, how can i programme to allow the incoming binary to becoming a temperature reading appearing on the keil?
how can i programme to allow the incoming binary to becoming a temperature reading appearing on the keil? How about using an array? For example:
float temp_table [256] = { ... };
"Each step from 0000 0000 to 0000 0001 contribute to a certain degree C." Exactly - so all you need to do is apply the scale factor that relates the 1-bit step to a certain degree C. You may also need to add an offset to account for the Celsius temperature corresonding to the 8-bit binay 0000 0000. Assuming it's linear, it's your good old y = mx + c Note that this has nothing specifically to do with Keil - the principle is the same whatever tools you use, and whatever language, from whatever vendor! Try thinking about how you'd do it by hand!
View all questions in Keil forum