LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the data flow

Solved!
Go to solution

 

Hello,

I am working on a program in which i have to control the data flow on wires.

The task is that the data should not pass on until a given value is generated. And the program remains reading the wire until that value is generated.

When that value has obtained, now the data pass on to the while loop regardless of the data that is generated latter on.

For this reason i have created two while loops one searches for that value and the other is the main which have to perform processing when the specified value is generated (taken in the first loop).

This could also be said that "Wait until a certain value is received"

single point signal.PNG

 

The first loop is created just to wait until a value 3 is obtained.

The second loop is the main which has to process it.

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

Hi,

Why don't you use single while loop and a Case structure? Have a look.

You can execute code written in second while loop in "True" Case.

 

Example.PNG

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 2 of 13
(4,828 Views)

Thanks gak

The thing is that, i have to search it only for the first time. And when that value is occurred now i have to do processing regardless 3 occurs again or not. 

0 Kudos
Message 3 of 13
(4,825 Views)

You can also say it like.

Wait until 3 is occurred and then go to the processing.

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

State machine architecture is best option for this.Have a look at attached vi.

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 5 of 13
(4,810 Views)

I think that i am unable to clerify my task

This is to 

"Not start the program until 3 comes"

Once 3 is occurred than run the main program

Not concerned with the value obtained

0 Kudos
Message 6 of 13
(4,802 Views)

Hi Intelligent,

You can place your main code in "Main" state of the vi I have posted.

What You have done is, you are checking value of "numeric". If it is =3, you stop that loop and start new while loop in which you carry out further process.

I have done same thing with state diagram structure. First state is "Init". Whatever is your initial condition, is checked in this state. It will act as your first while loop. It will exit this state when your condition is satisfied.

Then it will enter in Next state i.e.. "Main". Here you can carry out further process on data as you have done in second while loop.

I think I have made myself clear.

 

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 7 of 13
(4,799 Views)

Whilst your screenshot is not best coding practice, I struggled to see what you were asking for help with.

 

I figured out eventually what your problem was. The two while loop system you have written will do the bare minimum of what you want (although as I said, it is far from best practice and left as it is it would still have issues when running). However what you have would never progress beyond the first loop unless the Numeric was set to 3 at the start. Whether you understand the state machine or not, what you do need to understand is that terminals on the block diagram are read where they are put.

 

So in your diagram, the only value that will ever be compared to the three is the initial value of the numeric. Move the numeric into the while loop and it will be read in each iteration.

 

However, your second while loop has it waiting for a 7 before finishing, and so you would need a read of the value in that location as well. There are various ways to do this, but the best answer would be a state machine. Read the numeric OUTSIDE of the case structure, but inside the while loop. Create an enum to manage the cases. Control the cases using a shift register on the loop, initialise this (outside the loop) to "Case 1" (entry 0 in your enum). In "Case 1" look for a 3, if you have one update the shift regitser to be "Case 2", otherwise pass through the "Case 1" value. In "Case 2" look for a 7, if you find one send a True to the while condition, otherwise send a False. The System Status just needs to be wired to the not of the outcome of Numeric = 7. (The value being used as the other input for the AND will always be TRUE.)

 

It would be a good idea next time to actually ask a question in the first post, what you gave us was a number of statements, and a screenshot of some code which almost fills the requirements

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

 


@Intelligent wrote:

The first loop is created just to wait until a value 3 is obtained.

The second loop is the main which has to process it.


 

You have some severe misconceptions about dataflow and your code is highly flawed. Since your control is outside the first loop, any data change of the control will not propagate into the loop once the VI has started. This means that the first loop will either (1) complete immediately or (2) continue to spin forever while consuming all CPU.

Same with the second loop.

 

It is also very bad practive to do equal comparison with floating point numbers.

 

Here's a quick solution (LV 8), see if it suits your requirements. Modify as needed, e.g. add your LED back. 😉

 

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

 


@altenbach wrote:

 

It is also very bad practive to do equal comparison with floating point numbers.

 


Why is that?

 

=====================
LabVIEW 2012


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