LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[EASY PROBLEM] Pausing only One Loop

This is probably a very easy problem, but I am brand new to this LabView thing and after searching for a long while, I still have not found a solution.

This is my task:

"Write a VI that monitors a numerical control to see if the user has changed
the number being entered. Whenever the user does change the number,
your VI should make a normally green LED turn red for 0.5 seconds. Be
sure your VI monitors the input frequently, not just every 0.5 seconds."

 

My design is below. The problem is, when the number changes, the LED turns on, and the pause keeps the LED on for .5 sec, the number register pauses aswell. I DO NOT WANT THIS. As you can see, I added a second numeric to show me what the program sees the number value being. If the value changes faster than .5 sec, it doesnt register the change. This means (to me) that the wait is pausing both of the loops, when I only want it to pause the loop it is in.

 

Is there a way to fix this?


THANK YOU! ❤️

Untitled.jpg

0 Kudos
Message 1 of 6
(2,405 Views)

You only have 1 loop, and that one pauses, yes. Side note: Numeric 2 is unnecessary as it'll always be the same as Numeric(1).

It'd be great idea to look at events and it'll be really easy to solve with that.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 6
(2,394 Views)

New homework assignment, huh?

 

Read up on Event Structures to handle user actions.  A while loop can also be used for simpler but (usually)less expandable code.

There's a bunch of different ways to time actions.  Tick counter, Wait(ms), Elapsed Time, shift register counter, loop iteration count,etc.  All are included for a reason, you need to pick the most appropriate method.

The number register pausing during your .5s is basic dataflow.  Dataflow is *the* fundamental operation of LabVIEW, unlike text based languages.  Read up on that some more.

 

Don't worry, everybody starts at the beginning.  Put in the work and you'll start to realize how nice a language this is.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 3 of 6
(2,394 Views)

It's not pausing both loops since you really only have one loop (with a case structure in it).  In order to time the red LED (0.5 sec) your loop must pause for the delay VI to complete.  EVERYTHING that executes in the loop will slow down the loop.  Since this is schoolwork I suspect this is the solution your teacher expects.  Otherwise you'll have to use two loops with proper communication techniques between their threads.  Also, even if you do it that way you will not detect a new value change in less than 500 mSecs since the LED will still be red until that time expires.

 

BTW, your loop is also free-running so it will consume 100% of CPU.  You can put in a short (1mSec) delay OR use an event structure to monitor the value change of your control rather than poll it as you are doing now.

 

EDIT:  Just noticed it's a timed loop set to 1 mSec already.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 4 of 6
(2,390 Views)

You are right, there is only 1 loop and it is pausing that. You would be supprised, our reading does not really cover the material very well, and in general the answer is not found in our reading.

 

The reason I have the extra numeric is so that I can tell if there is a delay in the detection of a new value. And like you said, there is a .5 sec delay in the detection aswell. I DONT WANT THIS. I want to, as the problem suggests, detect the value much faster, and without the delay.

 

My question is how to do this. After I finish this post, I will do the research the post above you suggests, I just wanted to clarify.

 

Also any examples of functioning models would be of great help.

0 Kudos
Message 5 of 6
(2,379 Views)

Try this.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 6 of 6
(2,361 Views)