Understanding ADC ADRESL and ADRESH values (PIC16f690)

Status
Not open for further replies.

Ozwurld

New Member
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.
 

Attachments

  • 16F690TEMP.ASM
    8 KB · Views: 217
Thanks nigel:

 
Hey ozwurld, I'm interested to k ow more about your project, how's it going? Do you have a schematic?
Schematic not as yet, project has taken a nice form... but i decided to ditch the pic and use an arduino. I should have simulations by the time i submit my project report if your interested.
 
Schematic not as yet, project has taken a nice form... but i decided to ditch the pic and use an arduino. I should have simulations by the time i submit my project report if your interested.

Why didn't you code the PIC in C? I should have posted some code for you!! The Arduino is a good development station but you never learn the low level stuff for yourself!
 
Why didn't you code the PIC in C? I should have posted some code for you!! The Arduino is a good development station but you never learn the low level stuff for yourself!

Low level stuff is only about reading the datasheet.. why should someone learn something trivial that he does not even need to know? It is more important to learn how ADC works in general, than learn how to setup some registers in one particular uC.
 
i havent looked at uC as yet, the only reason i decided to go for the arduino is because im on a really tight schedule... i love asm but it can be disheartening at times.
 
i havent looked at uC as yet, the only reason i decided to go for the arduino is because im on a really tight schedule... i love asm but it can be disheartening at times.
The arduino environment is C++!!! That's what I don't understand...
 
There is always the option to use Atmel Studio instead of Arduino IDE.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…