I had a project that requires to measure illuminance(lux) using LDR and display the result on LCD. Thanks to some references from Google, I had managed to build a equation that shows relation between Lux and LDR’s resistance which is:
L = 1,48.(10^7).R^(-1,43)
Cause I’m using PIC18F with 10bit of ADC resolution and the reference voltage used is 5v so resolution of ADC module should be 4.88mV. Thus, I can get ADC value stored in ADRESH and ADREL to multiple with ADC resolution for achieving Vadc at the input as well as value of illuminance. So the questions are:
- I found some sources said that the value in ADRESH and ADRESL should be combined to a 16 bit registor by multiplying ADRESH with 256 then add them with ADRESL. But where will the result be stored when all of registers in PIC are 8 bit length?
- Suppose that the first problem was solved, the next one is how to implement the complicated equation above in assembly language. It is too tough for me! :))
- If the first two questions have been handled, an another problem arise when we display the final result on LCD( it’s definitely a float number). How can we do that?
I appologize for asking so many questions in a post but you know, I always think it out before posting anything here and these question did make me headache for days. I will really appreciate for your help.