Here I will present some LabVIEW applications where I have used the "State-machine" principle to make the LabVIEW Block Diagrams. Using the "State-machine" principle makes it easier to create more complex LabVIEW Applications, it makes it easier to extend and maintain your application in the future. Even for small LabVIEW applications, the "State-machine" principle is easy to use.
Below you can download the code and use it as a template for your own application(s).
Here I will present 2 different LabVIEW Applications:
The LabVIEW Application Examples are presented in the Video below:
The video is also available from my official YouTube Channel: https://www.youtube.com/IndustrialITandAutomation
It is also a good idea to structure your code using the Project Explorer in LabVIEW.
Below we see the Project Explorer:
If you are using the Project Explorer, it is also very easy to make executables, i.e., create professional applications which you can use and distribute without the need of having LabVIEW installed on the computer. You only need the LabVIEW Run-Time Engine, which you can download and use for free without having a LabVIEW license.
The OPC UA Server is created with the LabVIEW OPC UA Toolkit. Optionally, the data can also stored in a SQL Server.
Below we see the main OPC UA Server User Interface:
This is a basic example only providing one tag, but you can easly extend the program if needed.
OPC UA server Block Diagram:
Below you see the Block Diagram for the OPC UA Server Application:
Here you see the "State-machine" principle. Basically, a "State-machine" is a Case structure within a While Loop, which makes it easy and very flexible to make larger LabVIEW Applications. It is also easier to maintain, finding and fixing bugs, etc.
Below we see the main User Interface for the Control Application:
To run the application, you need to start the OPC UA server first, and you also need to setup your SQL Database (which is included in the download package, see below).
Control Application Block Diagram:
Below you see the Block Diagram for the Control Application:
Here you can also see the "State-machine" principle. Basically, a "State-machine" is a Case structure within a While Loop, which makes it easy and very flexible to make larger LabVIEW Applications. It is also easier to maintain, finding and fixing bugs, etc. Here you also see an "Event" structure which makes it easy to handle different events like button clicks, etc.
Control Application Configuration:
Under Configuration you can configure the DAQ settings, the Database connection, OPC settings, etc.
All these values are stored in a configuration file, which means the values you enter here will remain the same next time you open the application. You can also easily make changes to the configuration without changing the block diagram/your code. In that way you can create executable applications that can be used without having the LabVIEW software.
Below you see the Configuration.ini file. Here is the different DAQ, PID, OPC, and Database settings stored.
Making Executable Applications (EXE Applications):
If you use the Project Explorer during development of your LabVIEW Application it becomes easy to make an Executable Applications.
Here I have created executables for both the Control Application and the OPC UA Server Application. In that way you use or deploy your applications so that they can be used without having the LabVIEW software installed on the computer you shall use them.
Here you can download the LabVIEW Code.
You will also need my LabVIEW SQL Toolkit, which you find on my Database Communication in LabVIEW web site.
For more advanced applications and examples, see Datalogging and Monitoring page.
With this Application you can Log measurement Data using e.g., an USB-6008, to Files, Databases, etc.
This Examples uses programming techniques such as the State Machine principles, Event handling Local/Gloabal variables, Property Nodes, Arrays, String Manipulation, Shift Registers, Writing and Reading to Files, Writing/Reading to/from Database, Web Services, Error Handling, SubVIs, etc.
This Example also shows how you can create Executable Files and Installation Packages with LabVIEW.
More LabVEW Videos:
LabVIEW Features Videos - A set of Videos explaining all the main Features in LabVIEW - both basic features and more advanced Features like using References, Shift Registers, create and use State Machines, Web Services, etc.
LabVIEW Applications Videos - Here we use LabVIEW for real Applications like Data Logging (DAQ), OPC, Hardware in the Loop, Database Systems, Control and Simulations, Model Predictive Control (MPC), etc.
LabVIEW Video Collection - Here are a collection of ALL my LabVIEW Videos at YouTube.