polling-frequency of I/O-port

13 views
Skip to first unread message

ahf...@gmail.com

unread,
May 9, 2017, 12:00:40 PM5/9/17
to BeagleBoard
hello to every one,here is Yangyang.I want to know,how can test the polling-frequency of I/O-port on beaglebone black,and what is the maximum speed of the frequency ? The max. speed what I test is around 27kHz. Hope there is anyone can help me
contact via ahf...@gmail.com. Thanks.

Here is my code(python):

from bbio import *
import time

testIO = GPIO1_28    #P9_12
testVar = 0 

counter  = 0
cntMax = 10000
startTiME = time.time()
endTiME = 0

pinMode(testIO, INPUT)

while 1:
    if counter >= cntMax:
        endTiME = time.time()
        print 'Frequenz an test IO:', cntMax / (endTiME - startTiME)
        counter = 0
        startTiME = time.time()
    else:
        if not digitalRead(testIO) == testVar:
            testVar = not testVar
            counter += 1

William Hermans

unread,
May 9, 2017, 1:10:17 PM5/9/17
to beagl...@googlegroups.com
A few things about your code.

First, if you're concerned about performance, you're using the wrong language. Wrong type of a language for that matter. You should be using C, C++, or ASM. *IF* you're concerned about performance.

Secondly, calling a time() related function in your main loop, every iteration will slow your code down.

Thirdly printing to stdout every iteration of your loop will slow your application down A LOT.

Lastly, I'm not sure if the bbio library uses sysfs for manipulating pins or not. But if it does. There are performance limitations associated with this as well. 

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/72ede135-3c68-4410-8462-83ebeaee6020%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages