LabVIEW Time Sensitive Networking (TSN)


Deterministic Communication - TSN API Example

Deterministic Comm.PNG


This example demonstrates how to use the TSN driver to create a single Talker/Listener application for deterministic data streaming. This driver provides direct access to the fields of a TSN frame and executes based on configuration information entered directly by the user.  This information would normally come from a network configuration tool (CNC) used to set-up the switches.  When directly connecting two NI controllers the default values will also work.


Using Example with Cisco IE 4000 TSN Switch:


Cisco IE4000 alone provides 802.1as synchronization for rest of the TSN devices on the network but in order to stream deterministic data through the switch it is necessary to configure it using Cisco centralized network configuration (CNC) tool.  For more information about obtaining IE 4000 switch and optional CNC tool visit this page. CNC tool will provide necessary information needed to configure a stream in TSN API:

DMAC -    The MAC address associated with the stream

VID -         VLAN ID number

PCP -        Priority Code Point

Period -     Network communication period for all talkers and listeners on a TSN network

Tx Offset - Offset in time since the start of the period when the talker should transmit its data

Rx Offset - Offset in time since the start of the period when the reader should receive its data. 



Optionally this example shows how to take advantage of the time-stamping features of the driver to characterize the behavior of the network. Time stamping can be turned off for all talkers, allowing them to send TSN frames without additional header information.



General Instruction Installing a VI Package (.vip) Example:


Download the attached .vip package to your PC. Double click on the .vip package which should open up a VI Package Manager (VIPM). In the VIPM window click on the "Install" button on the top left corner and wait for the installation to finish. Once the installation is finished, the example can be accessed from the LabVIEW example finder. In any LabVIEW windows click on Help>>Find Examples...>> Select 'Directory Structure' radio button>> scroll down and find TSN Community Examples directory. 
Alternatively, example source code will be placed in C:\<Program Files>\National Instruments\LabVIEW 2017\examples\TSN Community Examples directory.


example finder.PNG


We recommend using the code provided on this page.  It has a few additions and enhancements for status monitoring and to help reduce errors:

Message 1 of 33

Rif.: Deterministic Communication - TSN API Example

Thanks for putting this code together. Some remarks to avoid dummy configuration errors


  • Stream conf from CNC cluster is where the parameters from the CNC tool have to be added. In particular:
    • DMAC: use xX-Yy-Zz-Aa-Bb-Cc formatting instead of te one with : (Xx:YY:ZZ etc) provided by the cisco CNC web UI. There's not format checking on the string so no error is returned if you use the wrong formatting
    • VLANID should be left to 3000 since this is the ID given by default to the LAN composed by End stations. You can double check by issuing the show vlan command on the switch CLI and then show vlan id 3000 to check that the Gb1/x ports you connected the TSN end stations to are listed under ports category

It's not mandatory to change App Timing config and Stream Conf from App cluster elements unless you have to want to tune the communication.


Hope this helps.


Fabio M.
National Instruments
Principal Systems Engineer
0 Kudos
Message 2 of 33

Re: Deterministic Communication - TSN API Example


I have the following question: When I try to load the Simple TSN from the Deterministic Comm - TSN API Example LV project, the following VIs are missing: 1588 time to LabVIEW and LabVIEW time to 1588

What needs to be installed additionally to the installations mentioned in the instructions in "Installing Software and Hardware Setup for NI TSN Devices" ...?

Thank you in advance ...


0 Kudos
Message 3 of 33

Re: Deterministic Communication - TSN API Example

I think in the latest installer they changed the name from "1588 time" to "absolute time". 


It is installed in vilib or if you install the community tools the VI will appear on the pallet so you can replace it.  We also updated the community monitor tools recently (last week) so it should have the correct linking:

0 Kudos
Message 4 of 33

Re: Deterministic Communication - TSN API Example

Hi Andreas,


With 17.0 TSN driver those VIs are located in:

C:\Program Files (x86)\National Instruments\LabVIEW 2017\vi.lib\TSN Toolkit


With 17.5 TSN driver they were renamed to 'Absolute Time to LabVIEW' and 'LabVIEW Timestamp to Absolute"

C:\Program Files (x86)\National Instruments\LabVIEW 2017\vi.lib\tsndriver\internal


Alternatively, you can install the TSN Community Tools Base Package and you should be able to find those VIs in the palette.

Or manually in C:\Program Files (x86)\National Instruments\LabVIEW 2017\user.lib\_TSN Community Tools


0 Kudos
Message 5 of 33

Re: Deterministic Communication - TSN API Example

Thank you!

0 Kudos
Message 6 of 33

Re: Deterministic Communication - TSN API Example


On my Industrial Controller (IC-3172), TSN works only with the first Ethernet port (eth1). On other ports: eth2-eth4, I receive a TSN driver error. I have tried changing all the ports from the block diagram of this example, but no success.

I feel like TSN is not enabled on other ports in firmware etc..

Sorry, I am not sure whether it's a right place to post this problem, maybe I should have opened another thread or contact the CS. 



0 Kudos
Message 7 of 33

Re: Deterministic Communication - TSN API Example

Hi Stalemate,


Can you post the error code you are getting? I am assuming its coming from the Am I correct?

0 Kudos
Message 8 of 33

Re: Deterministic Communication - TSN API Example

Hi Miro,


Yes, exactly. Sorry I can only get the error code tomorrow. Which other things (images, VIs, kernel version) should I post?


Thank you and regards 

0 Kudos
Message 9 of 33

Re: Deterministic Communication - TSN API Example

The error code would be enough. And maybe confirm your NI TSN driver version. I am assuming NI TSN 17.5


Thank you

0 Kudos
Message 10 of 33
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.