LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to have a while loop inside a case structure?

Solved!
Go to solution

Don't confuse a tab control with a state machine.

 

In general, it should not be necessary to connect your tab control's terminal to any case structure.  The tab control is generally used to just organize what is displayed and not displayed on the screen at any given point of time, and general isn't used to programmatically change anything.

 

With a state machine, you have a shift register on your outer most while loop that contains an enum to tell what state (case of the case structure) to run on the next iteration of the while loop.

 

And if you have anything you want to keep running no matter what state your state machine is currently in, such as DAQ, then you should put that code in a separate parallel while loop, and use queues, notifiers, functional global variables, or occasionally regular local variables to pass data back and forth to your state machine while loop.

0 Kudos
Message 11 of 38
(1,808 Views)

 


@Ravens Fan wrote:

Don't confuse a tab control with a state machine.

 

In general, it should not be necessary to connect your tab control's terminal to any case structure.  The tab control is generally used to just organize what is displayed and not displayed on the screen at any given point of time, and general isn't used to programmatically change anything.

 

With a state machine, you have a shift register on your outer most while loop that contains an enum to tell what state (case of the case structure) to run on the next iteration of the while loop.

 

And if you have anything you want to keep running no matter what state your state machine is currently in, such as DAQ, then you should put that code in a separate parallel while loop, and use queues, notifiers, functional global variables, or occasionally regular local variables to pass data back and forth to your state machine while loop.


 

Ravens Fan, I agree, tabs are just to make the front panel look better... My main concern is how to keep on updating a process which was started in 1 tab (1 case structure) even when

a different case is running....

 

Should it be a shared variable, global variable or what??? DO you know any simple example/tutorial where I can look up, I did upload a simple code in my last reply...

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 12 of 38
(1,791 Views)
Solution
Accepted by topic author LV_Enthu

Sorry to keep repeating myself but... You REALLY need to learn LabVIEW if you want to write the kind of apps you're trying to.  A case structure is specifically designed to run ONE CASE at a time.  That's why it's called a CASE structure.  No variable will help you because you have a sub-loop in every case so you must stop that loop before you can go to a different case.  Cases can NOT run in parallel!  You still lack the understanding of the basic dataflow concept that LabVIEW is founded on.  Study the tutorials.

 

[Before anyone jumps on me I do realize there are ways get around these limitations with invoke nodes, VI Server, etc.]

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 13 of 38
(1,778 Views)

NIquist, thanks a lot for the suggestion... I am trying to learn labview by developing such apps... hence i keep on asking questions...

 

I have created basic apps like I/O for DAQ, looping... and so on... I have basically completed the 6hr tutorial..but it only introduced basic facts about

 

creating a shared variable and introduction to state machines... I asked about sharing variables within state machines because I saw few examples which had

 

a screen shot of such kind of apps... But I just don't want to copy paste, would like to understand how is it done.....

 

Thanks

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 14 of 38
(1,770 Views)

I got a tutorial where Ican learn about what I want... thanks a lot guys... I am marking this thread as finished...

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 15 of 38
(1,764 Views)

I can see that you're really trying to learn rather than just asking for complete solutions and that is great!  In another thread you posted a two loop VI (I showed you how to use notifiers to communicate between them, remember?).  That VI used the LV DAQmx VIs instead of the DAQ Assistant and you were really on the right track.  Then you started trying to add advanced functionality too quickly, seemed to become confused and went back the the DAQ Assistant and Express VIs.   That is why I keep saying to learn the basics better. 

 

I suggest you tell us exactly what you expect your VI to do.  What is your actual project? 

What signals do you need to acquire, how do you want to process the data, do you need to have outputs that change based on the inputs received?  What about data storage and/or report generation?  Give us some details so that we can suggest an appropriate architecture and how to best implement it.

 

EDIT:  Smiley Surprised  OK.  Let us know if you have other questions.  Good Luck! Smiley Happy

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 16 of 38
(1,759 Views)

 


@NIquist wrote:

I can see that you're really trying to learn rather than just asking for complete solutions and that is great!  In another thread you posted a two loop VI (I showed you how to use notifiers to communicate between them, remember?).  That VI used the LV DAQmx VIs instead of the DAQ Assistant and you were really on the right track.  Then you started trying to add advanced functionality too quickly, seemed to become confused and went back the the DAQ Assistant and Express VIs.   That is why I keep saying to learn the basics better. 

 

I suggest you tell us exactly what you expect your VI to do.  What is your actual project? 

What signals do you need to acquire, how do you want to process the data, do you need to have outputs that change based on the inputs received?  What about data storage and/or report generation?  Give us some details so that we can suggest an appropriate architecture and how to best implement it.

 

EDIT:  Smiley Surprised  OK.  Let us know if you have other questions.  Good Luck! Smiley Happy


 

Hi NIquist,

               I would like to create a VI in which the start condition is a cylinder at position A. Once the position is confirmed, there is a motor which should be turned ON via LV.

Once the motor is ON, the cylinder should go to position B, once the cylinder is at position B, a counter should start... The cylinder has an attachment in the front which does a particular task

and once the task is finished, the cylinder should go back to position A and the system should shut off...

 

This is my task, I currently know how to get i/o using DAQ assistants, how to create a shared variable, how to create a simple state machine....

Let me know if you can help me with some suggestions... they are always welcome 😉

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 17 of 38
(1,750 Views)

The motors are driven by relays that are controlled by your DAQ outs, and the positions are detected by sensors that are read by your DAQ ins correct?

 

Your first step should be to draw a simple flowchart of the process.  You can then convert that into a state diagram which will help you build your state machine...

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 18 of 38
(1,738 Views)

Yes... correct...I do have a flowchart in my book...

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 19 of 38
(1,732 Views)

 

hello,

        I was reading the attached pdf on page 90, where they have introduced the concept of shared variables... I was curious to know if there is a way

to have a STOP button to have mechanical action as "latch when pressed" instead of "switch when pressed"???

 

Having a STOP button as latch always helps i guess...

 

Please see the link;. you have to download the pdf, the size of the pdf is too large to attach.....

https://lumen.ni.com/nicif/us/academiclv6hr/content.xhtml: https://lumen.ni.com/nicif/us/academiclv6hr/content.xhtml

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 20 of 38
(1,723 Views)