LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 parallel state machine

Solved!
Go to solution

I have 1 state machine controlling a number of pressure transducers and balances.

The pressure transducers and balance is used to analyze a soil sample

I need another state machine of exact same type as the other. The only difference is that the new state machine shall control another set of pressure transducers and balances.

The 2 state machines will have to run parallel, so I will be able to analyze 2 soil samples at the same time.
The state machines do not need to execute in the same speed. It is alright the one state machine is ahead of the other. 

Is there a smart way in LabVIEW to get over this, or do I simply need to copy the first state machine and change the id for pressure transducers and balances?

 

 

 

0 Kudos
Message 1 of 18
(5,199 Views)

Hi Michael,

 

when the only difference is the ID of your sensors/actors you could make that an input to your statemachine.

Then you could call the VI with the statemachine twice - after setting it to reentrant…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 18
(5,185 Views)
Solution
Accepted by topic author Michael.Koppelgaard

Reentrancy is the key here.  I recommend using the Preallocated Clone reentrancy for speed and memory management reasons.  So you just make a a high level VI that just calls this state machine twice, in parallel.  Pass in the ID to the state machine and you have both running.


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
Message 3 of 18
(5,173 Views)

I will try you suggestions. Might return for more help. Newer tried this - I'm relatively new in LabVIEW. Thank you for help 

0 Kudos
Message 4 of 18
(5,146 Views)

The state machine have to be in subvi's. Correct ?

0 Kudos
Message 5 of 18
(5,124 Views)

@Michael.Koppelgaard wrote:

The state machine have to be in subvi's. Correct ?


No, the state machine is implemented only ONCE in ONE subVI. You simply CALL that subVI TWICE in parallel by another VI.

 

EDIT: That's why Gerd and Tim recommend using IDs for identification of which instance you work in (e.g. for selecting instruments)

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 18
(5,120 Views)

Okay. That was also what I meant.

But how to get the front panel from the subvi ?

I need output from both call of subvi. I need to see what is happening. The VI is going to run for several hours.

Is it possible to use:

http://forums.ni.com/t5/LabVIEW/Combine-VI-into-one-VI/m-p/1923479#M643430

to get the front panel from the subvi (the state machine)?

 

0 Kudos
Message 7 of 18
(5,109 Views)

Best solution is to use subpanels for this.

Other option is to use property nodes to modify values/appearance of controls/indicators on the top level (calling) VI.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 18
(5,103 Views)

Oh I feel so stubit

I really don’t know what you mean. I’m new an trying to learn.

So if the weight in 1 instance of subvi shows 1655 g, how to get this value shown in an indicator in front panel of the top level?

Using subpanel as shown below will not distinguish between the different instances of the subvi - will it ?

Capture.PNG

0 Kudos
Message 9 of 18
(5,090 Views)

Hi Michael,

 

there are several ways to send data from subVIs to a main VI (or more general: between parallel running loops).

 

There are queues, notifier, FGVa aka AEs, shared variables, network stuff, control references, and some other. I recommend queues/notifier…

To show the FP of a subVI you only need to edit the (subVIs) FP settings - or you simply show all values in your main VI.

 

Oh I feel so stubit

When you feel stupid (:D) I recommend to take all those free (!) online resources offered by NI for LabVIEW beginners…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 18
(5,079 Views)