EB003 - ADC ReadAs...

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
dbasnett
Posts: 125
Joined: Mon Aug 15, 2011 1:54 pm
Has thanked: 8 times
Been thanked: 11 times

EB003 - ADC ReadAs...

Post 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?

User avatar
Steve
Matrix Staff
Posts: 3431
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: EB003 - ADC ReadAs...

Post 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.

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: EB003 - ADC ReadAs...

Post 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

User avatar
Steve
Matrix Staff
Posts: 3431
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: EB003 - ADC ReadAs...

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EB003 - ADC ReadAs...

Post 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.

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: EB003 - ADC ReadAs...

Post by Spanish_dude »

Right I meant 12 bits not 10, my bad.

Anyways, thanks for the info :)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EB003 - ADC ReadAs...

Post 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.

Post Reply