In my last post I gave a simple method used to simulate the unavailable hardware (be it cRIO, bench-top instruments, PXI or any kind) which can communicate to LabVIEW application. I also mentioned that I simulate using data sockets which I will explain in this article.
Data socket is a pretty much like a global variable. According to NI…
DataSocket is an easy-to-use, high-performance programming tool that is designed specifically for sharing and publishing live data in measurement and automation applications between different applications and between machines across the Internet. DataSocket for LabVIEW simplifies live data exchange between different applications on one computer or between computers connected through a network.
Simulation using data socket is more similar to earlier explained simulation using boolean as input to instrument driver VI. On top of that boolean input, I configure the simulated measurements to have data sockets connected and I have a separate simulation VI. If you are curious how to establish data-socket, scroll down of this article.
In my instrument driver, I will have case structures surrounding the hardware accessing functions. This case structure helps to avoid communicating with hardware when I’m in simulation mode.
In simulation mode, i.e., other side of the case structure, I do not pass out any data. However, the measurement indicators will have the data sockets connected to it.
In my separate simulation VI, I change values of simulated data. The controls in this VI will have data socket connected. Eventually this will change the data to software.
I see that using data-socket based simulation is advantageous when
I need to test the process or work-flow of the automated production line.I need to verify the handshaking between two process (eg. PLC and cRIO) .I don’t have software application built; but need to test the hardware arrangements working correctly.I don’t have hardware but need to verify the software.I need to develop software and hardware simultaneously and independently.
Here is a GIF record of how this simulation works.
Download this sample code for your exploration.
How to Establish Data Socket
In order to use data socket, you need to run Data Socket Server. Data Socket server is the heart of this simulation method which transfers your simulated values from simulation VI to the software. You can start the server by searching for in Start Menu of Windows.
Data socket for a controls or indicators can be enabled in Data Binding properties of the respective controls.
Path in the data socket is unique for each control and indicator of the instrument driver VI. For example in the above picture, dstp://localhost/measVoltNum is unique address for the control Measured Voltage. If another control say "Valve" is there in your application, then address for that could be like dstp://localhost/ValveBool . Looks very boredom job? Yes, you need to do this for all controls in simulation VI and use the same data binding address for the controls used in the application.
Once you have done that, you will find the controls in simulation VI have a small boolean box which turns green once it gets connected to the data socket server.
Ajay is a professional developer and architect of NI-LabVIEW applications with extreme interest in getting the hardware connected to LabVIEW and automating the stuff. Recently he is also putting his hands in NI-TestStand to get very dirty on it. He is also a good mentor for the various interns in his career. He is ready to help the people in techie roles.