6 Replies Latest reply on Sep 26, 2015 12:48 AM by Sriranjan

    Edison Arduino board: ADC sampling rate

    FlavioM

      Hi everyone,

      I have checked several posts but I have not found an answer to my question: is it possible to set the ADC sampling rate through mraa library? I have an analog signal on A0 port and I would set up the sampling rate at 1KHz.

       

      Thanks,

      Flavio

        • 1. Re: Edison Arduino board: ADC sampling rate
          mhahn

          with a non real-time system running I guess you won't be able to sample at an accurate sample rate. But with "for (true) {read; usleep(<=1000)}" you might come close.

          My bet

          • 2. Re: Edison Arduino board: ADC sampling rate
            FlavioM

            Yes, it's true

            Thanks

            Flavio

            • 3. Re: Edison Arduino board: ADC sampling rate
              FlavioM

              I have done several experiments and I have looked some docs in order to find a solution to my problem.

               

              First, I have written a benchmark that infers the mean frequency of the read function (at OS level that it is not real-time). My timestamps seem to indicate about 5KHz. The benchmark was written in Python.

               

              Second, I have used the sleep function but the mean frequency is about 620 Hz.

               

              Finally, I have studied the "Intel Edison Kit for Arduino"  and, if I understand correctly, the ADC is connect to the Edison through a SPI bus. However, I do not really understand why this bus is identified with SPI0 with respect to the others (iFigure 1, page 6)...

               

              The question is: can I set the clock frequency, through SPI interface, in order to have the ADC working a 1KHz?

              • 4. Re: Edison Arduino board: ADC sampling rate
                David_J_Hunt

                Flavio,

                   You don't 'set' the frequency of the ADC. It's all down to how often you poll it. The SPI bus frequency is the frequency at which the SPI bus communicates with the ADC chip, not how often it reads the results.

                So to get a 1KHz read 'frequency' you need to read, wait 1ms, and read again. It'll be slightly less than 1ms, as the read takes some time as well.

                Rgds,

                Dave.

                • 5. Re: Edison Arduino board: ADC sampling rate
                  nibbler

                  According to edison arduino hw guide and schematics adc is ads7951. According to it's datasheet it starts conversion on each chipselect falling edge. CS is connected to edison's gpio110. It will becool to drive cs with pwm   

                   

                  but I still didn' found how. And I didn't look into driver yet. But I have an idea - use some of kernel timer api and poll chipselect manually from timer callback. Then buffer data received from spi and provide it to userspace on read or ioctl.

                  • 6. Re: Edison Arduino board: ADC sampling rate
                    Sriranjan

                    Hello,

                     

                    I am looking for ADC speeds at 8khz using MRAA. Could some one suggest how to achieve high sped ADC sampling rate?