Nope!!yes I think I do
the 1024 is the 10 bit number the ADC reads.
the 500 is the 5 volts integer value. the + 1 ??
1024 is the span of the digital map, 500 is the span of the analogue map and the + 1 is because you never get to 5.00v..
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Nope!!yes I think I do
the 1024 is the 10 bit number the ADC reads.
the 500 is the 5 volts integer value. the + 1 ??
Correct... You do know the maths..If you supply PIC with 5 V and your reference voltage is Vsupply then in case of 10 bit ADC you have 2^10 -1 = 1024 - 1 = 1023 steps for 5 V .
5 V / 1023 = 4.88 mV -> each step of ADC represents 4.88 mV . The resolution of ADC is 4.88 mV .
Therefore x steps of ADC represent x*4.88 mV .
Is this going to be a 20 page or 40 page train wreck? A month or year long wreck?
Mike.
Device = 18F4520
Clock = 20
Include "adc.bas"
Include "Utils.bas"
Include "usart.bas"
Include "convert.bas"
Dim value As Word
#option USART_BRGH = True
Function ADC_value() As Word
result = ADC.Read(0)
End Function
TRISA = %00000001
ADC.SetConfig($0E) // set ADCON1 for AN0 analog, rest digital
SetBaudrate(br9600)
While true
DelayMS(20)
value = ADC_value
USART.Write(DecToStr(value),13,10)
DelayMS(200)
Wend
That's incorrect.You really need a function if you want the whole adc value or you'll end up with just a byte
We are only on page 14
In the actual prototype I am using the interinal osc as I want to keep parts count down.
Changing from internal osc shouldn't affect the ADCvoltages? I only need the voltages....
Have you tried it without using a function I get a mismatch that's all I got say about that now swordfish is not like the best.That's incorrect.
ADC.Read(0) will read AN0 and return a word. All you've done is wrapped the call with the overhead of another function.
For the code you have, the statement 'value = ADC.Read(0)' will work just fine.
If I was going to have several hundred units built then I would have boards assembled using a 44 pin pic instead of a 28 pin. Then the ADC would not be needed.