From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine SubVI

Can the attached VI statemachine be converted to a subvi ?  I have tried several variations but unsuccessful so far.  Would like to have a subvi icon with external connections SP, RO, and Overide.  I am creating other applications that will use multiple instances of this code.

 

AO0, AI1, (daqassis) and the override boolean need to be external inputs and should not be embedded in the statemachine.  I left them embedded in the statemachine for functional demonstration purposes.

 

Thanks

0 Kudos
Message 1 of 4
(3,438 Views)

All VI's can be turned into subVI's.   It sounds like you are asking how to wire up the connector pane.

 

That is a basic LabVIEW skill.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 2 of 4
(3,430 Views)

It can be a subVI. The values of the inputs cannot change while the subVI is running. The connector pane needs to be wired for inputs and outputs.

 

As a subVI the code needs some means of stopping. The VI you posted will run forever. Stopping a VI by using the front panel close X or the Abort button is not a good practice. For one thing it will leave the DAQ devices in unknown states. If you wnat to use the data in the main VI while the subVI is still running, you need to add a queue to transfer the data.

 

If the subVI needs to display its front panel while running, you need to change some of the properties regarding the window appearance and execution.

 

If you will be running multiple copies in one VI, you may want reentrant execution. Also you need to make sure that the multiple DAQ Assistants will not have resource conflicts.

 

While you can probably make it work, you might be better off starting over with the Prodcuer/Consumer (Data) Design Pattern. That is specifically designed for applications like this.

 

Lynn

Message 3 of 4
(3,423 Views)

Lynn,

 

Thanks for all the information !  I had to rethink my program structure based on what you said.  I created a case structure that produced almost the same functionality as the previous statemachine.  I am not ready for the producer / consumer solution yet.

 

I was able to convert the case statement to a subvi by selecting case structure then creating subvi from edit menu.  I did not edit the subvi icon yet.  There is no need to modify the connector pane that was generated by LabView yet.

 

I copied and pasted a second  set of controls, added the subvi, and wired it together.  Well it wasn't nearly that easy but I got there.

 

Regards

Download All
0 Kudos
Message 4 of 4
(3,335 Views)