Overview
Numerous test, control, and design application require real-time performance. This tutorial will cover the basic concepts of real-time systems.
Table of Contents
Introduction to Real-Time Systems
Real-time operating systems originated with the need to solve two main types of applications: event response, and closed loop control systems. Event response applications require a response to a stimulus in a determined amount of time, an example of such a system is an automotive airbag system. Closed loop control systems continuously process feedback in order to adjust an output; an automotive cruise control system is an example of a closed-loop control system. Both of these types of systems require the completion of an operation within a specific deadline. This type of performance is referred to as determinism.
Real-time systems are sometimes classified as "soft" or "hard". Soft real-time typically means the utility of a system is inversely proportionate to how long it has been since a deadline is missed. For example, when pressing a cell phone button to answer an incoming call, the connection must be established soon after the button has been pressed. However, the deadline is not mission-critical and small delays can be tolerated. Hard real-time systems are those in which the utility of a system becomes zero in the event of a missed deadline. An automotive engine control unit (ECU) must process incoming signals and calculate spark plug timing within a deadline. If the deadline is missed, the engine will fail to operate correctly. The usefulness of a task after a deadline is missed is depends on whether the system is a soft real-time or a hard real-time system, as shown in Figure 1.
Operating systems such as Microsoft Windows and Mac OS provide an excellent platform for developing and running your non-critical measurement and control applications. However, because these operating systems are designed for general purpose use, they are not the ideal platform for running applications that require deterministic performance or extended uptime.
General-purpose operating systems are optimized to run a variety of applications simultaneously, ensuring that all applications receive some processing time. These operating systems must also respond to interrupts from peripherals such as the mouse and keyboard. The user has limited control regarding how these tasks are handled by the processor. As a result, high-priority tasks can be preempted by lower priority tasks, making it impossible to guarantee a response time for your critical applications.
In contrast, real-time operating systems give users the ability to prioritize tasks so that the most critical task can always take control of the processor when needed. This property enables you to program an application with predictable results.
Figure 1- Difference between hard and soft real-time
Real-time operating systems are required when the processor is involved in operations such as closed loopcontrol and time-critical decision making. These applications require timely decisions to be made based on incoming data. For example, an I/O device samples an input signal and sends it directly to memory. Then, the processor must analyze the signal and send the appropriate response to the I/O device. In this application, the software must be involved in the loop; therefore, you need a real-time operating system to guarantee response within a fixed amount of time. In addition, applications requiring extended run-times or stand alone operation are often implemented with real-time operating systems.
Real-Time Performance
The most common misconception associated with real-time performance is that it increases the execution speed of your program. While this is true in some cases, it actually enhances your application by providing more precise and predictable timing characteristics. With these enhancements, you can determine the exact time when certain events will occur.
Real-Time Control
With real-time control, you can continually monitor and simulate a physical system. Real-time control applications repeatedly perform a user-defined task with a specified time interval separating them. Most real-time control systems monitor the physical system, compare the current state with the desired state, and then simulate the physical system based on the comparison. The time it takes to traverse this loop is considered the loop cycle time. This cycle time of the control loop varies based on the complexity of the system.
Determinism measures the consistency of the specified time interval between events. Many control algorithms, such as PID, require very deterministic behavior. For example, an elevator gradually moves to the correct floor because of the deterministic behavior of the control loop. Without the determinism, the elevator would still reach the correct floor but without stability.
With all real-time systems, there is some amount of error called jitter. Jitter is another way of measuring the determinism of a real-time system. You can calculate it as the maximum difference between any individual time delay and the desired time delay in a system, as shown in Figure 2 below.

Figure 2- An example jitter diagram
Real-Time Event Response
With real-time event response, you can respond to a single event within a given amount of time. The real-time system guarantees some maximum response time to the single event. The event can be either periodic or random. An example of a real-time event response application is a safety monitoring system. If a physical plant enters a dangerous state, the real-time system must respond to the "danger" event within a guaranteed amount of time.
Latency is used to describe the time it takes to respond to an event. It is similar to the determinism in real-time control applications. With real-time event response, you are guaranteed a worst case latency.
NI Real-Time Technology
The LabVIEW Real-Time Module and LabWindows/CVI Real-Time Module are used to achieve reliable deterministic execution on dedicated hardware targets. For increased determinism needs, the LabVIEW FPGA Module combined with hardware that includes reconfigurable I/O technology offers nanosecond hardware response. Use National Instruments software to:
- Rapidly develop deterministic applications with graphical programming or ANSI C
- Easily architect distributed control and monitoring systems
- Eliminate time spent integrating diverse I/O
National Instruments offers a variety of real-time hardware targets that contain an embedded processor running a real-time OS for maximum reliability and deterministic performance. You can integrate a wide array of I/O with modular hardware that scales to accommodate high-channel-count data acquisition and control, industrial signal conditioning, and safety isolation.
Figure 3 - National Instruments Real-Time Technology
Test Drive LabVIEW Real-Time
Click Here to Proceed to the LabVIEW Real-Time On-line Eval
Related Links:
Introduction to LabVIEW Real-Time Webcast
Selecting Your LabVIEW Real-Time Deployment Platform
What is LabWindows/CVI Real-Time?
Reader Comments | Submit a comment »
No tutorial
How is this page a tutorial ? There's no code
sample, no walk through on any NI
application. It's just some generic info on
what a real-time OS is...
- Guillaume Dargaud, LPSC/IN2P3/CNRS. guillaume@gdargaud.net - Apr 5, 2007
not enough program examples
- j, b. - Jul 26, 2004
REAL time
sir, all the information present related RTOS
very nice, i want text formate notes or cd.
regards
meganathan
- Jun 28, 2003
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/).


