Awesome Darrell!![]()
I plugged in your brilliant code and it works flawlessly!
Is it possible to get 2 decimals of resolution using the 10bit ADC? On a 3 Volt system that drops out a 2.0 Volts it could make a difference.
Awesome Darrell!![]()
I plugged in your brilliant code and it works flawlessly!
Is it possible to get 2 decimals of resolution using the 10bit ADC? On a 3 Volt system that drops out a 2.0 Volts it could make a difference.
"Do or do not, there is no try" Yoda
Well as far as the math goes, you can get 2 decimals by multiplying *500 instead of 50. Then change the SEROUT2 to divide by 100 and use DEC2.
But those references aren't really accurate enough to get that kind of resolution reliably.
And they drift some with temperature, so you'll probably want to stick with 1 decimal place.
You could also do the same thing with an external "Precision" reference and get better resolution. But of course that uses a PIN, which are precious on an 8-pin chip.
DT
Yeah, I though that would work. I tried X500 and got readings that varied by about .05 Volts even when I hit the PIC with a heat gun to see if there would be significant temperature drift. Not bad actually.
This is a totally awesome way to read the battery voltage Darrell. THANKS AGAIN. You are a friggin genius!
"Do or do not, there is no try" Yoda
Can anyone help me with configuring the AD converter in 16F877A on the labX1 board? I am using MicroCode Studio-pbp and i have tried the following code from the help button and from another post i read.
ADCON1=132 ' 128 + 4 = %10000100 'Left just 3 analog inputs rest digital
TrisA = 255 'all inputs for the a to d
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (rc = 3)
Define ADC_SAMPLEUS 50 ' Set sampling time in microseconds
AdcIn 1, W0
AdcIn 3, W1
The error says that ADCIN needs a variable.
My assignment is just to read the AD input from the three potentiometers at A0 A1 and A3.
Pretty lost. Thanks! also, i didnt know how to start a new thread so sorry for posting in ya'lls.
Kay
Big button near the top of forum pages, "+ Post New Thread".didnt know how to start a new thread so sorry for posting in ya'lls.
Dave
Always wear safety glasses while programming.
AdcIn 1, W0
AdcIn 3, W1
The error says that ADCIN needs a variable.
Kay, I'm assuming that you have migrated to the PIC world from Basic Stamps and you may not have defined your variables - something you do not need to do in Stamps. So you need:
W0 var byte
to define W0 as a byte variable - these definitions usually go near the top of the page.
"Do or do not, there is no try" Yoda
For 10-bit A/D you'll want to define W0 & W1 as WORD sized vars...;o)
Bookmarks