You may have previously seen the term "real-time" used to describe a computing system, or even heard of the LabVIEW Real-Time Module. What does this terminology mean? What components make a system "real-time"? When does it make sense to choose a real-time system for your project?
This paper provides a straightforward guide that will answer all of these questions and help you determine it it makes sense to consider building a real-time system. After you have read through this paper, it is recommended that you visit Building a Real-Time System with NI Hardware and Software next to learn more about how National Instruments can help you build a superior real-time system in as little time as possible.
2. What is a Real Time System?
|A real-time computing system is able to very reliably execute programs with very specific timing requirements, something that is important for many science and engineering projects. The key component that is needed to build a real-time system is a Real-Time Operating System (RTOS); other hardware and software pieces that make up an entire real-time system are discussed in the next section.|
For many engineers and scientists, running a measurement or control program on a standard PC with a general-purpose OS installed (such as Windows) is unacceptable. At any time, the operating system might delay execution of a user program for many reasons: to run a virus scan, update graphics, perform system background tasks, and more. For programs that need to run at a certain rate without interruption (for example a cruise control system), this delay can cause system failure.
Note that this behavior is by design: general-purpose operating systems are optimized to run many processes and applications at once and provide other features like rich user interface graphics. In contrast, real-time operating systems are designed to run a single program with very precise timing. Specifically, real-time operating systems can allow you to:
- Perform tasks within a guaranteed worst-case timeframe
- Carefully prioritize different sections of your program
- Run loops with nearly the same timing each iteration (typically within microseconds)
- Detect if a loop missed its timing goal
When researching real-time computing systems, you may run across the terms "hard real-time" and "soft real-time". To clarify, hard real-time systems are designed to absolutely guarantee that a task will execute within a certain worst-case timeframe. Therefore, for projects involving safety or systems that could result in a large investment in the event of failure, hard real-time is often a requirement. On the other hand, soft real-time systems are designed to satisfy your timing requirements most of the time but without absolute certainty. This can be acceptable for operations like video processing, where a lost data frame is not good but may not necessarily be a critical problem.
Figure 1. Hard real-time systems guarantee (when programmed correctly) that a deadline will be consistently met, while soft real-time systems may periodically exceed the deadline.
If you are interested in a more detailed explanation on how real-time operating systems work or wish to explore common real time terms like "determinism" and "jitter", you can read the paper: What is a Real-Time Operating System?.
In addition to providing precise timing, real-time computing systems can be set up to run reliably for days, months, or years without stopping. This is important not only for engineers building systems that need 24-7 operation, but also for any application where down time is costly. A "watchdog" feature is also typically included in real-time systems to automatically restart an entire computer in the event that the user program stops running. Furthermore, hardware used in a real-time system is often made very rugged to sustain harsh conditions for long periods.
3. What Components Make Up a Real-Time System?
Though the major component needed to create a real-time system is the RTOS, various pieces of software and hardware are needed to build a real time system from start to finish.
- RTOS: This special OS is designed to run a user program reliably with very precise timing.
- Development tools: A compiler, linker, and debugger are needed that can generate code compatible with the real time operating system.
- Drivers: For a real-time operating system to communicate with system hardware and I/O modules, real-time compatible drivers are needed that can guarantee worst-case timing for most I/O operations.
- I/O modules and system hardware with real-time drivers (included in the software section above).
- (Optional) Rugged hardware: Chassis used in a real-time system may be designed to sustain harsh environments for long periods of time.
- (Optional) Watchdog timer: An integrated watchdog timer can automatically restart an entire computer if a user program stops running.
4. Summary: Do I Need a Real-Time System?
In summary, building a real-time system can be a good idea if you need to make sure that certain parts of your program run in a certain amount of time, or if you need to run your program reliably for long periods of time. If you are working on a mission-critical or safety-related project, then the need for building a real-time system is clear.
Even in the case where precise timing and long term reliability are not absolute requirements for your project, building a real-time system can provide added peace of mind that your program will continue to run without interrupting your measurement or control process. If the system that you are creating could result in maintenance costs in the event it is interrupted, the hardware and software costs required to create a real-time system may be well worth the investment.
Note that a real-time system does not necessarily make sense for every measurement or control project. Real-time operating systems typically only run one program at a time, and most real-time systems do not feature a user interface; in this case a separate computer must be used to provide graphics or user controls. Some projects require hardware determinism where logic is implemented on an ASIC or FPGA. Still, thousands of real-time systems are in operation today and will continue to be a viable solution for projects that need precise timing and high reliability.
Continue on to the following paper to learn how you can use NI hardware and software to build a superior real-time system in as little time as possible: