PulseIn function

More
23 Oct 2016 20:27 #81971 by arthuki
arthuki created the topic: PulseIn function
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.
More
23 Oct 2016 21:36 #81974 by andypugh
andypugh replied the topic: PulseIn function
This seems rather off-topic for the LinuxCNC forums.
But:
The Arduino code is here:
github.com/arduino/Arduino/blob/master/h...wiring_pulse.cpp#L30

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)
More
23 Oct 2016 21:42 #81975 by arthuki
arthuki replied the topic: PulseIn function
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.
More
23 Oct 2016 21:59 #81976 by andypugh
andypugh replied the topic: PulseIn function
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?
More
24 Oct 2016 22:13 #82015 by arthuki
arthuki replied the topic: PulseIn function
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?
More
25 Oct 2016 10:25 #82032 by andypugh
andypugh replied the topic: PulseIn function
I really think you are asking in the wrong place, to be honest.
More
25 Oct 2016 18:29 #82051 by arthuki
arthuki replied the topic: PulseIn function
Yeah, maybe.

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