Count duration a GPIO is high (or low) ?

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ichrysomallis
 
Posts: 1
Joined: Fri Mar 22, 2019 8:50 am

Count duration a GPIO is high (or low) ?

Post by ichrysomallis »

Hello,

I'm using a Beaglebone black micro-controller with ROS (melodic, code in rospy) and Adafruit_BBIO library installed. Is there any way to receive the exact duration is ns/us/secs a GPIO is high? Currently, I want this feature so I can accurately convert a signal beaglebone receives from a sonar sensor, into distance.

Thanks in advance,

Jason C.

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Count duration a GPIO is high (or low) ?

Post by drewfustini »

You could create some logic using GPIO.input(PIN) and timestamps to calculate the amount of time the pin was high. This might work if you are interested in millisecond resolution but I'm not sure how precise it will be.

The BeagleBone's TI AM3358 processor does have a peripheral for measuring input pulses called eCAP. The Adafruit_BBIO library does not support this due to there being no upstream Linux kernel driver for it. However, there a library called libpruio which supports eCAP. It targets the PRU (Programmable Real-Time Units) in the AM3358 processor:
http://users.freebasic-portal.de/tjf/Pr ... p_8py.html

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”