Skip to content

Instantly share code, notes, and snippets.

@pdp7
Created Nov 23, 2016
Embed
What would you like to do?
Adafruit_BBIO.ADC adc.py
import Adafruit_BBIO.ADC as ADC
ADC.setup()
print ADC.read("AIN0")
print ADC.read_raw("AIN0")
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:~# python ./adc.py 
0.403418809175
1652.0
root@beaglebone:~# uname -a
Linux beaglebone 4.4.32-ti-r68 #1 SMP Thu Nov 17 12:17:45 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# cat /etc/dogtag 
BeagleBoard.org Debian Image 2016-11-21
root@beaglebone:~# cat /etc/debian_version 
8.6
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:~# find / |grep Adafruit_BBIO
/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp/Adafruit_BBIO
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp/Adafruit_BBIO/PWM.so
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp/Adafruit_BBIO/GPIO.so
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp/Adafruit_BBIO/ADC.so
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp/Adafruit_BBIO/SPI.so
/root/.python-eggs/Adafruit_BBIO-1.0.0-py2.7-linux-armv7l.egg-tmp/Adafruit_BBIO/UART.so
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:/opt/source/adafruit-beaglebone-io-python# git log -1 --oneline
4371949 Adjust ADC scaling based on kernel version
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:~# cat /boot/uEnv.txt  |grep -v '^#' | sort -r 
uname_r=4.4.32-ti-r68
cmdline=coherent_pool=1M quiet cape_universal=enable
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:~# python ./adc.py 
Traceback (most recent call last):
  File "./adc.py", line 2, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
root@beaglebone:~# python ./adc.py 
0.403174608946
1653.0
root@beaglebone:~# 
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:~# dmesg
[  586.897163] bone_capemgr bone_capemgr: part_number 'BB-ADC', version 'N/A'
[  586.904387] bone_capemgr bone_capemgr: slot #5: override
[  586.909820] bone_capemgr bone_capemgr: Using override eeprom data at slot 5
[  586.916854] bone_capemgr bone_capemgr: slot #5: 'Override Board Name,00A0,Override Manuf,BB-ADC'
[  586.941180] bone_capemgr bone_capemgr: slot #5: dtbo 'BB-ADC-00A0.dtbo' loaded; overlay id #1
[  587.110392] ti_am3359-tscadc 44e0d000.tscadc: chan 0 step_avg truncating to 16
[  587.117849] ti_am3359-tscadc 44e0d000.tscadc: chan 1 step_avg truncating to 16
[  587.125211] ti_am3359-tscadc 44e0d000.tscadc: chan 2 step_avg truncating to 16
[  587.132498] ti_am3359-tscadc 44e0d000.tscadc: chan 3 step_avg truncating to 16
[  587.139778] ti_am3359-tscadc 44e0d000.tscadc: chan 4 step_avg truncating to 16
[  587.147055] ti_am3359-tscadc 44e0d000.tscadc: chan 5 step_avg truncating to 16
[  587.154333] ti_am3359-tscadc 44e0d000.tscadc: chan 6 step_avg truncating to 16
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

root@beaglebone:~# strace -f -o /tmp/strace python ./adc.py 
Traceback (most recent call last):
  File "./adc.py", line 2, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
root@beaglebone:~# 
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

First run:

4670  open("/sys/bus/iio/devices/iio:device0/in_voltage1_raw", O_RDONLY) = -1 ENOENT (No such file or directory)

Second run:

9212  open("/sys/devices/platform/bone_capemgr/slots", O_RDWR|O_LARGEFILE) = 3
9212  open("/sys/bus/iio/devices/iio:device0/in_voltage1_raw", O_RDONLY) = 3
9212  open("/sys/bus/iio/devices/iio:device0/in_voltage0_raw", O_RDONLY) = 3
9212  open("/sys/bus/iio/devices/iio:device0/in_voltage0_raw", O_RDONLY) = 3
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# cat adc.py 
import Adafruit_BBIO.ADC as ADC
ADC.setup()
print ADC.read("AIN0")
print ADC.read_raw("AIN0")
root@beaglebone:~# python adc.py 
0.403907209635
1654.0
root@beaglebone:~# uname -a
Linux beaglebone 4.1.9-bone16 #1 Wed Sep 30 16:50:09 UTC 2015 armv7l GNU/Linux
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.1.29-bone22 #1 Fri Aug 5 10:18:54 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403663009405
1653.0
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.1.34-bone24 #1 Thu Oct 13 01:35:56 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403663009405
1654.0
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.1.30-ti-r69 #1 SMP Sun Aug 14 11:23:09 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403907209635
1654.0
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.4.33-bone14 #1 Mon Nov 21 00:44:10 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403907209635
1653.0
root@beaglebone:~# 
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

FAIL

root@beaglebone:~# uname -a
Linux beaglebone 4.4.31-ti-r67 #1 SMP Sat Nov 12 06:10:55 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
Traceback (most recent call last):
  File "adc.py", line 2, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

FAIL

root@beaglebone:~# uname -a
Linux beaglebone 4.4.30-ti-rt-r66 #1 SMP PREEMPT RT Thu Nov 10 23:31:38 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
Traceback (most recent call last):
  File "adc.py", line 2, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are: 
  - A cape with a conflicting pin mapping is loaded 
  - A device tree object is loaded that uses the same name for a fragment: helper
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.4.30-ti-r65 #1 SMP Tue Nov 8 17:28:39 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403907209635
1654.0
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.4.32-bone14 #1 Thu Nov 17 06:46:24 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403907209635
1654.0
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# uname -a
Linux beaglebone 4.4.33-bone14 #1 Mon Nov 21 00:44:10 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# python adc.py 
0.403907209635
1654.0
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# python adc.py 
0.403907209635
1654.0
root@beaglebone:~# uname -a
Linux beaglebone 4.9.0-rc6-ti-r5 #1 SMP Tue Nov 22 05:03:07 UTC 2016 armv7l GNU/Linux
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 23, 2016

OK

root@beaglebone:~# python adc.py 
0.403907209635
1653.0
root@beaglebone:~# uname -a
Linux beaglebone 4.9.0-rc6-bone3 #1 Tue Nov 22 11:23:48 UTC 2016 armv7l GNU/Linux
@pdp7

This comment has been minimized.

Copy link
Owner Author

@pdp7 pdp7 commented Nov 29, 2016

root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: PF----  -1 
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universaln
root@beaglebone:~# ls
adafruit-beaglebone-io-python  node_modules	  spidev_test.c.1
Adafruit_DotStar_Pi	       olegantonyan-bbio  spi-loop.py
adc.py			       pr		  spi-test-bbio.diff
ADS1248_minimal.py	       Project16.js	  strace.log
bb.org-overlays		       pwm-test.py	  tux.png
bonescript-test.js	       spidev_test
mrburns42-test.py	       spidev_test.c
root@beaglebone:~# python ./adc.py 
2.00944447517
3588.0
root@beaglebone:~# uname -a
Linux beaglebone 4.4.34-ti-r69 #1 SMP Wed Nov 23 20:01:14 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# cat ./adc.py
import Adafruit_BBIO.ADC as ADC
ADC.setup()
print ADC.read("AIN0")
print ADC.read_raw("AIN0")
root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: PF----  -1 
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universaln
 5: P-O-L-   1 Override Board Name,00A0,Override Manuf,BB-ADC
root@beaglebone:~# dmesg |tail 
[  481.342614] bone_capemgr bone_capemgr: Using override eeprom data at slot 5
[  481.342631] bone_capemgr bone_capemgr: slot #5: 'Override Board Name,00A0,Override Manuf,BB-ADC'
[  481.360075] bone_capemgr bone_capemgr: slot #5: dtbo 'BB-ADC-00A0.dtbo' loaded; overlay id #1
[  481.527559] ti_am3359-tscadc 44e0d000.tscadc: chan 0 step_avg truncating to 16
[  481.527592] ti_am3359-tscadc 44e0d000.tscadc: chan 1 step_avg truncating to 16
[  481.527603] ti_am3359-tscadc 44e0d000.tscadc: chan 2 step_avg truncating to 16
[  481.527613] ti_am3359-tscadc 44e0d000.tscadc: chan 3 step_avg truncating to 16
[  481.527622] ti_am3359-tscadc 44e0d000.tscadc: chan 4 step_avg truncating to 16
[  481.527632] ti_am3359-tscadc 44e0d000.tscadc: chan 5 step_avg truncating to 16
[  481.527641] ti_am3359-tscadc 44e0d000.tscadc: chan 6 step_avg truncating to 16
root@beaglebone:~# cat /etc/dogtag 
BeagleBoard.org Debian Image 2016-08-14
root@beaglebone:~# cat /etc/debian_version 
8.6
root@beaglebone:~# uname -a
Linux beaglebone 4.4.34-ti-r69 #1 SMP Wed Nov 23 20:01:14 UTC 2016 armv7l GNU/Linux
root@beaglebone:~# 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment