|
|
View previous topic :: View next topic |
Author |
Message |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
ADC question |
Posted: Sat Apr 19, 2008 5:22 am |
|
|
Im using a pic 16f877a for and ADC conv and displying it on lcd. using 10 bit and vcc as ref but the 5/1023 res is a bit unaccurate for me. Ibought a 2.5 v ref.
My question is can i just simply connect is to pin 5 ref on pic change code to include a vref and use same calculation as for the vcc vref
adcvalue = adcvalue * 5 /1023
adcvalue = adcvalue * 2.5/1023
Thanks _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
|
Ttelmah Guest
|
|
Posted: Sat Apr 19, 2008 9:46 am |
|
|
Yes.
Except the division should be by 1024!...
The PIC is slightly unusual in this. Normally on most ADC's, the output changes to the top value (1023), about half a level 'below' the top voltage. There are then 1024 'counts', and 1023 'levels' (like the old 'number of fence posts' calculation). The PIC actually changes to the top reading about one bit 'low', so there are still 1024 counts, and 1023 levels, but these cover the range from 0 to 1023/1024th of the Vref voltage source,so the division to give the voltage per step, should use 1024, not 1023. Then (to make it even more complicated....), the transition point at the bottom of the range, is slightly _high_, so that the best approximation to the voltage for a given reading on the PIC, is:
adc_counts*(Vref/1024) + (Vref/2048)
Fun.....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|