EB003 - ADC ReadAs...
EB003 - ADC ReadAs...
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?
- 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...
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.
AsVoltage returns a string should you require displaying the value directly.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: EB003 - ADC ReadAs...
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
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
- 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...
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.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).
- 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...
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.
In contrast some devices only have an 8-bit ADC. On these both the ReadAsInt and ReadAsByte return the same 8-bit value.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- 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...
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel