LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a value from a case structure to a while loop.

I am passing value out of a case structure and then passing it to a while loop.  I can pass it out of the case structure but when I pass it into the while loop it goes to zero.  Is there anyway I can fix it so it retains the value in the while loop?
0 Kudos
Message 1 of 9
(3,688 Views)
Hi,
 
You're text it's not very clear ( for me). Can you post a small example with your problem?
Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 2 of 9
(3,687 Views)
How do I post a an example?
 
Thank You
 
 
0 Kudos
Message 3 of 9
(3,682 Views)
 
Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 4 of 9
(3,670 Views)
0 Kudos
Message 5 of 9
(3,662 Views)
Hi leaf34,
the value don´t change to zero. Why do you need such code?
You you can remove the case structure, because you constant is everytime "True". And you can also remove the second while loop. Can you explain what you try to do?

Mike
0 Kudos
Message 6 of 9
(3,630 Views)

It is all in the dataflow. Your while loop will not output data until the loop has finished, so if you place a probe after the while loop, it will not contain data until the first loop has stopped.

Run your VI in execution highlighting mode for a better understanding. Yes, the second loop has no purpose. Again, it will always receive a TRUE on the boolean (because only if this wire is true the previous loop was able to complete). Once the first loop is done, the value of the boolean will never get read again and the true value exiting the first loop will stop the second loop after one iteration.

These are very basic concents that are very essential. You should probably start with a few LabVIEW tutorials to get a better understanding.

Message 7 of 9
(3,627 Views)

Thank You for that explanation, the code you saw was just an example not the code I am using.  I am trying to measure to different things: angular velocity and angular acceleration from a motor.  I got angular velocity by looking for an event and then dividing the distance between events by the amount of time past.  Now to get my acceleration I have to measure the change in velocity and divide that by the change time.  To do this I was originally trying to display both the present velocity and velocity at some time step before present one.  This is way I needed the second while loop, so I could put a delay in that loop thus giving me a velocity at some knowen time step before the present one.  If there is anyway this can be accomplished I sure appreciate it.    

Thank You.

I attached my orginal code.       

0 Kudos
Message 8 of 9
(3,598 Views)
Hi leaf34,
 
I haven't analyzed your velocity and acceleration algorithms in depth, but I wanted to point out two VIs that may be of use to you as you attempt to code your own derivative function: the Derivative x(t).vi and the Derivative x(t) PtByPt.vi.
 
I hope this helps.
Kevin S.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 9
(3,555 Views)