Applicable VersionsNetSim StandardNetSim Pro


Applicable Releases
v12.2
v13.0


TABLE OF CONTENTS


Introduction

NetSim can be interfaced with LabVIEW, which allows users to interact with LabVIEW during run-time. LabVIEW can interact and control the behavior of its Models. 


LabVIEW is a system engineering software for applications that require test, measurement,  and control with rapid access to hardware and data insights. NetSim now has a method of Interfacing with LabVIEW in a fashion similar to that of MATLAB interfacing. NetSim can initialize a LabVIEW Virtual Instrument (.vi) file during runtime, pass inputs to components of the file, execute the vi, read the computed parameters from its components, and terminate the vi instance at the simulation end.


Softwares used

  • NetSim Standard v12.2 or higher
  • LabVIEW 2020
  • Visual Studio Community Edition 2019 or higher

LabVIEW Example

In this article, we have considered a simple LabVIEW Example. NetSim invokes LabVIEW periodically, which in turn generates a random number and passes it to NetSim in run-time.


NetSim-LabVIEW interfacing

Upon interfacing NetSim with LabVIEW the following tasks are performed at simulation start:

  • LabVIEW Engine is initialized
  • LabVIEW GUI window is loaded
  • LabVIEW - Random Number generator Example is loaded

Upon simulating a network created in NetSim the following tasks are performed periodically:

  • LabVIEW generates a random number
  • NetSim reads the data generated by LabVIEW 
  • NetSim Prints the random number to the Simulation console

Output/Metrics specific to this example

  • NetSim Event Trace - LabVIEW event is registered to periodically interact with LabVIEW

Modifications done to NetSim Source codes

Projects: Zigbee

Files

  • 802.15.4.c, 
  • 802.15.4.h, 
  • Zigbee.vcxproj (Project file)

Files added:

  • Labview_Interface.cpp
  • Labview_Interface.h


Procedure to download this project for this example 

Follow the instructions specified in the following link to clone/download the project folder from GitHub using Visual Studio: How to clone Netsim File Exchange project repositories from Github

Other tools such as GitHub Desktop, SVN Client, Sourcetree, Git from the command line, or any client you like to clone the Git repository. 


Note:
It is recommended not to download the project as an archive (compressed zip) to avoid incompatibility while importing workspaces into NetSim.

The cloned project directory will contain the documentation specific to the NetSim version (v12.1/v12.2). 


Secure URL for the GitHub repository: 

NetSim v12.2: https://github.com/NetSim-TETCOS/NetSim-Interfacing-with-LabVIEW_v12.2.git

NetSim v13.0: https://github.com/NetSim-TETCOS/NetSim-LabVIEW-Interfacing-v13.0.git

Procedure to setup NetSim for this example

  • Import the Workspace provided in the repository for interfacing with LabVIEW in NetSim
  • Go to Open Simulation/Open Work option and then click on Workspace Options -> Open Code
  • Change Labview.tlb path as per your installation in Labview_interface.cpp file which has been added to the ZigBee source code project.
  • Rebuild Zigbee project
  • Copy Random_Number.vi LabVIEW file to "C:\Program Files (x86)\National Instruments\LabVIEW 2020\examples"


Running NetSim Simulation scenario

  • Open Example from NetSim i.e Home Screen ->Open Simulation -> LabVIEW_Example
  • NetSim Scenario
  • Run-Simulation


Results


As the simulation runs, NetSim automatically initializes LabVIEW and NetSim triggers generation of new random numbers in the LabVIEW model and also gets and prints them to the simulation console as shown below:

NetSim Run-time Simulation interacting with LabVIEW