Page 1 of 1

EB003 - ADC ReadAs...

Posted: Thu Sep 15, 2011 1:48 pm
by dbasnett
What are the advantages / disadvantages of using the different versions of the ADC component ReadAs. I am currently only using the LDR and POT on board the EB003 and using the ReadAsByte. I am curious if I should be using AsInt or AsVoltage and what the difference, other than data type, is?

Re: EB003 - ADC ReadAs...

Posted: Thu Sep 15, 2011 1:54 pm
by Steve
AsInt provides a better level of accuracy if you need it. But in a lot of applications a byte return is more than sufficient.

AsVoltage returns a string should you require displaying the value directly.

Re: EB003 - ADC ReadAs...

Posted: Thu Sep 15, 2011 3:27 pm
by Spanish_dude
Hi,

ReadAsInt uses the 10 bit mode ADC and ReadAsByte make use of the 8bit mode of the ADC (correct me if I'm wrong).

ReadAsInt:
- disadvantages : I'd say you'll need to use an integer (= 2 bytes) to save the ADC value
- advantages : I'd say it's more accurate

ReadAsByte:
- the opposite of ReadAsInt

Nicolas

Re: EB003 - ADC ReadAs...

Posted: Thu Sep 15, 2011 3:44 pm
by Steve
Spanish_dude wrote:ReadAsInt uses the 10 bit mode ADC and ReadAsByte make use of the 8bit mode of the ADC (correct me if I'm wrong).
Not quite. In Flowcode, the ADC always performs the full conversion. The "ReadAsByte" simply returns the top 8 bits of the result. "ReadAsByte" is probably a tiny bit quicker, but only because it is working with an INT datatype rather than a BYTE.

Re: EB003 - ADC ReadAs...

Posted: Thu Sep 15, 2011 4:19 pm
by Benj
Some devices have 12-bit ADC. On these the ReadAsInt will return the 12-bit result.

In contrast some devices only have an 8-bit ADC. On these both the ReadAsInt and ReadAsByte return the same 8-bit value.

Re: EB003 - ADC ReadAs...

Posted: Thu Sep 15, 2011 11:16 pm
by Spanish_dude
Right I meant 12 bits not 10, my bad.

Anyways, thanks for the info :)

Re: EB003 - ADC ReadAs...

Posted: Fri Sep 16, 2011 9:58 am
by Benj
Hello Nicolas,

No your right most devices have the 10-bit ADC. I was just detailing the other weird and wonderful less common devices with 12-bit and 8-bit.