title: Increase Beaglebone Black ADC sampling rate?
body: <p>I'm working on a project that requires the use of a microcontroller, and for this reason, I decided to use the Beaglebone Black. I'm still new to the Beaglebone world and I'm facing some problems that I hope you guys can help me with.</p>
  
  <p>In my project I will have to continuously read from all the 7 analog read pins and do some processing accordingly. My question is, what will be the fastest programming language to do so (I must read as much samples as possible and in a very short time!) and how to increase the sampling rate from KHz to MHz?</p>
  
  <p>I tried the following codes:</p>
  
  <p>Javascript Code:</p>
  
  <pre><code>var b = require('bonescript');//this variable is to refer to my beaglebone
  time = new Date();
  b.analogRead("P9_39");
  console.log(new Date() - time);
  </code></pre>
  
  <p>this code will simply perform one analog read and will print out the time needed to perform the read. Surprisingly, the result was 111ms!! which means that my sampling rate is 10 if I'm not wrong.</p>
  
  <p>An alternative was to use pyhton:</p>
  
  <pre><code>import Adafruit_BBIO.ADC as ADC
  import time
  
  ADC.setup()
  millis = int(round(time.time() * 1000))
  ADC.read_raw("P9_39")
  millis = millis = int(round(time.time() * 1000)) - millis
  print millis
  </code></pre>
  
  <p>this code took less time (4ms) but still, if I wanted to read form the 7 analog input pins, I will only be able to read around 35 samples from each.</p>
  
  <p>Using the terminal:</p>
  
  <pre><code>echo cape-bone-iio &gt; /sys/devices/bone_capemgr.*/slots
  time cat /sys/devices/ocp.3/helper.15/AIN0
  ############OR############
  time cat /sys/devices/ocp.3/44e0d000.tscadc/tiadc/iio\:device0/in_voltage0_raw 
  </code></pre>
  
  <p>and this took 50ms.</p>
  
  <p>I want my sampling rate to be something in MHz. How can I do so? I know that the Beaglebone Black is capable of that but I could not find a clear way to do so. Any help is appreciated.
  Thanks in advance.</p>