LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

catch event when digital signal DAQ input has falling edge

I am using NI ELVIS II device, I have a digital input signal. I want to catch the event when this input signal changes from HIGH to LOW, I don't care how many counts. To do this, I used a local variable (as in VI attached) but I think it is still not the most optimal. Do you have any other way to replace my plan and speed up it? Thank you.

0 Kudos
Message 1 of 13
(3,023 Views)

Hi hung,

 

using local variables in a loop is NEVER a good idea!

What about using shift registers instead?

 

What about that (classic!) Rube-Goldberg in your VI?

IF true THEN true ELSE false

That is basically a NOP…

check.png

When your loop runs endlessly, then those DAQmxStopTask and DAQmxClearTask will never be called…

 

Do you have any other way to replace my plan and speed up it?

Yes, sure!

Use the DI signal as a trigger for the second task. Start the second task on a falling edge of the first DI signal…

To learn about that DAQmx feature you should look at the example VIs in the example finder, coming with LabVIEW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,000 Views)

Hi GerdW,

Thank you for the things you said very interesting. The algorithm that uses local variables as I did before is due to thinking like the previous C/Arduino programming language I used. As you said, Use the DI signal as a trigger for the second task. I tried searching for example

Capture.PNG

I don't know if this is an example you want me to find.

 

 

 

0 Kudos
Message 3 of 13
(2,994 Views)

Hi hung,

 

please see the example "Analog Input - Synchronization": there is a StartTrigger at the 2nd DAQmx task.

You need to do the same with your DI task: set the first DI signal as a start trigger - you can even select the edge of the DI pulse…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(2,988 Views)

Hi GerdW,

I tried trying to read the example and look for more examples online. But in the example "Analog Input - Synchronization" I don't understand how it works.

I found an example on google but also could not understand how it works. Can you help me make a simpler example? I have been studying labview for 2 days, I see examples that are too difficult. Thanks you!

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019PBVSA2&l=en-VN&fbclid=IwAR1Ixs3bRPCi...

 

0 Kudos
Message 5 of 13
(2,970 Views)

Hi GerdW,

I just wrote an example, you can help me see if it works properly: "when the Master Channel has an  Input pulse from high to low, the Slave Channel has an output pulse from a low level to a high level." Thank you.

Capture.PNG

0 Kudos
Message 6 of 13
(2,964 Views)

Hi hung,

 

you don't need that "master" task.

All you need is to set the correct (PFI) channel for this DAQmxTrigger…

 

I have been studying labview for 2 days, I see examples that are too difficult. Thanks you!

That's why there is a "Training" section in the header of thisLabVIEW board.

You really should take that!

You want to cope with DAQ hardware, so you better do some training before starting to code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 13
(2,954 Views)

 I have a NI-ELVIS II device. I want to read an input analog signal when there is a digital input signal from a high level to a low level. I use DAQmx Triggers to do that. Analog signal my input connected to AI0 + -, digital input signal connected to FPI0. But I can't read anything, can someone help me? Thank you.

0 Kudos
Message 8 of 13
(2,948 Views)

 I have a NI-ELVIS II device. I want to read an input analog signal when there is a digital input signal from a high level to a low level. I use DAQmx Triggers to do that. My Analog signal input connected to AI0 + -, digital input signal connected to FPI0. But I can't read anything, can someone help me? Thank you.

 

0 Kudos
Message 9 of 13
(2,943 Views)

Hi hung,

 

why did you create two more threads for the very same topic? Please keep discussions in one place (for one problem)!

 

But I can't read anything, can someone help me?

- You didn't set any trigger source, the DAQmx channel control is empty.

- You set the edge to "rising", but from your description you want to wait for a "falling" edge.

- You didn't set any number of samples to read.

- You set the acquisition mode to "continuous" (which is fine), but only call DAQmxRead once. IMHO there should be a loop around DAQmxRead.)

- Do you get any DAQmx errors? If yes: which one?

- Did you connect your digital signal to PFI0?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 13
(2,932 Views)