6 Replies Latest reply on Aug 17, 2015 12:45 AM by pf2811

    Faster Analog Read

    VictorLexand

      How exactly do I access a faster analog read using the Galileo board despite the I2C expander that is the famous gpio limiter.

      Is it possible to analog read at the kilohertz range?

        • 1. Re: Faster Analog Read

          Hi Victor,

           

          I would like to share some information related to your question, perhaps this will help you.

           

          Some users are testing the I2C functionality  and as you will see in this discussion https://communities.intel.com/message/223020#223020 they have found a method via Linux to run their tests, also here is one of the documents that I would recommend you to verify (from Sergey's blog  programing GPIO from Linux) http://www.malinov.com/Home/sergey-s-blog/intelgalileo-programminggpiofromlinux

           

          Regards.

          • 2. Re: Faster Analog Read
            VictorLexand

            Hi LDiego,

             

            I have not used linux on arduino before but I now have linux installed and operating on arduino.

            From this blog you suggested (Sergey's Blog - Malinov Family Web Presence), I can see that typing once the analog port is connected, the value at A0 can be read with

            root@clanton:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw

            But how fast is continuous read? After the third echo command connects A0 to ADC chip, can I then analog read on arduino the A0 pin at a faster rate? If so, how much faster?

             

            Thank you.

            • 3. Re: Faster Analog Read

              Victor,

               

              It will have the  AnalogRead speed, currently has only one speed and  is about 7 to 8 millisecond,  100 Hz approximately.

               

              Regards,

              LDiego.

              • 4. Re: Faster Analog Read
                pf2811

                I too have been trying to speed up the analogRead function, on Galileo Gen2, to run it in a loop at a rate of 10kHz. Unamended I have achieved a rate of 3.3kHz when running analogRead in a tight loop i.e. it took about 300 microseconds for each read. I experienced a similar reading rate if I adopted the technique of Sergey's blog (mentioned above).

                This suggested to me that the analogRead function and the method of Linux file read are similar. I had a look at the Galileo source code for the Intel released IDE (Intel® Download Center) - needs to be downloaded and unzipped.

                In 'IDE_GPLCompliance.src-1.0.4\IDE_GPLCompliance.src-1.0.4\IDE_GPLCompliance.src.1.0.4\corelibs-galileo-1.6.0\hardware\intel\i586-uclibc\cores\arduino' take a look at analogRead in wiring_analog.c. You can see that the reading of the ADC reading is ultimately using a file accessing mechanism. There is the infamous lseek function to move to to the beginning of a file - this really slows things down!

                It seems that in Galileo the analogRead is not done by reading registers of the ADC directly (as is done on Arduino boards with AVR cores) but by a file access mechanism - no wonder it is slow!

                 

                I would be grateful if anybody has any knowledge on how to access the ADC on Gailleo Gen 2 directly to speed up analogue read, as can be done on other Arduino boards.

                • 5. Re: Faster Analog Read
                  msmithers

                  Is the 3.3 kHz loop only reading 1 input or switching between different inputs?

                   

                  I have an application which reads 6 different inputs at a minimum of 200 Hz each. The Galileo Gen 1 analog IO was a bitter disappointment so I implemented everything on an Arduino Mega and it's running ok right now. But I have to do quite a few of coding tricks for some of the math, and the math would be much easy on the 400 MHz Galileo core.

                  • 6. Re: Faster Analog Read
                    pf2811

                    The 3.3kHz loop is reading only 1 analogue input and using a second analogue input as a digital output to trigger a sensor. Remember this is Galileo Gen 2. As this read rate was inadequate for our application I too have had to switch to a Mega 2560. However I could do so much more if the Galileo was up to it in the read rate issue.