LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

rising and falling edge detection in a while loop

Hi,
I have a control system for for a energy maintenace with a Field Point 1601 system for the Digital In and out put. The maintenace system needs only a pulse to power up and down. My control system creats a permanent signal. When I use a timer device will brake the "While Loop".
My Idee was a rising and falling edge detection but I have no clue how to programme it.
Can somebody help or can you send me an example?
I`m just a beginner so please write it easy.
 
Thanks kix     
0 Kudos
Message 1 of 12
(6,578 Views)

Hi kix

I'll try to describe it with words, so that you can try to create the vi yourself.

So as you already mentioned, you need a while loop, where you read and compare boolean values. To detect an edge you need the old and the current value. So this means you need a shift register, so that the current value of loop x is available as old value in loop x+1.

The pattern of a rising edge is oldvalue = false & currentvalue = true, right? So this is what you have to code.

Hope this is a usable starter.

Just have a try and don't hesitate to ask, if you get stuck.

Thomas

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 12
(6,575 Views)
Thanks that work. But it reduce the speed of the main while loop. Do you know a way to programm it without reducing speed.
   
0 Kudos
Message 3 of 12
(6,563 Views)
What Thomas suggested should execute very quickly. If your loop slowed noticeably, something else is probably happening. Can you post an example which shows the slow down?

Lynn
0 Kudos
Message 4 of 12
(6,559 Views)
I agree with Lynn, that there must be something else that slows the loop down.
 
By the way - if I have to detect edges, I always execute this detection in a separate loop using queues and events to react on - but this may be a bit far off now, as you're new to LV. But maybe once it could be helpful ;).
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 5 of 12
(6,552 Views)

I have a similar problem.

I have two voltage meters that output a "high" and a "low" signal.

I want to measure the duration of a drop when the first signal is low and the second is high, but only when the signal falls, not when it rises.

This is the screenshot of the current output.

signal.png

As you can see it detects both cases instead of just the first.

I can also provide the VI if needed.

0 Kudos
Message 6 of 12
(6,035 Views)

Well, I don't work with LV anymor as I changed my job, but let's give it a try...

Obviously, you already measure the first duration correctly. As you measure the second duration as well, there must something be wrong with your "triggers". I'd suggest you to build kind of a truth table for the trigger conditions.

For example U1 is high and U2 is high = idle, U1 is low and U2 is high = start measurement and so on. This can guide you to the current problem or it may help you create another trigger logic.

 

Regards

Thomas

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 7 of 12
(6,031 Views)

Yes, I'ver come this far, but I can't figure out how to build the truth table you mentioned.

For now it's like this:

if the signal is high, it records the time. If the signal is low, it doesn't.

0 Kudos
Message 8 of 12
(6,017 Views)

Please post your VI along with some typicla data and a clear indication of what you want it to do. Someone will likely be able to help.  It is very difficult to troubleshoot from a few sentences.

 

Lynn

0 Kudos
Message 9 of 12
(6,004 Views)

Hi

 

can u plz send code of this.

 

Thanks

0 Kudos
Message 10 of 12
(5,171 Views)