1 2 Previous Next 20 Replies Latest reply on Oct 5, 2015 11:15 AM by mmario

    Galileo ADC resolution too low?

    Kirasan

      The Intel Galileo user's manual states: "Each one of the 6 analog input pins provides 12 bits of resolution (that is, 4096 different values). By default, they measure from ground to 5 volts."

       

      However, when I input a 5V signal into the A0 pin, I consistently get 1023 as a reading, instead of 4095.

      Is anyone else experiencing this issue, that is, 10 bit ADC resolution instead of the promised 12 bits?

       

        • 1. Re: Galileo ADC resolution too low?
          SpiderKenny

          On My Galileo

          From Linux, not Arduino, if I read from A0, I get 4095 for +5V

           

          I do this by first set the MUX for A0 to 0, the MUX is on GPIO37:

          cd /sys/class/gpio

          echo -n "37" >export

          cd gpio37

          echo -n "out" >direction

          echo -n "0" >value

          The reading from the ADC:

          cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw

           

          I can't check from Arduino at the moment.

          • 2. Re: Galileo ADC resolution too low?
            flummer

            Hi Kirasan,

             

            I'm guessing that the libraries in the Arduino environment is scaling it down to 10 bit to make it easier to use existing code for Arduino without too many changes.

             

            There is probably a way to access the full resolution like SpiderKenny is doing from Linux

             

            /Thomas

            • 3. Re: Galileo ADC resolution too low?
              JPMontero_Intel

              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

              • 4. Re: Galileo ADC resolution too low?
                Kirasan

                Amazing! I guess should learn how to setup Linux, but for now the ability to use the Arduino IDE makes this a quick fix

                • 5. Re: Galileo ADC resolution too low?
                  RGee

                  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.

                  • 6. Re: Galileo ADC resolution too low?
                    pulled_pork

                    Hi,

                    I ran the test code for the ADC resolution; while the analogReadResolution(12) gave values ranging from 0 to 4096, the numbers were all spaced by 4 on my G2. In other words, if I set the input signal at 2.5 volt, I get something like 2048, but when I tweaked the output by a little, the number jumped to 2052, 2056... no 2049, 2050 and so on. This tells me that I am still working with a 10-bit data depth, not the 12-bit AD7298 is supposed to offer. Am I missing something? Thanks.

                    • 7. Re: Galileo ADC resolution too low?
                      pulled_pork

                      Hi,

                      Here is what I meant in my last posting about the ADC resolution. I hope someone would point out what I did wrong... Thanks.ADC-Resolution.png

                      • 8. Re: Galileo ADC resolution too low?
                        RGee

                        Not sure you are doing anything wrong. As I mentioned in my post, on my Generation 1 and 1.53, using analogReadResolution(12) inside of script gives me the full 12 bit resolution of the A2D. I have tested this out using a variety of sensors and am absolutely convinced that is the case. If you don't set it at 12 bits, you get the default of 10 bits...and, as I wrote in my previous post, setting it to 16 bits does not get you true 16 bit resolution but will pad the 4 lsb bits with 0s.

                         

                        Change the code to Serial.print(analogRead(Pin), BIN); makes it easy to see this. The screen shot below was taken a few minutes ago after connecting +5 to A0.

                        ANREScap1.jpg

                         

                        Looks like you are getting 10 bit resolution and 0 padding for the unused bits. Could this be a Gen 1 / Gen 2 difference? I don't know, sorry.

                        • 9. Re: Galileo ADC resolution too low?
                          pulled_pork

                          RGee:

                           

                          Thanks for your comments. From the BIN display (attached) it is very clear that at this point the Galileo 2 is only giving me 10-bit of real ADC resolution. It is possible that there is a glitch in the way the ADC functionality is implemented in the Adruino IDE 1.5.3. The G2 unit as tested here is using the latest FW  (ver 1.0.3) as of Sept, 2014.

                           

                          One more (perhaps related) observation: While G2 comes with 12-bit DAC output, the Adruino forum mentioned that one needs to use the command  analogWriteResolution()  to set it to 12-bit (based on Adruino Due). But when I tried that command on my G2, an error message occurred saying the command is not supported. After some digging, I found the writeup at EmutexLabs     saying one needs to insert a few lines into the AnalogIO.h file before that command would work. After I did that the  analogWriteResolution()  command works now. I wonder if similar issue exists for the ADC  analogReadResolution() command but not showing up during compile?


                          What is the DAC resolution for G1? I picked G2 because it is supposed to give me 12-bit for both ADC and DAC. But now that the ADC is limited to 10-bit, G1 looks pretty good now.... Thanks


                          Regards,ADC-Resolution-BIN.png

                          P_P

                          • 10. Re: Galileo ADC resolution too low?
                            pulled_pork

                            Hello,

                             

                            I'd appreciate if you could confirm this: I think I might have found the answer to the ADC resolution mystery: the Gen2 Galileo uses TI ADC108S102 as its ADC chip, which is a 10-bit, 8-channel chip. In contrast, the Gen1 Galileo uses the AD7298 chip, a 12-bit ADC unit. This explains why I am seeing only 10 bits of resolution on the G2 while RGee got 12 bits from his G1 tests. This is really a major disappointment for me because both the input and output for my applications both need 11 to 12 bits of resolution but the G2 is shortchanged by the 10-bit ADC chip. Is there a good (safe) way to add the TI ADC128S102 (the 12-bit version of the current chip) to the G2 board? Thanks !

                             

                            Regards,

                            P_P

                            • 11. Re: Galileo ADC resolution too low?
                              JPMontero_Intel

                              Hi,

                               

                              Rgee you are right, the resolution is up to 12 bits on the Galileo board that is why it’s showing the zeroes in the 16bit resolution, thank you for feedback.

                               

                              Pulled_pork I did this test with the Gen2 board and I got your same results. Let me think if I can figure out a workaround for this.

                               

                              Regards,
                              JPMontero_Intel

                              • 12. Re: Galileo ADC resolution too low?
                                pulled_pork

                                JPMontero_Intel:

                                 

                                Thanks. I just ordered a couple of G1.Y to try, they should be here in a few days. All things being equal, I think G2's 12-bit PWM output feature is great once I get it to work, but if its ADC is limited to 10-bit, we might have better luck with G1.Y for our current projects. By the way, I looked at the datasheets fro both TI ADC108S102 and ADC128S102, their architecture is identical.... Thanks.

                                 

                                Regards,

                                P_P

                                • 13. Re: Galileo ADC resolution too low?
                                  pulled_pork

                                  JPMontero_Intel:

                                   

                                  The G1.Y units arrived. They both show true 12-bit ADC resolution as others have seen. However their PWM output resolution is not very good, I see a resolution of about 80mV regardless of the analogWriteResolutuon() setting, i.e. using 10-bit res, the voltage only jumped one step (of 80mV) every 15, 16 counts is added. This effectively puts the PWM resolution at about 6-bit, or about 60 levels of output between 0 and 4.8 V. Any insight on improving G2's ADC resolution? Thanks.

                                   

                                  Regards,

                                  P_P

                                  • 14. Re: Galileo ADC resolution too low?
                                    JPMontero_Intel

                                    Hi pulled_pork,

                                     

                                    I've checked the information and it appears to be this way: Intel Galileo has a 12-bit ADC (AD7298) and the Intel Galileo Gen 2 has a 10-bit ADC (ADC108S102). The improvement on the Intel Galileo Gen2 is in the PWM to 12-bits resolution, not the ADC.

                                     

                                    Regards,
                                      JPMontero_Intel

                                    1 2 Previous Next