bbb Internal ADC configuration settings?

It is a driver, so you can open, poll and read from /dev/iio:device0

For a quick test, do the following: After you enable the various scan_channels, start the buffer and then do the following:

dd if=/dev/iio:device0 of=~/test.txt

Press ctrl-C to stop capture.

Use hexdump to view the file.

Regards,
John

Hm.

Sorry, but unfortunately I’m still quite a bit lost. What should I be doing to dev/iio:device0 (open?) in order to do the following:
echo 1 > in_voltage0_en
echo 1 > buffer/enable

I’m assuming that I should be able to see in_voltage0_en and buffer in the folder /sys/bus/iio/devices/iio:device0 but I currently do not see those attributes/drivers/folders/buffers/whatever-you-want-to-call-them.

Typing
root@beaglebone:/dev# open iio:device0
doesn’t seem to do anything.

Do you think you could break your steps down even further?

Thanks.

From memory,

echo 1 > /sys/bus/iio/devices/iio:device0/scan_element/in_voltage0_en

echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable

Regards,
John

It says:

root@beaglebone:/# echo 1 > /sys/bus/iio/devices/iio:device0/scan_element/in_voltage0_en
-bash: /sys/bus/iio/devices/iio:device0/scan_element/in_voltage0_en: No such file or directory

and I can’t find scan_elements in sys/bus/iio/devices/iio:device0

root@beaglebone:/sys/bus/iio/devices/iio:device0# ls -l
total 0
-r–r--r-- 1 root root 4096 Mar 1 21:13 dev
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage0_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage1_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage2_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage3_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage4_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage5_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage6_raw
-rw-r–r-- 1 root root 4096 Mar 1 21:13 in_voltage7_raw
-r–r--r-- 1 root root 4096 Mar 1 21:13 name
drwxr-xr-x 2 root root 0 Mar 1 21:13 power
lrwxrwxrwx 1 root root 0 Mar 1 20:47 subsystem → …/…/…/…/…/bus/iio
-rw-r–r-- 1 root root 4096 Mar 1 20:47 uevent

root@beaglebone:/sys/bus/iio/devices/iio:device0# tree
.
├── buffer
│ ├── enable
│ ├── length
│ └── watermark
├── dev
├── in_voltage0_raw
├── in_voltage1_raw
├── in_voltage2_raw
├── in_voltage3_raw
├── in_voltage4_raw
├── in_voltage5_raw
├── in_voltage6_raw
├── name
├── of_node → …/…/…/…/…/…/firmware/devicetree/base/ocp/tscadc@44e0d000/adc
├── power
│ ├── async
│ ├── autosuspend_delay_ms
│ ├── control
│ ├── runtime_active_kids
│ ├── runtime_active_time
│ ├── runtime_enabled
│ ├── runtime_status
│ ├── runtime_suspended_time
│ └── runtime_usage
├── scan_elements
│ ├── in_voltage0_en
│ ├── in_voltage0_index
│ ├── in_voltage0_type
│ ├── in_voltage1_en
│ ├── in_voltage1_index
│ ├── in_voltage1_type
│ ├── in_voltage2_en
│ ├── in_voltage2_index
│ ├── in_voltage2_type
│ ├── in_voltage3_en
│ ├── in_voltage3_index
│ ├── in_voltage3_type
│ ├── in_voltage4_en
│ ├── in_voltage4_index
│ ├── in_voltage4_type
│ ├── in_voltage5_en
│ ├── in_voltage5_index
│ ├── in_voltage5_type
│ ├── in_voltage6_en
│ ├── in_voltage6_index
│ └── in_voltage6_type
├── subsystem → …/…/…/…/…/…/bus/iio
└── uevent

Regards,
John

What is your kernel version?

Regards,
John

Audrey,

Please read the link I gave you a couple weeks ago . . . http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver’s_Guide#Continuous_Mode

Everything you need to know to use the ADC is explained on this page. But from your last post, and the paths you’ve shown us. You’re in the wrong directory. Essentially, you’re still in the one-shot directories, which are completely separate from the continuous mode directory structure.

Audrey,

Also, if you need your samples to be taken precisely at apart. You’ll have to use a PRU - Period. Linux is good for determinism at around 200ms, which often times Linux is faster, but it’s not guaranteed, The PRU’s on the other hand run outside of Linux( bare metal essentially ), and can be very precise timing wise.

SO with using the PRUs, sometimes it’s not about how fast you need something, but how deterministic you need something.

Where do you get the concept that there are two paths? From everything I know about IIO, there is only one path, /sys/bus/iio/devices/iio:deviceX, were X is the number assigned to each IIO driver loaded. There is no one-shot or continuous mode for this driver. I believe mode was removed from IIO.

Regards,
John

Again this is wrong. The scan cycle determines the sampling rate and these samples are then fed to the fifo. As long as the interrupt services the 64 sample fifo before it overflows, then no samples are lost. In essence, the driver can easily keep up.

Regards,
John

Hi William, I did read that article you sent me. I was unable to follow the Driver Configuration bit, but as far as the continuous mode is concerned, after careful re-reading of the article, I think I understand that you are trying to tell me that I should be in the /dev/iio:device0 directory to read the continuous mode. However, my problem is that buffer, scan_elements, and mode, which the article says are used to set up the continuous mode, should be in the /sys/bus/iio/devices/iio:device0 directory. And that was where I was in, but I could not find them, which is my current problem.

John3909, my kernel version is 3.8.13-bone70.

I think if this doesn’t pan out, I will be looking into using the PRU, although I would like to understand the current system better before moving on to something more complicated.

Thanks everyone for your help!

Yeah, that is what I thought. IIO on the 3.8 kernel didn’t have a lot of features and this is why you are having difficulty using it. I would recommend upgrading to the 4.1 kernel or even the 4.4 kernel. I personally use the 4.1 kernel, but I back ported IIO from the IIO-next kernel so that I am using the latest IIO which includes DMA framework support.

Regards,
John

Thanks John, do you know where to get kernel 4.1? This is the only place I know that has beaglebone images, but they don’t specify which kernel each version has: http://beagleboard.org/latest-images

I know that my beaglebone has the image BBB-eMMC-flasher-debian-7.8-lxde-4gb-armhf-2015-03-01-4gb.img.xz

Fresh as of yesterday: 4.1.18-ti-r53

http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Debian_Image_Testing_Snapshots

We've been fixing up the usb gadget setup, so they are a more stable
then the "8.3" images on http://beagleboard.org/latest-images

Regards,

Thanks!

Hi,

So I finally had the time to upgrade my beaglebone, and it now has this kernel: 4.1.18-ti-r53

However, now, a lot of the directories and stuff have changed. I can’t even enable the adc (echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots) because there is no longer any folder called bone_capemgr.9.

root@beaglebone:/sys/devices# ls -l
total 0
drwxr-xr-x 3 root root 0 Mar 20 17:12 armv7_cortex_a8
drwxr-xr-x 3 root root 0 Mar 20 17:12 breakpoint
drwxr-xr-x 21 root root 0 Mar 20 17:12 platform
drwxr-xr-x 3 root root 0 Mar 20 17:12 soc0
drwxr-xr-x 3 root root 0 Mar 20 17:12 software
drwxr-xr-x 6 root root 0 Mar 20 17:12 system
drwxr-xr-x 3 root root 0 Mar 20 17:12 tracepoint
drwxr-xr-x 15 root root 0 Mar 20 17:12 virtual

The folder armv7_cortex_a8 doesn’t have slots and when I tried: echo cape-bone-iio > /sys/devices/armv7_cortex_a8/slots it said permission denied.

There is also no longer any iio folder within /sys/bus:

root@beaglebone:/sys/bus# ls -l
total 0
drwxr-xr-x 4 root root 0 Mar 20 17:12 clockevents
drwxr-xr-x 4 root root 0 Mar 20 17:12 clocksource
drwxr-xr-x 4 root root 0 Mar 20 17:12 container
drwxr-xr-x 4 root root 0 Mar 20 17:12 cpu
drwxr-xr-x 4 root root 0 Mar 20 17:12 event_source
drwxr-xr-x 4 root root 0 Mar 20 17:12 hid
drwxr-xr-x 4 root root 0 Mar 20 17:12 i2c
drwxr-xr-x 4 root root 0 Mar 20 17:12 mdio_bus
drwxr-xr-x 4 root root 0 Mar 20 17:12 mmc
drwxr-xr-x 4 root root 0 Mar 20 17:12 nvmem
drwxr-xr-x 5 root root 0 Mar 20 17:12 pci
drwxr-xr-x 4 root root 0 Mar 20 17:12 platform
drwxr-xr-x 4 root root 0 Mar 20 17:12 scsi
drwxr-xr-x 4 root root 0 Mar 20 17:12 sdio
drwxr-xr-x 4 root root 0 Mar 20 17:12 serio
drwxr-xr-x 4 root root 0 Mar 20 17:12 soc
drwxr-xr-x 4 root root 0 Mar 20 17:12 spi
drwxr-xr-x 4 root root 0 Mar 20 17:12 usb
drwxr-xr-x 4 root root 0 Mar 20 17:12 virtio
drwxr-xr-x 4 root root 0 Mar 20 17:12 w1
drwxr-xr-x 4 root root 0 Mar 20 17:12 workqueue

/sys/devices/platform/bone_capemgr/slots

sudo sh -c "echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots"

https://github.com/beagleboard/bb.org-overlays/

Regards,