While many RT targets run headless, it is often useful to display information from the RT target or send commands to the real-time application. To accomplish these tasks, you can create a user interface that runs on the host computer or on the RT target (for RT targets that support the embedded UI or remote front panels). In this part of the tutorial, we create a UI that allows the user to stop the real-time application from the host computer.

Adding a VI to the Host Computer

Unlike RT target VIs, you do not need to deploy a host computer VI before running. Because you are developing on the host computer, LabVIEW automatically saves the VI to the computer.

Complete the following steps to add a new VI to the host computer:

  1. In the Project Explorer window, right-click My Computer and select New»VI from the short-cut menu.
  2. In the front panel, select File»Save to save the VI.
  3. Name the VI Windows Main.
  4. Click OK.

Creating an Event Case to Stop the Application

In the tutorial's UI, the Event structure waits for the user to press the Stop button. You set the period of the Event structure to match the Timed Loop to synchronize the Event structure with the loops running on the RT target.

Complete the following steps to create an Event structure that waits for the user to press the Stop button:

  1. Add a Stop button to the front panel of Window Main.vi.
  2. Enter Stop Application in the Stop button label.
  3. Add a While Loop to the block diagram of the VI.
  4. Add an Event structure within the While Loop.
  5. Right-click the selector label of the Event structure and select Add Event Case from the short-cut menu to display the Edit Events dialog box.
  6. Select Stop Application in the Event Sources list box.
  7. Select Value Change in the Events list box.
  8. Click OK.
  9. Place the Stop Application control within the Event structure.
  10. Right-click the Event Timeout terminal of the Event structure and select Create Constant from the short-cut menu.
  11. Enter 250 as the constant to match the period of the Timed Loop in Real-Time Main.vi.

Synchronizing the Stop Functions of Both VIs

This section explains how to synchronize the stop functions of all of the loops in the application using the same shared variable that you used in Real-Time Main.vi. With the entire application linked to one Stop button, you can stop all processes within the application safely and simultaneously.

Complete the following steps to synchronize the stop functions of the application:

  1. Place a copy of the Active? variable within the Event structure in Windows Main.vi.
  2. Right-click the Active? variable and select Access Mode»Write from the short-cut menu.
  3. Add a Not function within the Event structure.
  4. Add an Or function outside of the Event structure but within the While Loop.
  5. Wire the output of the Stop Application control to the x input of the Not function.
  6. Wire the output of the Stop Application control to the x input of the Or function.
  7. Wire the .not. x? output of the Not function to the Active? input of the Active? variable.
  8. Wire the x .or. y? output of the Or function to the conditional terminal of the While Loop.

Adding Error Handling

As in other parts of the tutorial, it is recommended to wire the error terminals for functions.

Complete the following steps to connect error wires in Windows Main.vi:

  1. Right-click the error out output of the Active? variable and select Create»Indicator from the short-cut menu.
  2. Right-click the error in input of the Active? variable and select Create»Constant from the short-cut menu.
  3. Place the error in constant outside and to the left of the While Loop.
  4. Wire the error in constant through the While Loop and the Event structure and connect it to the error in input of the Active? variable.
  5. Wire the error out output of the Active? variable to the y input of the Or function.
  6. Place the error out indicator outside and to the right of the While Loop.
  7. Wire the error out output of the Active? variable to the input of the error out indicator.
  8. Select Timeout in the Event structure selector label.
  9. Connect the error wire through the Event structure.
  10. Right-click one of the two While Loop error tunnels and select Replace with Shift Register from the short-cut menu.
  11. Click the other While Loop error tunnel to replace it with a shift register.
  12. Save the VI.

Result

When you run Real-Time Main.vi and Windows Main.vi and click the Stop Application button in Windows Main.vi, LabVIEW stops the entire application, including the loops running within Real-Time Main.vi.