akem90
Junior Member level 1
- Joined
- Apr 14, 2010
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Malaysia
- Activity points
- 1,374
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I am also using a LM35 as a temperature sensor. It has the great property of linearity. Just to echo what cl10greg has said, set up the ADC IAW your data sheet then save the readings for manipulation. For me each bit of the concatinated ADRESH/ADRESL (2*8bit registers combined to make 10 bits - left or right justified) register equals 4.88mV. So if I read a temperature of 35 degress Celsius thats an LM35 output of .35V. with the resolution at 4.88mV.
.35/4.88m = 72 (approx). If you then multiply that by 49 you get 3528. You can then display the 2 msb which alleviates having to deal with float values. Giving you an output of 35. Of course you may encounter quantisation error but it can only affect your readings by 0.5 degree.
You can of course use an op-amp to amplify the readings before you ADC them, but be careful on your op-amp choice. You don't want to go near the rail voltage and ruin the linearity.
Of course it is. Here is a link for the datasheet, look at page 111 http://www.futurebots.com/16f877.pdf
I will give you a run down of the steps and we can go from there.
1.) Setup analog read ports for the LM35DZ before the main loop
-> ADCON1 register (Select the result format and the reference voltages)
-> ADCON0 register (Select clock speed, select channel, turn on A/D)
2.) Configure the interrupt if you want to use that
3.) Main loop
->Set the Go/Done bit
->Wait for the bit to be cleared
->Your result is in the ADRESH and ADRESL registers
->Map your LED matrix to ports and print the numbers
->Add wait delay before next acquistion