08-13-2008 08:11 AM
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
08-13-2008 08:19 AM - edited 08-13-2008 08:20 AM
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.
Hope this helps,
Daniel
08-13-2008 08:36 AM
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
08-13-2008 08:53 AM
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
08-13-2008 09:58 AM
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
08-13-2008 10:14 AM
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