-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AIN read performance issue #29
Comments
Thanks, that's good info. Both PyBBIO and Adafruit_BBIO are using the sysfs drivers. The difference is that Adafruit is using a C extension to do the file I/O, where as PyBBIO is currently doing file I/O straight from Python. I did it that way because it was the quickest way to get the ADC working, but I am planning on moving more of the IO to C extensions as I find the time. I suppose it would still be possible to directly control the ADC the way I was on earlier kernels, but the problem is it then wouldn't be compatible with any overlays that use the ADC, because the iio driver would just reconfigure it. One of my goals is to make PyBBIO as cape compatible as possible, so it has to be able to work along side the iio driver. I'm still looking into how best to do this. |
In new kernels there is now a fix for AM335x_ADC_Driver that provides continuous sampling support Would be awesome to have same functionality in python. May be worth to consider? |
Thanks for pointing that out. It would definitely be cool to support continuous mode in PyBBIO to get some faster sampling, perhaps even combined with epoll to fire a callback after every sample. I definitely want to get the normal ADC reads faster first though. |
I'm closing this issue as I'm not planning on changing the way analogRead() works any time soon. |
Where can i find 'adafruit_bbio.adc'; i was interested to know the definitions of 'adc.read', 'adc.read_raw' |
This is the wrong repository. |
Ok.. Problem was solved.. Thanks -----Original Message----- This is the wrong repository. |
I have wrote a small program to read as many requests as possible from AIN0:
from bbio import *
import time
bbio.bbio_init()
i = 0
j = 0
end = time.time() + 1
while time.time() < end:
x = analogRead(AIN0)
if x > 0:
i=i+1
else:
j=j+1
print "have read " ,i , " times in a second with ",j," failed."
bbio.bbio_cleanup()
I get the following output:
root@beaglebone:
/python# python readAIN1_PyBBIO.py/python# python readAIN1_PyBBIO.pyhave read 307 times in a second with 0 failed.
root@beaglebone:
have read 320 times in a second with 0 failed.
root@beaglebone:
/python# python readAIN1_PyBBIO.py/python# python readAIN1_PyBBIO.pyhave read 313 times in a second with 0 failed.
root@beaglebone:
have read 318 times in a second with 0 failed.
root@beaglebone:
/python# python readAIN1_PyBBIO.py/python# python readAIN1_PyBBIO.pyhave read 320 times in a second with 0 failed.
root@beaglebone:
have read 317 times in a second with 0 failed.
root@beaglebone:
/python# python readAIN1_PyBBIO.py/python# python readAIN1_PyBBIO.pyhave read 318 times in a second with 0 failed.
root@beaglebone:
have read 317 times in a second with 0 failed.
root@beaglebone:~/python# python readAIN1_console.py
when I do the same on Adafruit library, I get
import Adafruit_BBIO.ADC as ADC
import time
ADC.setup()
i = 0
j = 0
end = time.time() + 1
while time.time() < end:
x = ADC.read("AIN1")
if x > 0:
i=i+1
else:
j=j+1
print "have read " ,i , " times in a second with ",j," failed."
root@beaglebone:
/python# ./readAIN1_console.py/python# ./readAIN1_console.pyhave read 818 times in a second with 0 failed.
root@beaglebone:
have read 822 times in a second with 0 failed.
root@beaglebone:
/python# ./readAIN1_console.py/python# ./readAIN1_console.pyhave read 820 times in a second with 0 failed.
root@beaglebone:
have read 825 times in a second with 0 failed.
root@beaglebone:~/python# ./readAIN1_console.py
have read 820 times in a second with 0 failed.
So, I figured that you read from sysfs, are you still having plans for reading AIN0 from memory? Is there any way to get more reads per second?
The text was updated successfully, but these errors were encountered: