NI Home > Community > NI Discussion Forums

LabVIEW

Reply
Member kix
Member
kix
Posts: 3
0 Kudos

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     
Active Participant
becktho
Posts: 1,576

Re: rising and falling edge detection in a while loop

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... :smileywink:
--------------------------------------------------------------------
Member kix
Member
kix
Posts: 3
0 Kudos

Re: rising and falling edge detection in a while loop

Thanks that work. But it reduce the speed of the main while loop. Do you know a way to programm it without reducing speed.
   
Proven Zealot
johnsold
Posts: 9,831
0 Kudos

Re: rising and falling edge detection in a while loop

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
Active Participant
becktho
Posts: 1,576
0 Kudos

Re: rising and falling edge detection in a while loop

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 :smileywink:.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... :smileywink:
--------------------------------------------------------------------
Member
shears
Posts: 16
0 Kudos

Re: rising and falling edge detection in a while loop

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.

Active Participant
becktho
Posts: 1,576
0 Kudos

Re: rising and falling edge detection in a while loop

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... :smileywink:
--------------------------------------------------------------------
Member
shears
Posts: 16
0 Kudos

Re: rising and falling edge detection in a while loop

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.

Proven Zealot
johnsold
Posts: 9,831
0 Kudos

Re: rising and falling edge detection in a while loop

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