LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i measure the time between two successive rising edges ,using digital input ..

Solved!
Go to solution

Hello

 

I'm trying to 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 😞

 

Can somebody please help me !!!

 

note: the time that I'm measuring ranges between 200 ms - 2 seconds

0 Kudos
Message 1 of 20
(3,329 Views)

Hi,

 

Can you post your VI in a 2010 (or earlier) version?

 

-CC

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


0 Kudos
Message 2 of 20
(3,310 Views)

ofcourse !

 

here it is ..

0 Kudos
Message 3 of 20
(3,303 Views)

Cheers for that. It's always a good idea to post your SubVIs as well - the problem could be in one of those.

 

To help you out:

 

You already know how to use shift registers so why not use one again for time? Create a new shift register for  the time then simply compare the "rising edge time" to the the previous time stored in the shift register and then write the new time to the shift register.

 

 

Just a few other pointers:

 

1. You'll want to initialise your shift registers ie wire a constant to the left hand register outside of the loop. This will cause the register to be reset each time the program is run. This is so that your counter will start from zero each time you run your code.

 

2. You don't need to use the "greater than?" compare function with boolean as they can only be true or false (1 or 0)! The "Equal?" function is what you should use here.

 

3. Lastly, it's a small thing but you can use the same tunnel that feeds into a case structure in each of the cases - no need to create two tunnels for the true and false cases, use the same one.

 

-CC

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


Message 4 of 20
(3,300 Views)

Chrissy

 

I did what you said about wiring a shift register to the time ,but the problem is when I do this ,I see the value of the present and the last iteration the same ,and I don't know why ,may be coz the value can change in one iteration and then the following one returns to be the same ,so I don't notice the change ,May be I'm doing something wrong.

 

Can you please show me how is the right way to do it ? I just want to display the difference in time between the last and current time and i dont want this difference to just returns to zero rapidly and i don't see it

0 Kudos
Message 5 of 20
(3,279 Views)

Attached is a quick example of how to get the time between clicks of a boolean button.

 

Try and incorporate the basic idea behind the example into your program.

 

I'm more than happy to take another look when you've had a go.

 

-CC

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


0 Kudos
Message 6 of 20
(3,274 Views)

I know it may be a silly question ,but how does the false condition looks like ,I think the tunnel through the case structure have to be wired in the false case to something Smiley Happy

0 Kudos
Message 7 of 20
(3,267 Views)

You are absolutely rightSmiley Happy, all output tunnels from a case structure have to be wired (or at least set to "Use default value" mode).

 

My false case is just a wire connecting the input tunnel on the left to the output tunnel on the right. This means that the program doesn't update shift register when the boolean button is false.

 

-CC

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


0 Kudos
Message 8 of 20
(3,264 Views)

I made it the way it looked in your example ,the time outputs zero ,and this is the same problem i ran into while making it in my program 😞 ,or in this case it outputs the "Wait ms" of the loop 😞

0 Kudos
Message 9 of 20
(3,259 Views)

You nearly got it right. You just need to set the mechanical action of the button to "latch when pressed" (right click on the button>>mechanical action>>latch when pressed)

 

This means the button will be set to true and remain true until LabVIEW has read its state, then it'll 'latch' back to false.

 

-CC

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


Message 10 of 20
(3,256 Views)