LabVIEW Real-Time Module User Manual
LabVIEW Real-Time Module User Manual
TM
Worldwide Offices
Australia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599,
Canada (Calgary) 403 274 9391, Canada (Ottawa) 613 233 5949, Canada (Québec) 450 510 3055,
Canada (Toronto) 905 785 0085, Canada (Vancouver) 514 685 7530, China 86 21 6555 7838,
Czech Republic 420 224 235 774, Denmark 45 45 76 26 00, Finland 385 0 9 725 725 11,
France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, Greece 30 2 10 42 96 427, India 91 80 51190000,
Israel 972 0 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970, Korea 82 02 3451 3400,
Malaysia 603 9131 0918, Mexico 001 800 010 0793, Netherlands 31 0 348 433 466,
New Zealand 0800 553 322, Norway 47 0 66 90 76 60, Poland 48 22 3390150, Portugal 351 210 311 210,
Russia 7 095 783 68 51, Singapore 65 6226 5886, Slovenia 386 3 425 4200, South Africa 27 0 11 805 8197,
Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51, Taiwan 886 2 2528 7227,
Thailand 662 992 7519, United Kingdom 44 0 1635 523545
For further support information, refer to the Technical Support and Professional Services appendix. To comment
on the documentation, send email to [email protected].
Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects
in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National
Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives
notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be
uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before
any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are
covered by warranty.
National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical
accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent
editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected.
In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES , EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE . C USTOMER’S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF
NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR
DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY
THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including
negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments
shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover
damages, defects, malfunctions, or service failures caused by owner’s failure to follow the National Instruments installation, operation, or
maintenance instructions; owner’s modification of the product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire,
flood, accident, actions of third parties, or other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National
Instruments Corporation.
Trademarks
DataSocket™ , FieldPoint™, LabVIEW™, National Instruments™, NI™ , ni.com™ , NI Developer Zone™, NI-CAN™ , NI-DAQ™ , NI-VISA™ , and
TestStand™ are trademarks of National Instruments Corporation.
Product and company names mentioned herein are trademarks or trade names of their respective companies.
Patents
For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the patents.txt file
on your CD, or ni.com/patents.
Chapter 1
Introduction to the LabVIEW Real-Time Module
LabVIEW Real-Time Module Platforms.......................................................................1-1
Real-Time System Components ....................................................................................1-2
Host Computer.................................................................................................1-2
LabVIEW ........................................................................................................1-2
RT Engine........................................................................................................1-2
RT Target.........................................................................................................1-3
RT Series Plug-In Devices (ETS Only) ............................................1-3
Networked RT Series Devices (ETS Only) ......................................1-3
RT Target on the Real-Time Subsystem (RTX Only) ......................1-4
Real-Time Module and Express VI Considerations ......................................................1-4
Unsupported LabVIEW Features...................................................................................1-5
Modifying Front Panel Objects of RT Target VIs...........................................1-5
Using OS-Specific Technologies in RT Target VIs ........................................1-6
Chapter 2
Connecting to RT Targets
Downloading VIs to an RT Target ................................................................................2-3
Closing a Front Panel Connection without Closing VIs................................................2-3
Connecting to VIs Running on an RT Target ................................................................2-4
Configuring RT Target Options.....................................................................................2-5
Chapter 3
Building Deterministic Applications
Creating Multithreaded Applications in LabVIEW.......................................................3-1
Dividing Tasks to Create Deterministic Multithreaded Applications .............3-2
Assigning Priorities to VIs ..............................................................................3-3
Assigning VIs to Execution Systems ..............................................................3-4
Cooperatively Yielding Time-Critical VI Execution ......................................3-5
Passing Data between VIs..............................................................................................3-6
Global Variables..............................................................................................3-6
Functional Global Variables............................................................................3-6
Chapter 4
Timing Applications and Acquiring Data
Timing Control Loops ................................................................................................... 4-1
Timing Control Loops Using Software........................................................... 4-1
Wait (ms) .......................................................................................... 4-1
Wait Until Next ms Multiple Function............................................. 4-2
Real-Time Timing VIs...................................................................... 4-4
LabVIEW Timed Loop (ETS Only) ................................................. 4-4
Timing Control Loops Using Hardware ......................................................... 4-4
Acquiring Data with VIs Running on an RT Target ..................................................... 4-5
RT Series Data Acquisition Devices (ETS Only) ........................................... 4-5
RT Series FieldPoint Modules (ETS Only) .................................................... 4-5
NI PCI-7831 Plug-in Device (ETS and RTX) ................................................ 4-5
Chapter 5
Optimizing Applications
Avoiding Shared Resources .......................................................................................... 5-1
Memory Allocations and Preallocating Arrays............................................... 5-1
Casting Data to Proper Data Types................................................................. 5-3
Reducing the Use of Global Variables............................................................ 5-3
Avoiding Contiguous Memory Conflicts ...................................................................... 5-3
Avoiding SubVI Overhead ............................................................................................ 5-5
Setting VI Properties ..................................................................................................... 5-5
Chapter 6
Debugging Deterministic Applications
Verifying Correct Application Behavior .......................................................................6-1
Using the LabVIEW Debugging Tools ...........................................................6-1
Using the Profile Window ...............................................................................6-2
Using the Real-Time System Manager (ETS Only)........................................6-2
Verifying Correct Timing Behavior ..............................................................................6-3
Using the Tick Count (ms) Function ...............................................................6-3
Using the NI Time Stamp VIs .........................................................................6-3
Using an Oscilloscope .....................................................................................6-3
Using Software Drivers ...................................................................................6-3
Using the LabVIEW Execution Trace Toolkit (ETS Only) ............................6-4
Using and Defining Error Codes ...................................................................................6-4
Chapter 7
Deploying Applications
Building Stand-Alone Applications...............................................................................7-1
Configuring Target Settings ............................................................................7-1
Saving Stand-Alone Applications .....................................................7-2
Selecting a Target after Launch ........................................................7-2
Quitting LabVIEW after Launch ......................................................7-2
Creating an Application Installer.....................................................................7-3
Launching Stand-Alone Applications............................................................................7-4
Launching Embedded Applications Automatically.........................................7-4
Launching Applications Automatically Using Command Line Arguments ...7-5
Connecting to Stand-Alone Applications on an RT Target ...........................................7-6
Appendix A
Technical Support and Professional Services
Glossary
Index
Conventions
The following conventions appear in this manual:
» The » symbol leads you through nested menu items and dialog box options
to a final action. The sequence File»Page Setup»Options directs you to
pull down the File menu, select the Page Setup item, and select Options
from the last dialog box.
bold Bold text denotes items that you must select or click in the software, such
as menu items and dialog box options. Bold text also denotes parameter
names.
monospace Text in this font denotes text or characters that you should enter from the
keyboard, sections of code, programming examples, and syntax examples.
This font is also used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, functions, operations,
variables, filenames, and extensions.
(Platform) Text in this font denotes a specific platform and indicates that the text
following it applies only to that platform. The (RTX) platform tag denotes
content specific to the LabVIEW Real-Time Module for RTX Targets.
The (ETS) platform tag denotes content specific to the LabVIEW Real-Time
Module for ETS Targets.
Related Documentation
The following documents contain information that you might find helpful
as you read this manual:
• RT Series hardware documentation
• Getting Started with the LabVIEW Real-Time Module
• (Mac OS) LabVIEW Real-Time Module for Mac OS X User Manual
Addendum, which describes the differences between the Windows and
Mac OS X versions of the LabVIEW Real-Time Module
• LabVIEW Real-Time Module Release Notes
• LabVIEW Help, available by selecting Help»VI, Function,
& How-To Help
• Getting Started with LabVIEW
• LabVIEW User Manual
• LabVIEW Application Builder User Guide
Venturcom Phar Lap ETS provides a real-time operating system that runs
on NI RT Series hardware to meet the requirements of embedded
applications that need to behave deterministically or have extended
reliability requirements.
Host Computer
The host computer is a computer with LabVIEW and the LabVIEW
Real-Time Module installed on which you develop the VIs for the real-time
system. After developing the real-time system VIs, you can download and
run the VIs on the RT target. The host computer can run VIs that
communicate with the VIs running on the RT target.
LabVIEW
You develop VIs with LabVIEW on the host computer. The Real-Time
Module extends the capabilities of LabVIEW to allow you to select an RT
target on which to run VIs.
RT Engine
The RT Engine is a version of LabVIEW that runs on the RT target.
The RT Engine runs the VIs you download to RT targets. The RT Engine
provides deterministic real-time performance for the following reasons:
• The RT Engine runs on a real-time operating system (RTOS) or RTX
subsystem, which ensures that the LabVIEW execution system and
other services adhere to real-time operation. Refer to Chapter 3,
Building Deterministic Applications, for information about the
LabVIEW execution system.
• The RT Engine runs on RT Series hardware or the RT target on the
RTX subsystem. Other applications or device drivers commonly found
on the host computer do not run on RT targets. The absence of
additional applications or devices means that a third-party application
or driver does not impede the execution of VIs.
• RT targets on which the RT Engine runs do not use virtual memory,
which eliminates a major source of unpredictability in deterministic
systems.
RT Target
An RT target refers to RT Series hardware or the RTSS that runs the RT
Engine and VIs you create using LabVIEW. There are three types of RT
targets: RT Series plug-in devices, networked RT Series devices, and the
RTSS.
This manual does not contain information about the data acquisition
daughterboard of plug-in devices. Refer to the appropriate plug-in device
documentation for information about the data acquisition daughterboard
for plug-in devices.
VIs running on the RTSS can use an NI PCI-7831 plug-in device for data
acquisition. Refer to Chapter 4, Timing Applications and Acquiring Data,
for information about deterministic data acquisition using LabVIEW.
Note Some LabVIEW example VIs use unsupported VIs and functions and do not execute
on an RT target.
Note If you have not configured the hardware in MAX, click the Configure button to
open MAX. Refer to the Remote Systems Help, by selecting Help»Help Topics»Remote
Systems from MAX, for information about using MAX to configure RT Series hardware.
Press the <F5> key to refresh the pull-down menu of the Select Execution Target
dialog box.
Note When you edit a VI or convert a VI from a different version of LabVIEW, you must
save the VI on the host computer before you can download and run it on the RT target.
You also can download LabVIEW VIs without running them by selecting
Operate»Download Application after selecting an RT target as the
execution target. You can determine which VIs are downloaded to the RT
target by selecting Browse»Show VI Hierarchy to open the Hierarchy
window. The VI hierarchy appears with a pin in the upper left corner of
each VI.
When the pin is in the vertical position, as shown to the left, the VI
downloaded to the RT target.
When the pin is in the horizontal position, as shown to the left, the VI has
not downloaded to the RT target.
If you select File»Exit, LabVIEW opens a dialog box that asks if you want
to exit LabVIEW without closing RT Engine VIs. If you click the Yes
button, LabVIEW exits without closing the VIs on the RT target. If you
click the Close all RT Engine VIs button, LabVIEW closes all the VIs
running on the RT target, unloads the VIs from memory, and closes
LabVIEW.
You also can select Operate»Switch Execution Target and then select
another execution target. LabVIEW opens a new front panel connection to
the RT target you select. The VIs running on the original RT target continue
to run.
Note When connecting to an RT Series plug-in device, if you place a checkmark in the
Reset checkbox on the Select Execution Target dialog box, LabVIEW clears all VIs in
memory on the target.
If you moved or modified the local copies of the VIs since you downloaded
them to the RT target, LabVIEW displays the Changed or Missing VIs
dialog box, shown in Figure 2-3.
The Changed or Missing VIs dialog box shows the name of the local VIs
that are missing or that have been modified and no longer match the VIs
running on the RT target. Use the Changed or Missing VIs dialog box to
browse for a VI you moved on the host computer file system, to close all
VIs running on the RT target and update them with the latest version of
each VI, and to close the front panel connection between LabVIEW and the
RT target while leaving the VIs running.
Most computers have only one processor, so tasks execute one at a time.
Computers achieve multitasking by running one application for a short
amount of time and then running other applications for short amounts
of time. As long as the amount of processor time allocated for each
application is small enough, computers appear to have multiple
applications running simultaneously.
system thread according to the VI priority and execution system you assign.
The threads execute on the processor accordingly. You can use
deterministic communication methods to pass data between the
different VIs.
The real-time operating system (RTOS) on RT targets and the RTSS use a
combination of round robin and preemptive scheduling to execute threads
in the execution system. Round robin scheduling applies to threads of equal
priority. Equal shares of processor time are allocated among equal priority
threads. For example, each normal priority thread is allotted 10 ms to run.
The processor executes all the tasks it can in 10 ms and whatever is
incomplete at the end of that period must wait to complete during the next
allocation of time. Conversely, preemptive scheduling means that any
higher priority thread that needs to execute immediately pauses execution
of all lower priority threads and begins to execute. A time-critical priority
thread is the highest priority and preempts all priorities.
Note (RTX) VIs that monopolize processor resources prevent Windows processes from
executing. Windows returns an RTX Starvation Timeout error. You must allow Windows
processes enough processor resources to run by including sleep in RT target VIs. Refer to
the NI Web site at ni.com/info and enter the info code RTX001 for information about
RTX Starvation Timeout errors that might occur when using the LabVIEW Real-Time
Module for RTX Targets.
Note Because time-critical priority threads cannot preempt each other, create only one
time-critical thread in an application to guarantee deterministic behavior.
In addition to the five priority levels listed above, you can set VIs to
subroutine priority. VIs set for subroutine priority do not share execution
time with other VIs. When a VI runs at the subroutine priority level, it
effectively takes control of the thread in which it is running, and it runs in
the same thread as its caller. No other VI can run in that thread until the
subroutine VI finishes running, even if the other VI is at the subroutine
priority level.
The names of the execution systems are suggestions for the type of VIs to
place within the execution system. By default, all VIs run in the standard
execution system at normal priority. The user interface execution system
handles all user interface tasks. You can assign instrument I/O and data
acquisition task VIs to other execution systems, but the labels help to
organize the VIs. In addition to the six execution systems, you also can
assign VIs to the same as caller execution system. The same as caller
category runs subVIs in the same execution system as the VI that called the
subVI.
The execution systems are not responsible for managing the user interface.
If a thread in one queue needs to update the user interface, the execution
system passes responsibility to the user interface execution system, which
updates the user interface.
You must build time-critical VIs that periodically yield, or sleep, to allow
lower priority tasks to execute without affecting the determinism of the
time-critical code. By timing control loops, you can yield time-critical VIs
and cooperatively relinquish processor resources. Refer to Chapter 4,
Timing Applications and Acquiring Data, for information about the
methods available for timing time-critical VIs to relinquish processor
resources.
Global Variables
Use global variables to access and pass small amounts of data between VIs,
such as from a time-critical VI to a lower priority VI.
Using a global variable is a good way to pass data smaller than 32-bits, such
as scalar data, between VIs. For larger amounts of data, use functional
global variables or the Real-Time FIFO VIs. Refer to the LabVIEW User
Manual for information about creating and using global variables.
LabVIEW
Host Computer
RT Engine
RT Target
You also can use front panel communication to debug VIs while they run
on the RT target. You can use LabVIEW debugging tools—such as probes,
execution highlighting, breakpoints, and single stepping—to locate errors
on the block diagram code. Refer to Chapter 6, Debugging Deterministic
Applications, for information about debugging applications.
Network Communication
With network communication, a host VI runs on the host computer and
communicates with the VI running on the RT target using specific network
communication methods such as TCP, VI Server, and in the case of
non-networked RT Series plug-in devices, shared memory reads and
writes. You might use network communication for the following reasons:
• You want to run another VI on the host computer.
• You want to control the data exchanged between the host computer and
the RT target. You can customize communication code to specify
which front panel objects get updated and when. You also can control
which components are visible on the front panel because some controls
and indicators might be more important than others.
• You want to control timing and sequencing of the data transfer.
• You want to perform additional data processing or logging.
In Figure 3-3, the RT target VI is similar to the VI in Figure 3-2 that runs
on the RT target using front panel communication to update the front panel
controls and indicators. However, the RT target VI in Figure 3-3 uses
Real-Time FIFO VIs to pass data to a communication VI. The
communication VI then communicates with the host computer VI using
network communication methods to update controls and indicators. Refer
to the Passing Data between VIs section of this chapter for information
about the methods available to send data between VIs running on an RT
target. Refer to the Exploring Communication Methods section of this
chapter for information about methods available to send data between VIs
running on an RT target and VIs running on the host computer.
LabVIEW
Host Computer
Network Communication
VI Communication RT Engine
RT Target
front panel data from the time-critical VI. The Real-Time FIFO VIs transfer
data deterministically and do not affect the timing of the time-critical VI.
– VI Server
– SMTP (send only)
• Bus Communication—Used for communication over different bus
communication ports.
– Serial
– CAN
• IrDA Wireless Communication—Used for communication with RT
targets using IrDA hardware.
Shared Memory
In operating systems like Windows, two processes or applications can
communicate with each other using the shared memory mechanism of the
operating system. Similarly, VIs running on an RT target and VIs running
on the host computer can communicate using the Real-Time Shared
Memory VIs. Use the Real-Time Shared Memory VIs to read and write to
shared memory locations of RT Series plug-in devices or the shared
memory locations of the real-time subsystem.
Network Communication
Table 3-1 lists the characteristics of the different network communication
methods.
TCP
TCP is an industry-standard protocol for communicating over networks.
VIs running on the host computer can communicate with RT target VIs
using the LabVIEW TCP functions. However, TCP is non-deterministic,
and using TCP communication inside a time-critical VI might cause the
loop cycle time to vary from the desired time. Refer to the LabVIEW Help,
available by selecting Help»VI, Function, & How-To Help, for
information about the LabVIEW TCP functions.
UDP
UDP is a network transmission protocol for transferring data between two
locations on a network. UDP is not a connection-based protocol, so the
transmitting and receiving computers do not establish a network
connection. Because there is no network connection, there is little overhead
when transmitting data. However, UDP is non-deterministic, and using
When using UDP to send data, the receiving computer must have a read
port open before the transmitting computer sends the data. Use the UDP
Open function to open a write port and specify the IP address and port of
the receiving computer. The data transfer occurs in byte streams of varying
lengths called datagrams. Datagrams arrive at the listening port and the
receiving computer buffers and then reads the data.
You can transfer data bidirectionally with UDP. With bidirectional data
transfers, both computers specify a read and write port and transmit data
back and forth using the specified ports. You can use bidirectional UDP
data transfers to send and receive data from the network communication VI
on the RT target.
(RTX) You must use RTRTX::0 as the address of the RT target when
attempting to write data to the target using the LabVIEW UDP functions.
Note You can bind a DataSocket connection to a front panel object and control the object
from a client connection. However, this feature is not supported by VIs on an RT target
because there is no front panel.
One advantage of using DataSocket is that multiple clients can access data
on the DataSocket Server. A LabVIEW VI can use the DataSocket Write
VI to post data to the DataSocket Server. Any number of VIs running on
different RT targets or host computers can use the DataSocket Read VI to
retrieve the data. RT target VIs can post data, such as status information, to
the DataSocket Server for a VI running on a host computer to read.
VI Server
Use the VI Server to monitor and control VIs on an RT target. Using VI
Server technology, a LabVIEW VI can invoke RT target VIs remotely.
The LabVIEW VI can pass parameter values to and from the RT target VIs,
creating a distributed application.
A host VI can invoke only VIs in memory on the RT target. The host VI
cannot dynamically download LabVIEW VIs to the RT target for use with
the VI Server. Refer to the Downloading VIs to an RT Target section of
Chapter 2, Connecting to RT Targets, for information about downloading
VIs without running them.
(RTX) You must use RTRTX::0 as the computer name of the RT target when
attempting to open an application reference using the VI Server.
Bus Communication
Serial (ETS Only)
Serial communication is the transmission of data between two locations
through the serial ports. The VISA functions provide serial communication
support in LabVIEW for communication between RT targets with serial
devices and serial instruments or computers that have a serial connection.
Serial communication is ideal when transfer data rates are low or for
transmitting data over long distances. You must install NI-Serial RT on the
RT target from MAX. (Mac OS) Install NI-Serial RT using the Remote
System Explorer.
Refer to the NI-CAN Hardware and Software Manual for information about
using NI-CAN hardware and software with LabVIEW.
You can use software methods or a hardware method to time control loops.
The software method is available for RT Series FieldPoint modules,
RT Series PXI controllers, and RT Series plug-in devices. The hardware
method is available only for RT Series plug-in devices and RT Series PXI
controllers.
Wait (ms)
The Wait (ms) function causes a VI to sleep for the specified amount of
time. For example, if the operating system millisecond timer value is
112 ms when the Wait (ms) function executes, and the milliseconds to
wait input equals 10, then the function returns when the millisecond timer
value equals 122 ms.
Use the Wait Until Next ms Multiple function to synchronize a loop with
the operating system millisecond timer value multiple. A loop has a period
of millisecond multiple if the Wait Until Next ms Multiple function
executes in parallel with other code in the same loop. However, the loop
does not have the period of millisecond multiple if the code takes longer
to execute than the millisecond multiple.
Avoid placing the Wait Until Next ms Multiple function in parallel with
other code because doing so can result in incorrect timing of a control
system. Instead, use a sequence structure to control when the Wait Until
Next ms Multiple function executes. Figure 4-1 shows the ideal timing of a
control system. The example control system reads an analog input, writes
an analog output, and waits in a synchronized cycle that repeats.
The block diagram in Figure 4-2 uses a While Loop with the Wait Until
Next ms Multiple function to create a control system.
If you are using arrays in time-critical VI control loops, you can reduce
jitter by preallocating arrays before entering the loop.
The block diagram in Figure 5-1 builds an array within the control loop.
Jitter affects the loop because the Build Array function inside the loop uses
the LabVIEW Memory Manager at every iteration to allocate memory for
the array.
The block diagram in Figure 5-2 uses the Initialize Array function outside
the loop and the Replace Array Subset function inside the loop to create the
array. Because the array is preallocated outside the control loop, the control
loop no longer needs to access the LabVIEW Memory Manager at every
iteration.
Use the smallest data type possible when casting the data type. If you must
convert the data type of an array, do the conversion before you build the
array. Also, keep in mind that a function output reuses an input buffer only
if the output and the input have the same data type. Arrays must have the
same structure and number of elements for function outputs to reuse the
input buffer.
When you reboot or reset an RT target, the RTOS and the RT Engine load
into memory as shown in diagram 1 of Figure 5-3.
Array 2
Array 1
Array 3
1 2 3 4
The RT Engine uses available memory for running RT target VIs and
storing data. In diagram 2 of Figure 5-3, ArrayMaker.vi creates Array 1.
All elements in Array 1 must be contiguous in memory.
The RTOS reuses the same memory addresses if you stop a VI and then run
it again with arrays of the same size or smaller. In diagram 3 of Figure 5-3,
ArrayMaker.vi creates Array 2. The RTOS creates Array 2 in the
reserved memory space previously occupied by Array 1. Array 2 is small
enough to fit in the reserved memory space that was allocated to Array 1.
The extra contiguous memory used for Array 1 remains in the reserved
memory space, as shown in diagram 3 of Figure 5-3.
the array because of the memory fragmentation. You can preserve memory
space by preallocating array space equal to the largest use case.
You also can convert subVIs into subroutines by changing the VI priority.
The LabVIEW execution system minimizes the overhead to call
subroutines. Subroutines are short, frequently executed tasks that generally
do not require user interaction. Subroutines cannot display front panel data
and do not multitask with other VIs. Also, avoid using timing or dialog box
functions in subroutines. Refer to Chapter 3, Building Deterministic
Applications, for information about setting VI priorities.
Setting VI Properties
To reduce memory requirements and increase performance of VIs, disable
nonessential options in the VI Properties dialog box available by selecting
File»VI Properties. Select Execution from the Category pull-down menu
and remove checkmarks from the Allow debugging and Auto handle
menus at launch checkboxes. By disabling these options, VIs use less
memory, compile quicker, and perform better overall.
Additionally, for NI PXI-8170 controllers, make sure the controller has the
following BIOS setting:
PnP/PCI Configuration
Assign IRQ for USB = DISABLED
Note You must place a checkmark in the Allow debugging checkbox of the Execution
page of the VI Properties dialog box to use the LabVIEW debugging tools to debug a VI.
The only feature not supported by the Real-Time Module is the Call Chain
ring, which appears in the toolbar of a subVI block diagram window while
single-stepping. Refer to the LabVIEW User Manual for information about
the LabVIEW debugging tools.
Note Do not use the LabVIEW debugging tools to debug execution timing because all
debugging tools affect the timing of an application.
Note You must connect LabVIEW to an RT target while running the Profile window.
Many of the options in the Profile window become available only after you
begin a profiling session. During a profiling session, you can take a
snapshot of the available data and save it to an ASCII spreadsheet file.
The timing measurements accumulate each time you run a VI. Refer to the
LabVIEW Performance and Memory Management Application Note for
information about using the Profile window.
Using an Oscilloscope
The Tick Count (ms) function and the NI Timestamp VIs allow you to
examine the relative timing of sections of LabVIEW VIs and to measure
the software jitter in the VIs. Sometimes you might need to measure the
jitter of the whole system at the hardware level, especially when you use
hardware timing and the software jitter is masked out at the system level.
Use external tools such as an oscilloscope to study the relationship between
input and output signals and to measure loop rates and jitter levels.
You can use custom error codes with VIs that run on an RT target.
Create error files using the Error Code File Editor by selecting
Tools»Advanced»Edit Error Codes. If you use custom errors with
LabVIEW, you must rename the files to use a *.err extension and then
place the error files in the c:\ni-rt\system\user.lib\errors
directory or the c:\ni-rt\system\errors directory on the RT target.
Use the FTP client in MAX or any other FTP client to transfer the error file
to the networked device. Refer to the LabVIEW Help, available by selecting
Help»VI, Function, & How-To Help, for information about defining
custom error codes.
Note You must select an RT target as the execution target before launching the
Application Builder if you want to embed the stand-alone application on the target.
If you place a checkmark in the Small target file with external file for
subVIs checkbox of the Build Options section, you cannot change the
LLB for other files path because Application Builder determines the path
from the Application Path text box in the RT Target Options dialog box.
Refer to the LabVIEW Help, available by selecting Help»VI, Function, &
How-To Help, for information about the RT Target Options dialog box.
RT targets have media storage devices where you can save stand-alone
applications. For example, the RT Series PXI controller has a hard disk
drive, and the FieldPoint 20xx network module has flash. You can
automatically launch embedded stand-alone applications each time you
start the RT target. Refer to the Launching Stand-Alone Applications
section of this chapter for information about launching embedded
stand-alone applications automatically on an RT target.
Note You must select the host computer as the execution target before launching the
Application Builder if you want to create an installer for a stand-alone application.
You must include the LabVIEW Run-Time Engine if you plan to install the
application on a computer that does not have the Real-Time Module
installed.
Note (RTX) You must install Venturcom RTX and the LabVIEW Real-Time Module for
RTX on the computer on which you want to install the application. You also must install
the NI-VISA 3.1 driver from the National Instruments Device Driver CD and NI-RIO 1.1
for R Series devices from the NI-RIO for R Series Devices CD if you want to use the
NI PCI-7831 plug-in device for instrument I/O.
Note RT targets must already have a version of the RT Engine installed that matches the
version of LabVIEW you use to build the stand-alone application.
To disable the Select Execution Target dialog box, specify the RT target
in a command line argument using –target. For example,
c:\mybuiltapp_rtengine.exe -target RTRTX::0
You also can target the host computer and automatically launch a host
computer application on startup. For example,
c:\mybuiltapp_host.exe -target host
To disconnect the host computer from the RT target after downloading the
application, leaving the embedded application running, use -quithost.
For example, the following command automatically downloads and runs
mybuiltapp_rtengine.exe on an RT target with the IP address of
10.0.40.76 and then closes LabVIEW on the host computer.
c:\mybuiltapp_rtengine.exe -target 10.0.40.76 -quithost
Note If the host computer requires a login before entering the operating system, the
application starts only after the login completes.
You also can reset a specified plug-in device using -reset. For example,
c:\mybuiltapp_rtengine.exe -target RT::0 -reset
If you searched ni.com and could not find the answers you need, contact
your local office or NI corporate headquarters. Phone numbers for our
worldwide offices are listed at the front of this manual. You also can visit
the Worldwide Offices section of ni.com/niglobal to access the branch
office Web sites, which provide up-to-date contact information, support
phone numbers, email addresses, and current events.
A
address Character code that identifies a specific location or series of locations in
memory.
application A collection of VIs that together accomplish the real-time system task.
D
DAQ See data acquisition (DAQ).
data acquisition (1) Acquiring and measuring analog or digital electrical signals from
(DAQ) sensors, transducers, and test probes or fixtures; (2) Generating analog or
digital electrical signals.
DataSocket An Internet programming technology to share live data between VIs and
other computers.
device An instrument or controller you can access as a single entity that controls
or monitors real-world I/O points. A device often is connected to a host
computer through some type of communication network.
driver Software unique to the device or type of device, and includes the set of
commands the device accepts.
E
embedded application A stand-alone application built using the LabVIEW Application Builder
and embedded as the start-up application on an RT target.
execution target The target on which to run a LabVIEW VI. Can be either an RT target or
the host computer.
F
FIFO First-in-first-out memory buffer. The first data stored is the first data sent
to the acceptor.
front panel A protocol for communication between LabVIEW on the host computer
communication and the RT Engine on an RT target, typically used during development.
functional global A subVI set to subroutine priority used to pass data between several VIs on
variable a block diagram.
G
global variable A variable that accesses and passes data between several VIs on a block
diagram.
H
host computer The computer on which you develop VIs using LabVIEW and download
them to an RT target.
I
I/O Input/Output—The transfer of data to/from a computer system involving
communications channels, operator interface devices, and/or data
acquisition and control interfaces.
J
jitter The amount of time that the loop cycle time varies from the desired time.
M
Measurement & A graphical user interface for configuring National Instruments hardware
Automation Explorer and software.
(MAX)
multitasking When a computer runs applications for a short amount of time to give the
impression of multiple applications running simultaneously.
multithreading Running tasks of an application for a short amount of time to give the
impression of multiple tasks running simultaneously.
mutex An operating system lock around a resource to protect the resource from
access by other VIs.
N
network A protocol for communication between a host VI and a VI running on the
communication RT target using specific network communication programmatic controls.
networked device A hardware platform with an embedded processor that you can control
using a separate host computer through an Ethernet connection.
O
operating system Base-level software that controls a computer, runs programs, interacts with
users, and communicates with installed hardware or peripheral devices.
P
PCI Peripheral Component Interconnect—A high-performance expansion bus
architecture originally developed by Intel to replace ISA and EISA. It is
achieving widespread acceptance as a standard for PCs and workstations;
it offers a theoretical maximum transfer rate of 132 Mbytes/s.
preemptive scheduling Execution system scheduling of threads in which higher priority threads
execute before all other threads.
protocol The exact sequence of bits, characters, and control codes used to transfer
data between computers and peripherals through a communications
channel, such as the GPIB bus.
R
real-time A property of an event or system in which data is processed as it is acquired
instead of being accumulated and processed at a later time.
Real-Time Operating Uses a combination of round robin and preemptive scheduling to execute
System (RTOS) threads in the execution system.
Real-Time Subsystem A real-time subsystem in Windows that has a priority based real-time
(RTSS) execution system independent of the Windows scheduler.
remote panel Allows you to operate a front panel on a machine that is separate from
where the VI resides and executes using a LabVIEW client or Web browser.
round robin scheduling Scheduling that attempts to share the processor in equal amounts of time
among all ready tasks of the same priority.
RT target RT Series hardware that runs VIs downloaded from and built in LabVIEW.
run-time engine Runs LabVIEW executables built using the LabVIEW Application Builder
on computers without LabVIEW.
S
shared memory Memory that can be sequentially accessed by more than one controller or
processor but not simultaneously accessed. Also known as dual-mode
memory.
shift register Optional mechanism in loop structures to pass the value of a variable from
one iteration of a loop to a subsequent iteration. Shift registers are similar
to static variables in text-based programming languages.
soft reboot Restarting a computer without cycling the power, usually through the
operating system.
T
target See RT target.
Traditional NI-DAQ An upgrade to the earlier version of NI-DAQ. Traditional NI-DAQ has the
same VIs and functions and works the same way as NI-DAQ 6.9.x. You can
use both Traditional NI-DAQ and NI-DAQmx on the same computer,
which is not possible with NI-DAQ 6.9.x.
U
UDP User Datagram Protocol. A standard format for transmitting data in
datagrams from one computer to another.
V
VI Virtual Instrument—(1) A combination of hardware and/or software
elements, typically used with a PC, that has the functionality of a classic
stand-alone instrument; (2) A LabVIEW software module (VI), which
consists of a front panel user interface and a block diagram program.
Virtual Instrument Single interface library for controlling GPIB, VXI, RS-232, and other types
Software Architecture of instruments.
(VISA)
execution systems, assigning VIs to, 3-4 to 3-5 instrument drivers (NI resources), A-1
execution target, selecting RT target IrDA wireless communication, 3-17 to 3-18
as, 2-1 to 2-2
Execution Trace Toolkit, LabVIEW, 6-4
Express VIs, 1-4 J
Jitter, reducing, 5-1
F
FieldPoint Modules, RT Series K
acquiring data, 4-5 KnowledgeBase, A-1
definition, 1-3
Flat Sequence structure, 4-3 to 4-4
front panel
L
closing connection without closing LabVIEW debugging tools, 6-1
VIs, 2-3 LabVIEW Execution Trace Toolkit, 6-4
modification of RT target VI front panels LabVIEW Memory Manager, 5-1 to 5-2
not supported, 1-5 LabVIEW Real-Time Module
front panel communication, 3-9 See also RT Engine; RT target(s)
functional global variables, 3-6 to 3-7 Express VI considerations, 1-4
overview, 1-1
platforms, 1-1 to 1-2
G LabVIEW software
global variables See also RT Engine
functional, 3-6 to 3-7 quitting after launching stand-alone
overview, 3-6 applications, 7-2 to 7-3
reducing use of, 5-3 real-time system component, 1-2 to 1-4
Timed Loop, 4-4
unsupported features with RT target
H VIs, 1-5 to 1-6
hardware timing control loops, 4-4 modifying front panel objects, 1-5
help, technical support, A-1 using OS-specific technologies, 1-6
host computer, 1-2 launching stand-alone applications
Host VI, 3-12 automatically, 7-4 to 7-5
using command line arguments, 7-5
when booting target, 7-4
I
imaging system, real-time (NI 1450 Series
Compact Vision System), 1-4 M
Infrared Data Association (IrDA) wireless manual. See documentation
communication, 3-17 to 3-18 mass compiling of VIs, 5-5
Initialize Array function, 5-2
memory O
allocation and preallocating operating system mutex, 5-1
arrays, 5-1 to 5-2
oscilloscope, for timing behavior
avoiding contiguous memory
verification, 6-3
conflicts, 5-3 to 5-5
minimizing usage by RT target Web
server, 5-6 P
multithreaded applications, 3-1 to 3-5 passing data between VIs, 3-6 to 3-8
cooperative yielding of time-critical VIs,
functional global variables, 3-6 to 3-7
3-5
global variables, 3-6, 5-3
definition, 3-1
Real-Time FIFO VIs, 3-8
dividing tasks for creating, 3-2 to 3-3
PCI-7041 plug-in device, 1-3
execution systems for categorizing
PCI-7831 plug-in device, 4-5
VIs, 3-4 to 3-5
platforms for Real-Time Module, 1-1 to 1-2
overview, 3-1 to 3-2
plug-in devices, RT series
round robin scheduling, 3-2
PCI-7041plug-in device, 1-3
VI priorities, 3-3 to 3-4
PCI-7831 plug-in device, 4-5
mutex, definition of, 5-1
preallocating arrays, 5-1 to 5-2
preemptive scheduling, 3-2
N priorities, assigning to VIs, 3-3 to 3-4
National Instruments support and priority inversion-induced jitter, 5-1
services, A-1 Profile window, 6-2
network communication, 3-10 to 3-11 programming examples (NI resources), A-1
characteristics (table), 3-14 PXI controllers, RT Series, 1-3
DataSocket, 3-15 to 3-16
purpose and use, 3-10 to 3-11
R
SMTP, 3-16
TCP, 3-14 real time system components, 1-2 to 1-4
host computer, 1-2
UDP, 3-14 to 3-15
LabVIEW software, 1-2
VI Server, 3-16
networked RT Series devices, 1-3 to 1-4 RT engine, 1-2
RT targets, 1-3 to 1-4
NI 1450 Series Compact Vision system, 1-4
Real-Time FIFO VIs, 3-8
NI PCI-7041 plug-in device, 1-3
NI PCI-7831 plug-in device, 4-5 Real-Time Module
See also RT Engine; RT target(s)
NI support and services, A-1
Express VI considerations, 1-4
NI Timestamp VIs, 6-3
Normal Priority VI overview, 1-1
platforms, 1-1 to 1-2
creating, 3-12
Real-Time Operating System
multithreaded applications, 3-2 to 3-3
(RTOS), 5-3 to 5-5
Real-time Subsystem (RTSS), 1-4
U
T UDP communication method, 3-14 to 3-15
targets. See RT target(s) user interface, creating for RT target
TCP communication method, 3-14 VIs, 3-8 to 3-10
technical support, A-1
thread
See also multithreaded applications V
definition, 3-1 Venturcom Phar Lap Embedded Tool Suit
Tick Count (ms) function, 6-3 (ETS), 1-1
time-critical VIs Venturcom Real-Time Extension (RTX), 1-1
cooperative yielding, 3-5 VI Server communication method, 3-16
creating with RT Communication VIs
Wizard, 3-11 to 3-12 See also RT target VIs; time-critical VIs
functional global variables, 3-6 to 3-7 acquiring data with VIs on RT target, 4-5
memory allocation and preallocating Changed or Missing VIs dialog box, 2-4
arrays, 5-1 to 5-2 connecting to VIs running on RT
multithreaded applications, 3-2 to 3-3 target, 2-4
timing behavior verification, 6-3 to 6-4 creating with RT Communication
LabVIEW Execution Trace Toolkit, 6-4 Wizard, 3-11 to 3-12
NI Timestamp VIs, 6-3 downloading to RT target, 2-3
oscilloscope, 6-3 error codes, using and defining, 6-4