Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Feb 15, 2007


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Sharing Data using Time-Triggered Shared Variables

4 ratings | 4.00 out of 5
Print

Overview

You can use shared variables to share data among VIs in a project or across a network. The Real-Time FIFO of a network-published shared variables enable sharing data between VIs on different targets across a network without affecting the determinism of the VI. However, network-published shared variable transfers data transfer data across the network non-deterministically. Figure 1, shows a network-published shared variable that is sharing data with another VI on a different RT target.


Figure 1. Sharing Data Using Network-Published Shared Variables


The network-published shared variable deterministically transfers the data to the Shared Variable Engine (SVE) running on the RT target. The Shared Variable Engine then transfers the data to the other RT target using non-deterministic communication.

Time-triggered shared variables share data between VIs and then transfer the data across a closed private network, or time-triggered network, deterministically. Other RT targets on the time-triggered network then can access the data.


Figure 2. Sharing Data Using Time-Triggered Shared Variables


Time-triggered communication with the LabVIEW Real-Time Module requires you to configure RT targets for time-triggered communication, create and configure time-triggered shared variables, and to configure the settings of the time-triggered network..

Configuring RT Targets for Time-Triggered Communication

Deterministic network communication using time-triggered shared variables requires your to configure RT targets with two Ethernet devices. One Ethernet device (primary) connects to the public network and is used to communicate with LabVIEW on the host computer. You can deploy software and applications to the RT target though this connection from the host computer. The secondary Ethernet device of an RT target connects to the secondary Ethernet devices of other RT targets using a crossover cable, network hub, or non-blocking Ethernet switch. The secondary Ethernet devices create a time-triggered network that you must then configure for time-triggered communication. All time-triggered communication is done on the time-triggered network of the secondary Ethernet devices.

Figure 3 shows a network of PXI RT targets that are setup as a time-triggered network. Notice the Closed Private Network used for the time-triggered communication between the RT targets and the Public Network used to communicate with the host computer.




Figure 3. Time-Triggered Communication

Note Devices or RT targets that are not configured for time-triggered communication disrupt the speed of a time-triggered network. Remove device not configured for time-triggered communication from the closed private network.

Complete the following steps to configure an RT target for time-triggered communication.

Supported RT targets: PXI 8170 & later. Desktop PC with Intel (P3 or later) or Athlon processors.
Supported Ethernet devices for PXI RT Targets: NI 8212, 8232, 8211, 8231 Ethernet Modules
Supported Ethernet devices for PC RT Targets: Intel based 82559, 82540 Network Interface Cards, such as the NI PCI-8232.

  1. In MAX, expand an RT target under the Remote Systems category of the configuration tree. Click the Network Settings tab on the right pane of the MAX window to display the network settings of an RT target. Configure the network settings of the RT targets using Measurement & Automation Explorer (MAX). MAX configures the network settings of the primary Ethernet device.
  2. Power down the RT target and then install the secondary Ethernet device. Refer to the RT target documentation for more information about installing devices for the target.
  3. Power on the RT target.
  4. From the Network Settings tab in MAX, click the Advanced Ethernet Settings button to open the Advanced Ethernet Settings dialog box.
  5. Select the secondary Ethernet device from the Ethernet Devices (by MAC Address) listbox. The primary Ethernet device is labeled as (primary).
  6. Select Time-Triggered Network from the Mode pull-down menu in the Ethernet Device Settings section.
  7. Click the OK button and then Reboot the RT target.
  8. Repeat steps for all RT targets you want to configure for time-triggered communication.

Note If you format the file system of the RT target after you configure a secondary Ethernet device, you will lose all Ethernet settings when you boot the target into safe mode and the RT target might recognize the secondary Ethernet device as the primary connection. Remove the secondary Ethernet device from the RT target and repeat steps 1-7 to reconfigure the target.

Creating Time-Triggered Shared Variables


You can create time-triggered shared variables under an RT target in the Project Explorer window. Figure 4 shows a LabVIEW project with two RT targets, PXI-RT and PXI-RT 2, configured for time-triggered communication.

Figure 4. LabVIEW Project with Time-Triggered Shared Variables

Complete the following steps to create a time-triggered shared variable under an RT target in the Project Explorer window.

  1. Create a new LabVIEW project or open an existing project.
  2. Add to the project an RT target that you configured for deterministic communication.
  3. Right-click the RT target and select New»Variable from the shortcut menu to open the Shared Variable Properties dialog box.
  4. Set the name and data type of the variable using the Name text box and the Data Type pull-down menu. The Custom type requires the use of a custom control or typeset. Refer to the LabVIEW Help for information about creating customs controls and typesets.
  5. Select Time-Triggered from the Variable Type pull-down menu.
  6. Select the communication style for the shared variable from the Variable Communication Style section.

    You can use either of the following two communication styles on the time-triggered network.

    • As part of the shared memory blocks–The time-triggered shared variables under an RT target are all transmitted during a shared memory block in the communication cycle of the time-triggered network. You can specify an offset from the start of the communication cycle for when you want to begin the transmission of the blocks for each RT target as shown in Figure 5. The shared memory blocks, containing the SMB variables for each RT target, are transmitted one after the other with no time gap between targets.

      Figure 5. Time-Triggered Shared Variables in Shared Memory Blocks

    • During a dedicated time slot within the network cycle–The time-triggered shared variables under an RT target are transmitted individually during a specific time slot in the network cycle that you specify. You can specify an offset from the start of the communication cycle when you want to begin the transmission of each time-triggered shared variable. You also can rearrange the order in which the shared variables are transmitted as shown in Figure 6.

      Figure 6. Time-Triggered Shared Variables with a Dedicated Time Slot



      • Microseconds into the network cycle–Specifies the offset from the start of the time-triggered network's communication cycle when the time-triggered shared variables will transmit data to all targets that are reading the data on the network.

        Note You cannot specify a specific order for the transmission of data using time-triggered variables configured with the As part of the shared memory blocks option. However, the During a dedicated time slot within the network cycle option requires a small added overhead in the transmission times. This is more noticeable when working with smaller data types such as scalars.





  7. Specify the size of the length or number of elements in the Size of the Variable section if you selected to create a shared variable of string or array data type.
  8. Click the OK button to accept the settings and create the shared variable under the RT target in the Project Explorer window.

After configuring the RT target for time-triggered communication and creating time-triggered shared variables, you must configure the time-triggered network.

Configuring a Private Network for Time-Triggered Communication


Use the Network Configuration dialog box to configure the time-triggered network. Select Tools»Real-Time Module»Configure Time-triggered Network from the Project Explorer window to open the Network Configuration dialog box. The Network Configuration dialog box displays a tree view of the time-triggered network. The top-level parent node is the Network node which represent the time-triggered network. The Network node contains child nodes for each RT target on the time-triggered network that is configured for time-triggered communication. Each Target node contains a node for each time-triggered shared variable hosted on that RT target.

[+] Enlarge Image
Figure 7. Network Configuration Dialog Box

You can click the Network, Target, and Shared Variable nodes on the Network Configuration dialog box to display a configuration page for that node on the right side of the dialog box.

The Network Configuration dialog box displays a timeline graph at the bottom of the window that represents the current configuration of the time-triggered network cycle.

Complete the following steps to configure the time-triggered network for time-triggered communication.

  1. Select Tools»Real-Time Module»Configure Time-triggered Network to open the Network Configuration dialog box.
  2. Click the Network node to display the Timed-triggered Network page. Use the Timed-triggered Network page to set the network speed, cycle time, and reflection time for time-triggered shared variables of SMB type. The network speed must be set to the speed of the slowest Ethernet device on the time-triggered network. The cycle time specifies the period of the communication cycle. The reflection start time specifies the time during the cycle when the time-triggered network begins to transmit the data of all the time-triggered shared variables configure as part of as part of the shared memory blocks.
  3. Click a Target node to display the Target page. Use the Target page to set a new id for an RT target, specify the speed of the secondary Ethernet device for the target, and to specify the MAC address of the secondary Ethernet device. The target ID is used to identify the RT target on the time-triggered network and must be unique between targets. You can choose to auto select the secondary Ethernet device or you can provide the MAC address for the device. The master RT target in the time-triggered network is labeled as (master).

    The Network Configuration dialog box displays a timeline graph at the bottom of the window. The timeline shows the Cycle Start block and the time-triggered variable transmission blocks. The time-triggered shared variables that you configured as part of a shared memory block are shown in blue and labeled by the name of the RT target defined in MAX. Time-triggered shared variables of dedicated slot type are shown in yellow. You can rearrange the blocks on the timeline by clicking the target's label and then dragging across the timeline configure the transmission times in the network cycle. The timeline displays conflicting blocks in red.

    Note You can only set an offset for the first shared memory block by dragging on the time-line. All other shared memory block for other RT targets will transmit in order after the first block. Specify time-triggered variable of dedicated time slot type if you want to set offsets between the transmission of variables or to rearrange the transmission order.


  4. Drag the blocks in the timeline to resolve any conflicts between different communication blocks and to configure the precise time for each communication block to transmit data.
  5. Click the Check Configuration button to test the current configuration of the deterministic network. The Network Configuration dialog box will return error conditions or conflicts.
  6. Click the OK button to save the time-triggered network settings and close the Network Configuration dialog box.


Figure 8 shows a time-triggered network configured with a 300 microsecond network cycle that begins the transmission of shared memory block variables 100 microseconds into the network cycle and then transmits a dedicated block variable 189 microseconds into the network cycle.

[+] Enlarge Image
Figure 8. Time-Triggered Network Configured to Transmit SMB and Dedicated Slot Variables

Sharing Data Using Time-Triggered Shared Variables


To share data using time-triggered shared variables, drag the variable from the Project Explorer window to a block diagram. You also can place a Shared Variable node on the block diagram and then right-click the node and select Select variable from the shortcut menu to select the time-triggered shared variable.
By default, the Shared Variable node is set to read. To change the Shared Variable node on the block diagram to write, right-click the Shared Variable node and select Change to write from the shortcut menu. Figure 9 shows a block diagram with a Shared Variable node, TT_Var1, that reads the value of a time-triggered shared variable and the adds a value of 10. The diagram then writes the results to a Shared Variable node, TT_Var2, that can be read by other RT targets on the time-triggered network.

Note You only can write to a time-triggered shared variable from VIs running on the RT target that hosts the shared variable. Also, you cannot read a dedicated time slot variable from the RT target where you host the variable.


Figure 9. Reading and Writing Values to Time-Triggered Shared Variables


Controlling Timed Structures with Timing Sources from Deterministic Networks


You can create time-triggered timing sources to control the execution of a timed structure in a VI running on an RT target. Time-triggered timing sources trigger when a specified event in the time-triggered network occurs. The LabVIEW Real-Time Module provides the Create Time Triggered Network Timing Source VI that you can use to capture when a timing source fires and then control the execution of a Timed Loop or Timed Sequence.

Creating a Timing Source



Note It is not required that you create a timing source to control timed structures. You can use the default network timing source, NetworkUSTSrc.

Complete the following steps to create a time-triggered timing source on the time-triggered network.

  1. Select Tools»Real-Time Module»Configure Time-triggered Network from the Project Explorer window to open the Network Configuration dialog box.
  2. Right-click the Network node and select Add Timing Source from the shortcut menu. A Timing Source node appears in the Network Configuration tree.
  3. Click the Timing Source node and specify the timing source name and type. Available timing source types:

    • SMBs Reflected—Fires on the first occurrence when all targets on the time-triggered network that host SMB variables start to transmit data. After the first occurrence, the timing source fires when the all SMB blocks for the network have transmitted their data in the cycle. This behavior allows you to synchronize the start of timed structures on all targets by waiting for all target to come online.
    • SMB Reflected—Fires when a specific SMB block has transmitted its data in the cycle. You must select an RT target to associate with the timing source.
    • Channel Stop—Fires when the sending node finishes sending data. Data may not have been received by the receiving node. You must select a variable to associate with the timing source.
    • Channel Start—Fires when the sending node begins to transmit data. Data may not have been received by the receiving node. You must select a variable to associate with the timing source.
    • Data Sent—Fires when data is transmitted from the sending node. You must select a variable to associate with the timing source. Only available for use on the RT target that hosts the time-triggered shared variable.
    • Data Received—Fires when data is received by the receiving nodes. You must select a time-triggered shared variable to associate with the timing source. Only available for use on the RT targets that receive data from the time-triggered shared variable.
    • Default Network Timing Source (Network USTSrc)—This is the default timing source used by the time-triggered network. The default network timing source is a built-in The time-triggered network can use this timing source to control the execution of time structures if you do not create a timing source.

  4. Select the associated variable if you selected a Data or Channel timing source type.
  5. Select the associated RT target if you selected the SMB Reflected timing source type.

Controlling a Timed Structure with a Timing Source



Use the Create Time Triggered Network Timing Source VI, located on the Real-Time Module»Time-Triggered Network palette, with a time-triggered network timing source to control a Timed Loop or Time Sequence. The Create Time Triggered Network Timing Source VI fires a trigger that controls the execution of a timed structure when a specific event on a time-triggered network occurs.


Figure 12. Create Time Triggered Network Timing Source VI
Parameters:

  • error in—Propagates error conditions that occur before the execution of this VI.
  • Timing Source—Returns the name of the selected timing source. You can wire this output to a timed structures Timing Source terminal to synchronize the structure with the selected network activity.
  • Cycle time—Returns the configured time for the time-triggered network in milliseconds. Only available for the default network timing source.
  • error out—Returns error conditions that were passed into the VI or that occurred during the execution of the VI.


Complete the following steps to use a timing source from a time-triggered network to control the execution of a timed structure.

  1. Place the Create Time Triggered Network Timing Source VI on the block diagram.
  2. Right-click the Create Time Triggered Network Timing Source VI and select Select Timing Source from the shortcut menu to select a timing source that you have created on the time-triggered network. You can also use the default time-triggered network timing source. The default time-triggered network timing source is synchronized to the microsecond timing engine of the master node.
  3. Wire the Timing Source output of the Create Time Triggered Network Timing Source VI to the Source Name input on the Left Data node of the timed structure.

[+] Enlarge Image
Figure 13. Controlling a Timed Loop with a Deterministic Network Timing Source


Handling Time-Triggered Network Errors


Use the Handle Timed-Triggered Network Error VI with a time-triggered timing source to handle error conditions returned when you read from or write to a time-triggered shared variable. The Handle Timed-Triggered Network Error VI also can stop the transmission of data from nodes on the time-triggered network or shut down the entire network if an error occurs.

Figure 10. Handle Timed-Triggered Network Error VI
Parameters:

  • Action— Defines the action to take when an error occurs.

    • Ignore Error—Ignore timing source errors and continue execution of the diagram.
    • Stop All Node Transmissions—Stops the transmission of data from the node. The node continues to receive data transmitted from other nodes in the time-triggered network.
    • Shut Down Node—Stops the transmission of data from the node and shuts down the node. The node will no longer transmit or receive data from the time-triggered network.
    • Shut Down Network—Stops the transmission of data from the node and shuts down the node. The node also sends a shutdown message to all nodes in the time-triggered network.

  • error in—Propagates error conditions that occur before the execution of this VI.
  • error out—Returns error conditions that were passed into the VI or that occurred during the execution of the VI.


Figure 11 shows a VI that uses the Handle Timed-Triggered Network Error VI to shut down transmission from a node on the time-triggered network if an error occurs during a read.

Figure 11. Handling Time-Triggered Network Errors


4 ratings | 4.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).