LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

property nodes & Sequences

Hi
 
I'm currently testing part a vi that will be included as part of a larger vi to simulate actual system operation. The operation of the vi is meant to be as follows :-
 
1) Count from 1 to 5.
2) Depending on the value a certain case should be enacted.
3) All cases take the same basic form, the only difference being the time values. They should - set a boolean true, wait for a period of time, set the boolean false, wait for a period of time, then iterate to the next count.
 
To do this I have used a sequence within a case structure and property nodes to get the boolean value outside the loop. The property node sets the value of an indicator called 'rolling?'. This works perfectly. However when the code is placed in the main vi it need to pass this boolean state to other areas of the code. However this does not work. when setting the indicator 'rolling?' to a control, it continues to display the correct sequence, but the indicator 'boolean' connected to the 'rollling?' control does not display the same as the control, even though there is simply a direct wire link between them.
 
I have enclosed the vi. Any assistance would be gratefully received.
 
Cheers
 
Dave
0 Kudos
Message 1 of 13
(3,965 Views)
A few notes:

(1) Your code is excessively complicated for what it seems to be trying to do. See attached VI for a simplified version based on trying to follow your code. I think I got it right.

(2) Pick up the LabVIEW Style Guide on writing code. You'll be better off in the long run as your code will be easier to read.

(3) Once you place this VI as a subVI the output won't be available until the VI is finished, so the boolean state won't be available until then. It seems like you're trying to get the state of the "rolling?" boolean around your application. One method is to make that boolean into a global variable which you can read in your other code while this subVI is running. Another is to use queues in your application though that may be a little bit too much depending on the complexity of your application.
Message 2 of 13
(3,948 Views)

Hi Dave,

The Output indicate is read only once during the loop iteration.  So whatever the value of the Rolling? control is at the beginning of the loop iteration, that's going to be the value sent to the Output indicator.  There will be no further updating of that indicator throughout the course of the loop iteration, since that data has already gone through the wire between them.  If you truly want the value of the Output indicator to always match the value of the Rolling? control, you should either have a separate loop that is constantly doing that updating, or you could simply update a local variable of the Output indicator every time you update the Rolling? value.  Here are some other suggestions I have for you:

1.  Instead of using feedback nodes and all that logic with the Select function, you could just use the iteration count of the While Loop to indicate which state of the Case structure should run.

2.  Instead of using the Case Structure, you could have a single Flat Sequence Structure that just runs a case based on the iteration count of the While Loop.

3.  Local variables are a lot better to use in terms of performance than the Value property of controls.

Hope these suggestions help,
-D

Message 3 of 13
(3,947 Views)
Hi Dave,

I think your code is too complicated, you (and I also) would understand it better if it was more simple.

1. you have five times exactly the same code (in each case) you could have this code only once and just feed it with different values,
2. for such a small vi I wouldn't use "feed back nodes" they always confuse me, and I think you can run without them,
3. this won't change a lot but a property node is something too "powerfull" to be used in that case, you should use a local variable instead,
4. one more thing, if you want it to stop at once when you click stop, you should use the "elapsed time" function (I didn't put it in my vi)

have a quick look at my vi and tell me if it works like yours 😉

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 4 of 13
(3,939 Views)

Hi

Firstly thanks to everyone for their help.

I think I need to clarify things slightly. Firstly, the code will not be in a subvi, but will be placed in the main VI. WIth regards to the code I should make it a bit clearer how things work.
 
As the increment occurs, for each increment should occur :-
case 1 - boolean on, 8.9second delay, boolean off 12.35 second delay
case 2 - boolean on, 15.34 second delay, boolean off 17.45second delay
case 3 - boolean on, 17.45second delay, boolean off 14.35 second delay
case 4 - boolean on, 22.34second delay, boolean off 12.56 second delay
case 5 - boolean on, 25.67second delay, boolean off 35.46 second delay
 
The boolean output will be connected to a case structure in the main vi that controls a file saving operation.
 
Titou, if you connect an indicator to the 'rolling' control then the indicator and 'rolling' control do not display the same thing. This is the problem I have been having with the other code!
 
Cheers
 
Dave
0 Kudos
Message 5 of 13
(3,922 Views)

Ok Dave,

The code you posted at the beginning tends to prove that you don't really understand how LabVIEW works.
So, first you should run your code in "highlight execution” from the diagram and see what happens. LabVIEW is based on dataflow.

The “Output” indicator will be read only once by execution of the big for loop, so it is normal that on front panel you don’t have the same value “rolling ?”.

If you link a boolean indicator to the local variable in  the centre of the VI I posted, you yill see that this indicator is updated at each execution of the inside loop.
Run it in "highlight execution" I'm sure you will understand what was wrong in your first code.

Hope this helps 😉

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 13
(3,915 Views)

One of the problems in the above solutions is the fact that

  1. they write to value properties instead of the terminal directly.
  2. The stop button action is delayed until an entire loop finishes.

A better solution is using an event structure, manipulating the timeout and also loop once per value change, eliminating the sequences. Now the stop button works always immediately, independenly of the current program stage, even if you would use minutes as waits. Notice also that we don't need any property nodes or locals.

See if the attached solution make sense to you. (LabVIEW 7.1) 🙂

Message 7 of 13
(3,908 Views)

Hi

Thanks for the assistance so far. 

The example code submitted so far does not quite achieve what I am looking for. Currently, all the VI's submitted so far switch the output for fixed periods on and off. From my previous message (extract below) you will see that both the on and off times are different at each of the five iterations.

As the increment occurs, for each increment should occur :-
case 1 - boolean on, 8.9second delay, boolean off 12.35 second delay
case 2 - boolean on, 15.34 second delay, boolean off 17.45second delay
case 3 - boolean on, 17.45second delay, boolean off 14.35 second delay
case 4 - boolean on, 22.34second delay, boolean off 12.56 second delay
case 5 - boolean on, 25.67second delay, boolean off 35.46 second delay
 
I did originally write the vi using a for loop, but moved away from this in an attempt to solve the problem described.
 
Cheers
 
Dave
0 Kudos
Message 8 of 13
(3,876 Views)
Hi David,

I think Altenbach's solution is quite nice, no ?
I just modified it quickly to match your on/off delays (the way I modified may not be of the cleanest style) but I think it does what you are asking for.
If not, could you explain in what this code doesn't do what you need Smiley Surprised ?

PS : just replace the array constant in the diagram 😉

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 9 of 13
(3,863 Views)
Titou
 
Thanks for that  - almost there. I've never used the event structure before so I'm just off to do some research. There is one final thing to finish this off. How do extract the value of rolling so it can be used elsewhere in the VI. I need to use the value of rolling to control a case structure, to turn on/off a write file function. I have written the write file and the case structure to do this which is currently controlled by a switch on the front panel. I want to replace the switch with a wire that connects to the value of rolling.
 
Cheers
 
Dave
0 Kudos
Message 10 of 13
(3,848 Views)