Hi everyone,

First of all, thank you everyone for trying to help me. I appreciate 
everyone's input.

I took everyone's advice, and have moved away from bash to C++. It's 
clocking at about 2 milliseconds, but I would really like it to go down 
into the microsecond range:

> /** Simple LDR Reading Application
>
> * Written by Derek Molloy for the book "Exploring BeagleBone: Tools and
>
> * Techniques for Building with Embedded Linux" by John Wiley & Sons, 2014
>
> * ISBN 9781118935125. Please see the file README.md in the repository root
>
> * directory for copyright and GNU GPLv3 license information.            */
>
>  
>
> #include<iostream>
>
> #include<fstream>
>
> #include<string>
>
> #include<sstream>
>
> using namespace std;
>
>  
>
> #define LDR_PATH "/sys/bus/iio/devices/iio:device0/in_voltage"
>
>  
>
> int readAnalog(int number)
>
> {
>
>    stringstream ss;
>
>    ss << LDR_PATH << number << "_raw";
>
>    fstream fs;
>
>    fs.open(ss.str().c_str(), fstream::in);
>
>    fs >> number;
>
>    fs.close();
>
>    return number;
>
> }
>
>  
>
> int main(int argc, char* argv[])
>
> {
>
>    cout << "Starting the readLDR program" << endl;
>
>    int value;
>
>    int i=1;
>
>    while (true)
>
>    {
>
>      float value = (float)readAnalog(0)/4095*1.8;
>
>      cout <<"V= " << value << endl;
>
>      cout << i << endl;
>
>      i++;
>
>    }
>
>    return 0;
>
> }
>

Thank you TJF for pointing me to libpruio. I'll use it later if I need it, 
but for now I rather not use the PRU if I don't need to.

So I noticed this thing where I can't see the buffer, or scan_elements, or 
mode in iio:device0, and I wonder if I'm not enabling the adc dto properly 
or something:

> root@beaglebone:/sys/bus/iio/devices/iio:device0# ls -l
> total 0
> -r--r--r-- 1 root root 4096 Mar  1 20:51 dev
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage0_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage1_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage2_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage3_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage4_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage5_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage6_raw
> -rw-r--r-- 1 root root 4096 Mar  1 22:03 in_voltage7_raw
> -r--r--r-- 1 root root 4096 Mar  1 20:51 name
> drwxr-xr-x 2 root root    0 Mar  1 20:51 power
> lrwxrwxrwx 1 root root    0 Mar  1 20:50 subsystem -> 
> ../../../../../bus/iio
> -rw-r--r-- 1 root root 4096 Mar  1 20:50 uevent


This is what I've been doing to "enable" the adc (although I don't really 
know what it is doing. I can't find the file cape-bone-iio in bbb, and if I 
try echo cape-bone-iio > test.txt, it is just a regular string.):
echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots

I tried searching for /driver/iio/adc/ti_am335x_adc.c, but I can't find it 
(there's nothing in root@beaglebone:/sys/bus/iio/drivers#). Could you 
perhaps specify the full filepath?

Thanks.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to