Page 1 of 1

ADC ?

Posted: Mon Oct 22, 2007 12:36 pm
by Ondra
lam working with the ADC component. I have a device that is out-putting
.460mv as read by my multimeter. When I program the PIC to sample, read and then output, the value out of the RS232 port what I get is the number 23. What should I be seeing and why am I not getting the value as measured with my multimeter.

Thanks in advance

Posted: Mon Oct 22, 2007 1:31 pm
by Sean
Hello Ondra,

When you read the ADC value as a byte (8-bit conversion), the converter divides the reference voltage (5v) by 256, giving a resolution of approximately 20mV (19.53mV). The value returned by the component is the input voltage divided by the resolution (460mV / 20mV = 23).

If you read the ADC value as an integer (10-bit conversion), the converter divides the reference voltage by 1024, giving a resolution of approximately 4.9mV

In your example, if you multiply the ADC component return value by 20(mV), the result will be the value in milliVolts, correct to approximately 2.5%.

If you multiply the ADC result by 5000 (the reference voltage in milliVolts) and divide by 256, your answer will have the full accuracy of the ADC (0.4%). Unfortunately, the intermediate result of this calculation would be too large for an integer value (65535 max.), but multiplication by 625 and division by 32 gives the same result, without the danger of overflow for ADC values lower than 104.

Posted: Mon Oct 22, 2007 1:39 pm
by Ondra
Thanks Sean

Posted: Fri Nov 09, 2007 11:31 am
by echase
I am using the A/D reading into a Byte variable (8bit). So are you saying that if I change that variable to an Integer in Flowcode it automatically changes the input to 10 bit without any other Flowcode changes?

Excellent if it does as I was avoiding 10 bit inputs as I thought it was too complicated to set up, like have to read 2 Bytes for upper and lower bits of the reading and combining them. Can’t remember the help files covering 10 bit inputs.

Posted: Fri Nov 09, 2007 11:57 am
by Benj
Hello

To get the full 10 bit ADC value you must use the ReadAsInt function instead of the ReadAsByte function. You must also use an Int variable. This will load all 10 bits into the variable without any other messing around.

Posted: Fri Nov 09, 2007 12:14 pm
by Sean
Hello,

Reading a 10-bit A/D conversion is as easy as reading an 8-bit conversion. The double register read, bit shifting and integer assembly is all handled by Flowcode. The variable receiving the conversion value must be declared as an integer and will be set to a value between 0 and 1023.

There is no connection between the variable declaration and A/D conversion resolution. An integer variable can be used to receive either a byte or integer conversion. The only option to be avoided is reading an integer conversion into a byte variable.