PulseIn function

23 Oct 2016 20:27 #81971 by arthuki
Hey everyone,

I have a project with a LM555 timer and need to calculate how much time it takes for an input to go from LOW to HIGH and then to LOW again.

Basically, I want to know the period of a square wave generated by the LM555 timer.

I did it with Arduino using the function Pulseln. But I need to do this using a Beaglebone and programming in C++ (Using QtCreator).

Is there a way to "open" the function PulseIn so I know what it does? Moreover, do you guys have any piece of code that might help me?

Thank you in advance.
23 Oct 2016 21:36 #81974 by andypugh
This seems rather off-topic for the LinuxCNC forums.
The Arduino code is here:

But I doubt that it will really translate easily to BBB as I anticipate it uses a hardware timer in the microprocessor.

What time resolution do you need?

I can imagine ways to do this with LinuxCNC HAL, but it's a rather heavyweight package just to measure a pulse.
(Unless you are already using LinuxCNC and this timing needs to be done in a LinuxCNC context)
23 Oct 2016 21:42 #81975 by arthuki
Andypugh, thank you for the answer.

I need a resolution of about a few microseconds.

I have tried translating the code from arduino to C++ but as you said, it uses many of other arduino "built-in" functions.
23 Oct 2016 21:59 #81976 by andypugh
You might be able to do it with the Beaglebone PRU, but I think that the only expertise with that is on the Machinekit project. You could try asking there?
24 Oct 2016 22:13 #82015 by arthuki
Thank you all for the great answers. I believe that the best way will be through PRU. But I was thinking, what if I used PWM reading libraries (black lib for example) on this square wave?

Any thoughts?
25 Oct 2016 10:25 #82032 by andypugh
I really think you are asking in the wrong place, to be honest.
25 Oct 2016 18:29 #82051 by arthuki
Yeah, maybe.

Thank you anyway Andypugh
Time to create page: 0.145 seconds
Powered by Kunena Forum