Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 20046

Re: Galileo ADC resolution too low?

$
0
0

JPMontero_Intel wrote:

 

Hi Kirasan

 

You can change the resolution of the ADC in the IDE by using the command:

analogReadResolution();

 

I've drafted a test sketch and I got 8bit, 10bit, 12bit and 16bit resolution in the IDE, Take a look at the sketch I hope it helps you to do some testing with the ADC.

int Pin = A0;    // select the input pin for the potentiometer

 

 


void setup() {

  pinMode(Pin, OUTPUT);

  Serial.begin(9600);

}

 

 

 

void loop() {

  analogReadResolution(8);         // 5V => 255

  Serial.print("Res8bit: ");

  Serial.print(analogRead(Pin));

  analogReadResolution(10);        // 5V => 1023

  Serial.print("    Res10bit: ");

  Serial.print(analogRead(Pin)); 

  analogReadResolution(12);        // 5V => 4096

  Serial.print("    Res12bit: ");

  Serial.print(analogRead(Pin)); 

  analogReadResolution(16);        // 5V => 65536

  Serial.print("    Res16bit: ");

  Serial.println(analogRead(Pin));

  delay(1000);        

}

 


Regards,
JPMontero_Intel

I think that this is a bit misleading. As I see it, on my Gen 1 board, the AD7298 is a 12 bit ADC and you can not turn it into a 16 bit ADC simply by analogReadResolution(16) - although that would be nice . The value returned after analogReadResolution(16) simply pads the 12 bit value with zeros. If you change the statements "Serial.print(analogRead(Pin));" to Serial.print(analogRead(Pin), BIN);  you can see that pretty clearly. BUT, what is amazing is that it looks to me like you can use analogReadResolution(12) within a script to get the full resolution of the chip! Am I seeing that accurately, I sure hope so.  In a way, this makes sense if the sketch code takes the raw value (which would be 12 bits) and scaled it down to 10 bits - likely for compatibility.  So setting it lower than the 12 bit resolution, say 8 bits, will give the high 8 bits of the 12 bit value, and setting it higher than 12, say 16 bits, will give you the 12 bit value,  padded with zeros for the lower 4 bits. This makes compatible code easy if the hardware gets upgraded.  Good deal.


Viewing all articles
Browse latest Browse all 20046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>