Hello all,
Firstly i am a complete newbie at all this and i'm doing my best to try to understand this awesome micros functionalities.
I am busy trying to learn how to work with ADC's. I am building a solar lantern and would to monitor the amount of voltage left in my battery when the lantern is in use so that i can turn on a green LED when the battery still has enough energy else turn on a Red LED when the battery energy is low....
My ADC code doesnt seem to be working right in the simulator someone please have a looksy at my code, i have attached the asm file...
->After a bit of exploring the MPLAB sim i managed to find [Debugger>>Stimulus>>new workbook>>Registerinjection(tab)]
The register injection tab allows me to create a .txt stimulus so what i did is:
i created a text file with one line that reads 255 in decimal, i am assuming this should count as a high i.e 5V. However when i look at the values in ADRESH and ADRESL they dont seem to make sense.
I found a formula that states:
Value of [ADRESH / ADRESL] = (Measured Value/Vref)*256 and based on this; the values in ADRESH and ADRESH dont seem valied as the formula doesnt give me a measured value of 5V which should correspond to the 255 in the text file.
>>>Please advice..., i have attached the picture of the ADESH and ADESL values that i got
Thanks.
Firstly i am a complete newbie at all this and i'm doing my best to try to understand this awesome micros functionalities.
I am busy trying to learn how to work with ADC's. I am building a solar lantern and would to monitor the amount of voltage left in my battery when the lantern is in use so that i can turn on a green LED when the battery still has enough energy else turn on a Red LED when the battery energy is low....
My ADC code doesnt seem to be working right in the simulator someone please have a looksy at my code, i have attached the asm file...
->After a bit of exploring the MPLAB sim i managed to find [Debugger>>Stimulus>>new workbook>>Registerinjection(tab)]
The register injection tab allows me to create a .txt stimulus so what i did is:
i created a text file with one line that reads 255 in decimal, i am assuming this should count as a high i.e 5V. However when i look at the values in ADRESH and ADRESL they dont seem to make sense.
I found a formula that states:
Value of [ADRESH / ADRESL] = (Measured Value/Vref)*256 and based on this; the values in ADRESH and ADRESH dont seem valied as the formula doesnt give me a measured value of 5V which should correspond to the 255 in the text file.
>>>Please advice..., i have attached the picture of the ADESH and ADESL values that i got

Thanks.