LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV Won't Consistently Record Time

Solved!
Go to solution

Hey everyone,

 

So I've been working on this project where I need to write a LabVIEW vi that allows me to record the time elapsed between the breaking of two voltage tripwires (going from ~5V to 0V). The vi I have works... usually. The "time stamps" that it gives me do not always appear though, while the "bool indicators" flip every time without fail. This leads me to think that the computer (or DAQ?) aren't able to keep up with what I'm wanting to do, or I'm just not telling it to pull the samples I want correctly or something. I've played around a lot with the "Samples to Read" and the "Rate (Hz)" numbers to no avail, and have been exploring things in that realm but have hit a stone wall. You'll have to forgive me a bit, software is not my forte and I know just enough to get me in trouble. My vi and specifications are attached (the tripwires are connected to the first NI 9223 module at ports A0 and A1). Thanks in advance.

 

NI cDAQ-9188XT

Slots 1-2: NI 9223

Slot 3: NI 9213

Slot 4: NI 9237

Slot 5: NI 9218

Slot 6: NI 9218

Slot 7: NI 9401

Slot 8: Empty

 

 

0 Kudos
Message 1 of 4
(2,656 Views)
Solution
Accepted by aero2020

Your VI is inside out with a case structure on the outside, and while loops on the inside.

And what is the point of those while loops that have a True constant wired to the stop terminal?  And why did do you have the true constant outside the loop?  Those loops will only run one time.  Since you aren't using any shift registers, a 1-iteration while loop has no value here.

 

You are hiding a lot of code by using DAQ Assistant and blue dynamic data type wires.  Wiring that blue DDT wire to a case structure effectively converts it to a single boolean (see the red coercion dot where it enters the selector?) so you have either a single true or false.

 

I feel like you don't understand the concept of LabVIEW dataflow with the way this VI is built. I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

Message 2 of 4
(2,651 Views)

Thanks for the links, I'll get cracking on those. I can "program" in C# ok and MATLAB decently, so my flowchart kind of followed that type of logic. Then combine that with, as you correctly said, not really understanding the LabVIEW environment and you get the Frankstein I posted earlier. Strangely enough it works, just not as well as it should. I think your links will be a step in the right direction.

0 Kudos
Message 3 of 4
(2,641 Views)

I'm surprised that it would work at all.

 

For each signal, you ultimately wind up with a DDT (blue wire) that represents an array of booleans.  You feed each one into a case structure.  The case structure only accepts a single boolean.  So LabVIEW coerces that either to a True or False.  I don't remember if that will be the first or the last element of that array of booleans that is hiding in the blue wire.  So you wind up with something getting a time stamp if true, or nothing going to a timestamp if false.

 

Don't mess with the DAQ assistant or the dynamic datatype wire.  Learn to use the DAQmx palette and the standard functions there.  Capture a long enough waveform so you you know you'll see both triggers.

 

If you capture a 1-D array of waveforms, you can use a trigger level detector to determine when each waveform crosses the threshold.  Subtract the times between the two and you'll have your timing.

Message 4 of 4
(2,628 Views)