From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Level Trigger Detection and While Loop Condition

I'm reading an analog signal and want the reading to stop once I hit a certain value. 

The trigger is being detected because my indicator lights up, but it doesn't exit the while loop as I have it wired currently. It insists on running for 10 seconds (1000 samples/sec for 10,000 samples) even if the trigger is detected.

 

If the trigger is not detected, the indicator will be red after 10 seconds, but will continue running even if the trigger level is met. 

So, what am I using incorrectly and in which combination? DAQmx Read, Basic Level Trigger Detection.vi, the while loop or all three?

Thanks.

0 Kudos
Message 1 of 13
(4,265 Views)

True.PNG

^ This is totally unnecessary, btw.

 

So you're saying that the trigger detected light turns green, but the loop doesn't end? Does it keep looping, or is it stuck on something else inside that loop? You have an "Is Task Done" VI in there, so maybe the code is stuck on that for some other reason. If the True value gets passed to the stop terminal, the While loop will not iterate again.

 

Run your code using Highlight Execution to see what the loop looks like when that trigger is achieved. Also, probe the wire that is connected to the stop terminal and make sure it is in-fact True.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 13
(4,262 Views)

I know that = was unnecessary I was just desperate, ha. 

I removed the "Is Task Done" VI that didn't need to be there anyway. No go.

Also, I should specify the light won't turn green until the 10 secs passes and exits the loop that way. And I just probed the point you suggested and it doesn't turn True until after the 10 seconds. 


Edit: I was a bit hasty, if I let it run until the probe confirms FALSE and then i go to trigger it, it just waits awhile before finally switching to True. Is something really lagging this script down?

0 Kudos
Message 3 of 13
(4,253 Views)
So what you're seeing is the trigger not triggering. If you don't get a True value it then the trigger criteria hasn't been fulfilled. I'm away from my computer for the next few hours, after which I can open this up again and take a look if you still need.

In your post, you say that the "trigger is being detected", but this is incorrect apparently.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 13
(4,245 Views)

It is being detected, it just won't stop the loop.

I'll elaborate on my set up. The analog signal is a force sensing resistor and the trigger is when a certain force/voltage threshold is reached. 

Case 1: I press the FSR at anypoint during the runtime -- Trigger = TRUE, does not stop loop. The probe does not indicate it was True until the 10 secs of reading is over.
Case 2: I do not press the FSR (just sits at zero) -- Trigger = FALSE, does not not stop the loop. The probe does not indicate it was False until the 10 secs of reading is over.

Thanks!

0 Kudos
Message 5 of 13
(4,239 Views)

Consider your loop.  You do two things in sequence -- acquire 10K points at 1KHz (which requires 10 seconds before you have any points to process, and when the 10 seconds are up, you have all of the points), then you decide if the Trigger was detected.  Let's assume that it takes 0 time to detect the trigger.  Then every 10 seconds, you get a Trigger signal or not, regardless of when during the 10 seconds the trigger occurred.  You've basically quantized time into units of 10 seconds.

 

Bob Schor

0 Kudos
Message 6 of 13
(4,223 Views)
Bob_Schor is right. Change the number of data points you pull to a smaller number so that the loop iterates at a faster period than 10sec.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 13
(4,213 Views)

But what if I want it to run at least that longr? Is there a different function to actually interrupt the loop?

0 Kudos
Message 8 of 13
(4,177 Views)

So I guess I don't understand what you are trying to do... You want the loop to stop when the trigger is achieved, but you also want it to run for all 10 seconds of data. These are two things that cannot be done at the same time.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 9 of 13
(4,173 Views)

Nope, but that's okay!

I want it to potentially run for up to that time, but if the trigger is acheived I want it to end. I want the trigger to interrupt the loop if it is detected irrespective of how many times the loop can be potentially allowed to iterate.

 

Perhaps the trigger is in the wrong place or I need to use a different vi? 

0 Kudos
Message 10 of 13
(4,168 Views)