LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to return to loop

I am using a flat file structure to run my test sequence. Inside each is a loop to perform the test. After completion I go to the next step. If I have a failure I have to exit the loop and give the operator controll. Repeat the test, Continue or fail. I am sure my software is not the greatest. But every week I get new changes to add.

 

My question: If I fail a loop and ask the operator to push one of three buttons? How can I return to the loop or a setup loop? I am in the process of learning State diagrams.

 

 

Thanks

 

Philip

 

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

Philip,

 

you should learn about State Machine, not State Diagrams. Your code is overly complex and must be worked over again.

Some points to improve:

- Remove all global variables. Maybe you will need some locals, but those are to prevented if possible.

- Remove the sequence structure.

- Remove all unneccessary frontpanel and block diagram elements (e.g. DAQ Assistant2)

 

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 13
(4,649 Views)

How difficult is it to create State machine without the module from NI? I am in the process of developing examples for the State Maching.

 

Thanks

 

Philip

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

Philip,

 

a State Machine is no toolkit or something similar. It is an architecture for your code, so a design pattern for building your application (or at least the module).

You can find the basic layout of several design patterns in the Templatebrowser which can  be opened by selecting File >> New. In this browse, move to VI >> From Template >> Frameworks >> Design Pattern.

You will find an example for the Standard State Machine there as well.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 13
(4,602 Views)

Is it worth the money to buy the State Machine toolkit from NI? Cost is close to $900 dollars. It may help me speed  up the process.

 

Thanks for your help

 

Philip

0 Kudos
Message 5 of 13
(4,593 Views)

Philip,

 

there is no State Machine toolkit for LV. I think you are talking about either the Statechart Module (LV 8.x and later) or the State Diagram Toolkit (LV 7.1.1 and prior).

Well, they could save some time indeed, but they also could cost you time. This depends how fast you can adopt the mechanisms running behind the scenes of the module/toolkit.

So you have to decide for yourself it is worth trying.

 

Nevertheless, none of the stated module/toolkit should replace the procedure of learning about basic design patterns in LV.....

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 6 of 13
(4,584 Views)

Thanks for the explanation. I maybe able to purchase the State Module. But the other software is out of the question at this time. I am using a 30 day demo of the State Module. I am also looking at the examples. I am in the learning process. I have restarted the VI three times. Hallway meetings on changes? GRRR This is what keeps our jobs.

 

Thanks

 

Philip

0 Kudos
Message 7 of 13
(4,579 Views)
As Norbert has said, buying the State Diagram toolkits will probably end up costing you time, at least initially. What he suggests, looking at the discussions about State Machines (for which there is no specific toolkit) is a good idea. A State Machine is an flexible architecture that, when properly implemented, allows a program to proceed from one "State" to the next, based on various criteria, i.e., in this State a certain test is being performed. If it passes go to the next test state, if it fails, go to a state that displays an option to the operator of how to proceed. The simplest basic state machines usually consist of a case statement, inside a loop, with the case selection being passed into a shift register, so that when this "case" or "State" completes, whatever the next "case" or "State" can be determined, and placed on the shift register. There have been numerous threads devoted to this topic, the State machine can be very simple all the way to enormously complex, but are the powerful underlying structure in a lot of programs. Draw your desired process flow on paper, think out the transistions (pretty much the "old fashion" flowchart) and creating a "State Machine" should be easier.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 8 of 13
(4,563 Views)
An overly simple explanation of how to implement a state machine in LabVIEW is a case statement inside of a while loop. Use a typedefed ENUM or a string to define what states are in your state machine. Use a shift register to pass the next state to process for each loop iteration. The examples and templates that ship with LabVIEW will have several examples of this basic code. As stated several times you do not need to purchase any additional toolkits in order to implement a state machine within LabVIEW.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 13
(4,547 Views)

I am now working with State Modules. This has improved the software structure dramaticaly. My thanks to all of the help I recieved.

 

Thanks

 

PhilipSmiley Very Happy

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