You can use the Custom VI-based Server – Periodic Wizard to create a periodic I/O server. The Custom VI-based Server – Periodic Wizard converts a VI into a custom I/O server that runs as a service and publishes NI Publish-Subscribe Protocol (NI-PSP) data items to the network. LabVIEW automatically launches, registers, initializes, performs error handling, and shuts down the periodic I/O server when necessary.
The Shared Variable Engine launches the periodic I/O server when you load a LabVIEW process that includes a periodic I/O server. The periodic I/O server executes until the specified stop condition occurs. If the stop condition occurs and the periodic I/O server does not shut down by the specified timeout value, the VI aborts and generates an event of priority 500.
Creating a Periodic Custom I/O Server in LabVIEW
Before you create a periodic I/O server in LabVIEW, first create a data access VI that retrieves or emulates hardware data values in a loop structure. You then can use the Custom VI-based Server – Periodic Wizard to convert the VI to a periodic I/O server and configure the periodic I/O server in a process.
Guidelines for Creating a Data Access VI
Use the following guidelines when you create the data access VI:
- Make sure the VI does not contain any Event structures or user interface interaction.
- Make sure all While Loops terminate. While Loops must terminate so the Shared Variable Engine can stop the VI.
- Make sure all loops are timed in the same way.
- Make sure controls and indicators that you want to publish from the top-level VI do not contain local variables, property nodes, or control references. The server synchronizes control and indicator values with NI-PSP data items only when a value is read or written at the control terminal. Modifying the value using a local variable, property node, or control reference can cause the data to be out of sync with NI-PSP data items.
- If you select a While Loop in the top-level VI as the way to stop the server, configure the While Loop as either Stop if True or Continue if True. Do not use Stop on Error or Continue while Error.
- Use double-precision, string, and Boolean data types when you create a VI to convert into a custom I/O server. These data types are the most efficient to use when publishing data items. LabVIEW converts data types other than double-precision, string, and Boolean data types to variants, which can slow down the performance of the server.
The Custom VI-based Server – Periodic Wizard checks these items when you attempt to convert a data access VI to a periodic I/O server.
Converting the Data Access VI
To convert the data access VI into a periodic I/O server, right-click My Computer or a project library in the Project Explorer window and select New»I/O Server from the shortcut menu. In the Create New I/O Server dialog box, select Custom VI - Periodic and click the Continue button to create and configure the periodic I/O server. The Custom VI-based Server – Periodic Wizard creates the following files:
- A VI template saved as National Instruments\Shared\DSC\Custom VI Periodic Server\8.0\templates\vislt_filename.vit
- A registration VI saved as National Instruments\Shared\DSC\Custom VI Periodic Server\8.0\registration\vislr_filename.vi
- DLLs and VIs in the National Instruments\Shared\DSC\Custom VI Periodic Server\8.0\templates\filename folder
Testing a Periodic I/O Server
Use the NI Shared Variable Monitor to ensure that the periodic I/O server publishes values as expected.
Deploying a Periodic I/O Server
Before you can deploy an application that includes a periodic I/O server, you must copy the following items to the deployment computer:
- The registration VI, vislrfilename.vi, located in the National Instruments\Shared\DSC\Custom VI Periodic Server\8.0\registration\ folder
- The VI template, vislt_filename.vit, located in the National Instruments\Shared\DSC\Custom VI Periodic Server\8.0\templates\ folder
- The subVIs located in the National Instruments\Shared\DSC\Custom VI Periodic Server\8.0\templates\filename folder