Ask Engineering

How to implement an equation in assembly language using PIC18F and display its result on LCD?

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)

ADC input is voltage divider of LDR( as image showed below)

The equation above could be described by the following equation:

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:

  1. 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?
  2. 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! :))
  3. 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.
Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *