How to use PocketBeagle analog inputs 5-7?

721 views
Skip to first unread message

Ken Shirriff

unread,
Dec 3, 2017, 2:07:34 PM12/3/17
to BeagleBoard
I can read analog inputs 0-4 from /sys/bus/iio/devices/iio:device0/in_voltageN_raw but I can't get analog inputs 5-7 to work. Inputs 5 and 6 don't have analog as a choice in config-pin:

$ config-pin -l P1_2
default gpio gpio_pu gpio_pd pruout pruin

Analog input 7 (P2_36) doesn't have any other function, but it ignores any analog input voltage.

Is there a trick to using inputs 5-7 or is support under development?

Ken


Roland Schmidt

unread,
Dec 4, 2017, 10:54:39 PM12/4/17
to BeagleBoard
Hi Ken
some time ago I could read the analog inputs with:
cape_enable=bone_capemgr.enable_partno=BB-ADC
in uEnv.txt
But it was another kernel.

Robert Nelson

unread,
Dec 5, 2017, 10:01:04 AM12/5/17
to Beagle Board, Ken Shirriff
Since 5-7 ADC's are shared with a normal pin, you need to stick the
gpio in gpio mode with config-pin.. (no pull-up, no pull-down) then it
might work..

Haven't personally tried this yet..

Regards,

--
Robert Nelson
https://rcn-ee.com/

Jason Kridner

unread,
Dec 5, 2017, 1:03:06 PM12/5/17
to beagl...@googlegroups.com
I tested all 3 inputs as part of the board bring-up/validation process, but I was using a different device tree. I'm trying to get back to it with what Robert ships in the latest images, hopefully in the next day or so, but I'd like to provide some notes that might be of some use:

For 5 and 6, yeah, Robert's right on making sure the GPIO is set to input mode (should be default?) and that there is no pull-up/pull-down enabled on the pin. Do note, however, that there is a 10k pull-down due to the resistor divider on the input. All voltages on the ADC will be half of what they are on the headerpin.

For 7, there is an analog mux, but it should default to the status of the pin. There are some voltages internal to the PMIC that could be read, put the header pin status should be the default.
 

Regards,

--
Robert Nelson
https://rcn-ee.com/

--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYjKoCF5-ZULWhZUdefCMZo84H1g_1tmPQjaUFOO4v8Xpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--

Ken Shirriff

unread,
Dec 5, 2017, 2:21:21 PM12/5/17
to BeagleBoard
Thanks Robert and Jason. For pin 5 and 6, your solution works:

Pin 5:
$ config-pin P2_35 gpio
$ echo in > /sys/class/gpio/gpio86/direction
$ cat /sys/bus/iio/devices/iio:device0/in_voltage5_raw
1571

Pin 6:
$ config-pin P1_2 gpio
$ echo in > /sys/class/gpio/gpio87/direction
$ cat /sys/bus/iio/devices/iio:device0/in_voltage6_raw
1571

Because of the voltage divider, the values are half of the "normal" values.

But I still can't get pin 7 to work:
$ while [ 1 ]; do cat /sys/bus/iio/devices/iio:device0/in_voltage7_raw; done
This gives me a sequence of values starting around 1600 dropping by about 10 every second, unrelated to my input, slowing down to about 658. Sort of like the voltage if you were discharging a capacitor.

So analog input 7 seems to be measuring something, but I don't know what. Maybe some PMIC thing?

(I'm using Linux beaglebone 4.4.91-ti-r133 #1 SMP Tue Oct 10 05:18:08 UTC 2017 armv7l GNU/Linux)

Ken

Jason Kridner

unread,
Dec 5, 2017, 2:40:15 PM12/5/17
to beagl...@googlegroups.com
On Tue, Dec 5, 2017 at 2:21 PM Ken Shirriff <ken.sh...@gmail.com> wrote:
Thanks Robert and Jason. For pin 5 and 6, your solution works:

Pin 5:
$ config-pin P2_35 gpio
$ echo in > /sys/class/gpio/gpio86/direction
$ cat /sys/bus/iio/devices/iio:device0/in_voltage5_raw
1571

Pin 6:
$ config-pin P1_2 gpio
$ echo in > /sys/class/gpio/gpio87/direction
$ cat /sys/bus/iio/devices/iio:device0/in_voltage6_raw
1571

Because of the voltage divider, the values are half of the "normal" values.

But I still can't get pin 7 to work:
$ while [ 1 ]; do cat /sys/bus/iio/devices/iio:device0/in_voltage7_raw; done
This gives me a sequence of values starting around 1600 dropping by about 10 every second, unrelated to my input, slowing down to about 658. Sort of like the voltage if you were discharging a capacitor.

So analog input 7 seems to be measuring something, but I don't know what. Maybe some PMIC thing?

I'm not sure how to check the status of the analog mux.  Someone posted a driver patch on the TI e2e forum to change the status. Maybe we should carry that patch or help submit to mainline?


Out of curiosity, can you try:

sudo i2cset -y -f 0 0x24 9 5
sudo i2cget -y -f 0 0x24 9
sudo cat /sys/bus/iio/devices/iio:device0/in_voltage7_raw

I pulled the magic numbers from the patch and the files it references. 
 

For more options, visit https://groups.google.com/d/optout.
--

Ken Shirriff

unread,
Dec 5, 2017, 2:47:07 PM12/5/17
to beagl...@googlegroups.com
Thanks, Jason. Your magic i2cset commands worked and now I can use analog input 7.

Ken

To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/ryYJflyy2N8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CA%2BT6QPkYrrtzEeVM7dXeTnWh3Qp2uTfvZoVDWnfa%2BHi2mVXhdg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages