12-14-2013 09:52 PM
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
12-14-2013 10:04 PM
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
12-14-2013 10:15 PM
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
12-17-2013 11:02 PM
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