Showing results for 
Search instead for 
Did you mean: 

How can I measure the time between each two successive rising edges ,using Digital Input ?

Go to solution



I'm trying two measure the time in seconds between each two successive rising edges on a digital input .

Till now I have managed to detect the rising edge ,increment a counter with each rising edge ,and snap the time at which the rising edge happenned

all I need now is to subtract the current rising edge time from the previous rising edge time in order to calculate (T) which can be 1/frequency and display it in realtime to the user.

but I don't know how to do this Smiley Sad


Can somebody please help me !!!

0 Kudos
Message 1 of 11

somebody please remove this post ,I posted another one by mistake ,sorry

0 Kudos
Message 2 of 11

It would help if you included the sub VI "FP Read" with your example program.


This task can be accomplished by setting up a counter input task as a frequency measurement.


Not sure if you tried this yet, but if you include the missing sub VI, we would be able to help a little easier.

0 Kudos
Message 3 of 11

assuming your device does not have a counter....



rising edge timer_BD.png




Message 4 of 11

The subvi FP Read is included in the Fieldpoint Device Drivers package ,even if i included the subvi ,you wont be able to use coz u dont have the hardware.

 the vi typically outputs a boolean number ,either 0 or 1 ,that's it

0 Kudos
Message 5 of 11



Thanks a lot for your reply ,and yes my device does not have a counter input ,only the digital input .


I just want to know what the use for the two digital inputs *the boolean controls" ? can you please explain to me .



0 Kudos
Message 6 of 11
Accepted by topic author shadymohamed
08-27-2015 04:09 PM

Woah!  Smiley Surprised


Sorry Apok, but your code is becoming way too complicated/messy. I don't think that all of those shift registers or boolean conversion/operators are needed at all.


If you want to measure the timing between two button presses then this is a different (much less complicated) way. It simply records the timing of the button press into a shift register then compares the two.


Time Between Clicks - Simplified


Of course this is a very quick and basic solution just to show you that it can be much simpler than you are making it (remember to use the mechanical actions of the buttons to get the behaviour you want).


A better way would be to use an event structure looking at value changes of the buttons to determine the timings between clicks.



"If anyone needs me, I'll be in the Angry Dome!"

0 Kudos
Message 7 of 11

He has only one digital input.

0 Kudos
Message 8 of 11

Posted in error.



0 Kudos
Message 9 of 11

Try this. Substitute the boolean control with your FP Read. Note there will be some measurement error due to the FP Read overhead and non-deterministic OS.




The first rising edge "primes the pump" so ignore the first Elapsed Time and Frequency. This gives timing between adjacent rising edges, e.g., 2 and 3, 3 and 4, 4 and 5, etc.

Message 10 of 11