LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A simple labview question with example vi attached. Thank you very much

Solved!
Go to solution

Dear friends, 

 

I need some help here. I am using state machine. There are  2 indicator. My target is:

1. the indicator 1 will keep blinking, 2. after 5 iteration of first while loop, 3. the 2nd indicator will blinking as well (the indicator 1 should keep blink as well, not stop).

 

please check the attached vi(labview 2017 64bit). My problem is the 2nd indicator never start to blink....   if I put the 2nd indicator case into 1st while loop, the 2nd will be blink, its good, but 1st will stop. I do need 1st one blinking all the time, never stop.  

 

Thank you so much again.  Could you help me modify my vi, so that the 2nd will blinking after iteraion of 1st whole > 5, but 1st one still keep blinking?  Thank you again!!!

Untitled.png

Download All
0 Kudos
Message 1 of 16
(4,685 Views)

You have a data dependency. The parts on the right cannot start until the loop on the left has completed.

 

All you need is a simple state machine with one single outer loop. Try it!

0 Kudos
Message 2 of 16
(4,663 Views)

Here's one possible solution. Modify as needed.

 

0 Kudos
Message 3 of 16
(4,656 Views)

Dear the knight of NI, 

 

Thanks for your vi, yes, it works well. 

However, maybe this is my fault, I didnt make it very clear. I am doing a much bigger simulation. And there are 2 state machine actually. That's why I really really need to keep those 2 state machine. Is there a way to achieve the same thing but keep the 2 state machine??  Thank you so much for your help. you are the best Knight!  !!!! 

0 Kudos
Message 4 of 16
(4,609 Views)

You can still create a single state machine that contains all states. No need for separate loops, especially if they both run at the same speed.

 

If you want to run the two state machines in parallel, there cannot be any data dependency or they will run in sequence only. If this confuses you, you need to go back to the tutorials before proceeding.

0 Kudos
Message 5 of 16
(4,606 Views)

Dear Knight, 

 

Thanks for your quick reply. 

Just make sure, you mean, 2 state machines can NOT be run at the same time? and only can be run one after one? Thank you.  

0 Kudos
Message 6 of 16
(4,602 Views)

sunson29 wrote:

Just make sure, you mean, 2 state machines can NOT be run at the same time? and only can be run one after one? Thank you.  


 

No, you can have an unlimited amount of independent state machines on a single diagram, but there cannot be data dependency between them if they should run independently. If you have any wire (except channel wires :D) connecting two state machines, the second one can only start once the first one has completed.

 

You really need to familiarize yourself better with the principles of dataflow!

0 Kudos
Message 7 of 16
(4,595 Views)

thanks. where to study the NI dataflow?  

0 Kudos
Message 8 of 16
(4,591 Views)

3 Hour Introduction
6 Hour Introduction
LabVEW Basics
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Learning NI
Getting Started with NI Products


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 16
(4,585 Views)

@sunson29 wrote:

thanks. where to study the NI dataflow?  


Of course do all of Tim's suggestions right above.

 

Dataflow:

  1. A node (structure, function, frame, subVI, etc.) cannot execute until all wired inputs have received data.
  2. A node (structure, function, frame, subVI, etc.) only places data on its output wires once everything in it has completed.
  3. A loop cannot go to the next iteration until everything in its diagram has completed.
  4. ...

In your case, you have a green wire that stalls the second loop until the first loop has completed.

(Also note that your code to determine odd/even can be replaced by a bitwise AND with the number 1. Also, there is an "=0" primitive).

0 Kudos
Message 10 of 16
(4,565 Views)