LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect edge and set boolean variable

Hello,

 

I am searching for a VI that sets a boolean variable to true each time a rising edge is detected at the input channel and subsequently sets it to false, until the next rising edge arrives. Do you know if there is an Express-VI that I could use for this purpose or can you give me a hint how to program a VI that does what I need?

 

Thanks in advance,

 

Aenne

0 Kudos
Message 1 of 6
(8,646 Views)

Hi Aenne,

is the input channel boolean? Then you can just use the "Greater?" function from the Comparison palette to compare the latest value with the previous one. See code snippet.

Rising Edge 

Hope this helps,

Daniel

 

Message Edited by dan_u on 08-13-2008 03:20 PM
Message 2 of 6
(8,645 Views)

Hi Daniel,

 

thanks for your reply. The input channel is not boolean. So far I have used the DAQmx Creat Channel (CI - Count Edges).vi to count the edges arriving on that channel. So perhaps a possibility would be to check if the counter increases an then set the boolean variable to "true". How can I implement this? Or is there a "direct" way without using the counter?

 

Thanks again,

 

Aenne

0 Kudos
Message 3 of 6
(8,628 Views)

Hi Aenne,

 

yes, this is one possible way to do it.

As you plan to use the Count Edges it means you have a digital channel (which is what I meant by boolean in my previous post). If you want to detect all edges of the digital line your sampling has to be faster than the edge frequency.

In this case you could also configure it as digital input and use the algorithm proposed in my previous post.

 

Daniel

 

 

0 Kudos
Message 4 of 6
(8,620 Views)

Hallo Daniel,

 

the edge frequency is 1Hz, so detecting all edges shouldn't be a problem.

 

Can you explain a bit more in detail how I can solve my problem with your proposed algorithm? It confuses me that you have a while-loop. Is the Count Edges inside or outside that loop? How can I configure it as digital input?

 

Änne

0 Kudos
Message 5 of 6
(8,605 Views)

Hi Änne

 

If you use Count Edges this will return the edges between two readings afaik. This means you can just check whether the count is > 0.

 

If you use a digital input and configure it to read single values then you will have to compare the old value with the new value as shown in the code snippet. The DAQmx read will be in a loop anyway (timed loop most likely), just use a shift register in this loop to store the old value.

 

Daniel

 

0 Kudos
Message 6 of 6
(8,600 Views)