Achieving real-time measurement and control in a Windows environment
Real-time measurement and control, depending on the particular application and its requirements, means different things to different people. Users who require a response time in microseconds see their application as real time.
Real-time measurement and control, depending on the particular application and its requirements, means different things to different people. Users who require a response time in microseconds see their application as real time. Others who need a response time in seconds believe their application is real time as well.
One popular way to define real-time control is to divide it into three categories: hard, firm, and soft.
– Hard real time is viewed as a control situation in which failing to meet a deadline results in catastrophic failure.
– Firm real time is a control situation in which failure to meet a deadline results in data that are not useful.
– Soft real time is a control situation in which failure to meet a deadline results in data that are less useful than the information that would have been obtained had the deadline been met.
In most cases, people who work with or refer to real time in control or data acquisition are speaking of hard or firm real time. As the popularity of today’s conventional PC operating systems grows, more and more users are looking to familiar means such as Windows to handle some of these control tasks. Unfortunately, attempting to use some of these systems is often ineffective for real-time operations, which typically require deterministic performance in microseconds.
Ensuring guaranteed response times
Process industry and quality control applications associated with mass production constitute some of the most common applications that require guaranteed response times.
For example, a line processing 1000 cans/min may need to be checked and rechecked within milliseconds or a pile-up of cans can occur. In a refinery, thousands of variables must be sampled within a few seconds and control actions taken on the basis of the deviation from the setpoint of each process variable.
As industrial plants strive to reduce operating costs, the need for faster, more reliable control across all industries and applications continues to escalate.
For hard real-time applications that require deterministic performance in the single-microsecond range, the most effective real-time solution is to replace the local operating system with a real-time operating system. Distributed control system (DCS) and programmable logic control system (PLC) suppliers have been doing that for years. In each case, suppliers have used their own, proprietary operating system to guarantee hard real-time response.
Using the DCS
DCS operating systems of the past resembled modern extended versions of the Windows NT environment in that the preemptive scheduling of tasks with guaranteed interrupt response times offered deterministic performance. Today, many DCS suppliers support open-operating-system platforms, including Unix and Windows NT.
In late 1996, for example, several DCS vendors committed to the use of Windows-based products for distributed control. The decision was based largely on the increasing popularity of Windows NT and OLE for Process Control. Many DCS suppliers now offer PCs as an alternative interface to their proprietary operator workstations.
As an example, consider a refinery that has thousands of analog signals that need to be measured and compared to a setpoint (or desired value). Action must be taken whenever the value of the real-time analog signal deviates too far from the setpoint.
DCSs are capable of handling these requirements in hard real time. Because their proprietary operating systems easily handle multiprogramming and interrupts, the DCS is an ideal vehicle for handling this type of application.
DCSs are perceived as being most effective for handling very large, complex requirements in which the quantity of analog signals that needs to be scanned and controlled is significantly larger than the quantity of digital signals. Although DCS systems handle digital signals well, most users prefer PLCs for applications that have a preponderance of digital I/O because of the unique characteristics of the PLC operating system.
Taking the PLC approach
PLCs are best at handling the hard real-time requirements involved in processing digital signals. For this reason, they are used on high-speed processing lines such as those associated with conveyor belts, elevators, mills, etc. The PLC originated as a substitute for hard-wired control circuits that were typically designed using relay ladder logic. Most PLCs today are programmed in this same manner.
The strength of PLCs is in processing digital signals in hard real time (microseconds). High-speed processing of analog signals presents a problem. The PLC operating system is designed to process instructions one step at a time. For example, it starts at instruction number 1, then proceeds to numbers 2, 3, 4, etc., until it reaches the end of the instruction set. Then it starts over again at instruction number 1.
Multitasking and interrupt handling are largely out of the realm of the conventional PLC. Handling of analog signals, which detracts from the real task of sequential processing of instructions, is generally on an exception basis.
Because of the PLC structure, PLC suppliers have, in large part, decided not to evolve their proprietary operating systems into open platforms. Some have chosen to offer a Windows-based PC platform as an operator interface, while keeping the PLC operating system proprietary. This configuration lets the PLC, with its scanning architecture, guarantee response times on the order of microseconds, while providing a conventional, nonproprietary window to the process through the PC.
Making a case for the PC
Many users today are satisfied that PCs offer improved versatility, throughput, and communications capability. They also believe that achieving real-time data acquisition and control with guaranteed response times using a PC is a cost-effective alternative to larger, more expensive and proprietary DCS and PLC offerings. Once thought of as impenetrable, this market now represents a growing opportunity for many PC hardware and software suppliers.
Nevertheless, many users of PC-based, plug-in data acquisition and control boards are still dissatisfied with the performance of this equipment in a real-time environment. They complain that, despite their use of high-speed boards and speed-optimized application code, systems sometimes fail to respond to signals in time to guarantee the accuracy of a measurement or output. Why does this happen? Below are some of the key reasons for this dissatisfaction.
No guaranteed response times
Microsoft Windows 3.X, 95, and 98 are message-driven, event-polling systems with nonpreemptive scheduling. In other words, they cannot guarantee interrupt response times and, therefore, are not deterministic.
Because they cannot guarantee response times, they are not true real-time operating systems. They might work well for applications requiring a response in minutes or even seconds, depending on what other applications are being served by the computer. However, more time-critical tasks may encounter long delays and even result in application failures.
To compensate for operating system latency, some suppliers have developed software that enables these systems to operate on a real-time basis. Most provide real-time operating system (RTOS) extensions that work with the Win32 application programming interface (API). Because the RTOS operates in the computer’s protected mode or has interrupt-service routines that take precedence over Windows tasks, it allows system designers access to application programs that can handle real-time events.
However, this approach requires that the application program’s source code be recompiled to work with the RTOS. Implementation can be costly and requires a highly experienced programmer. In addition, other applications running on the computer may be negatively affected.
A better solution
Windows NT provides a reliable 32-bit operating system with preemptive, priority-based multitasking. When it is operated on a high-speed processor, it is robust enough to handle many real-time applications that require response times on the order of 5-10 milliseconds.
In normal practice, when an interrupt occurs, Windows NT preempts all tasks and uses a deferred procedure call. It performs only part of the required action and places the remainder of the required action into a queue for execution. Essentially, then, all real-time tasks execute in the background mode in the order received and without priority. It is this routine that limits Windows NT to relatively slow guaranteed response times.
Several independent software vendors have developed extensions for adapting Windows NT to a real-time environment. These extensions are designed to circumvent the operating structure that causes tasks to execute without priority. However, the cost can be high and programming requirements complex. In addition, guaranteed responses can be limited to the order of 20-50 microseconds/real-time event.
Looking at solutions for the future
The platform commonly used for real-time solutions is Windows CE. Capable of deterministic performance on the order of 150 microseconds, Windows CE is likely superior to Windows NT for hard real-time applications. However, Windows CE is still in its infancy and developers are just beginning to learn the subtle nuances of this platform.
An easy way to achieve guaranteed response times under Windows is to use a system independent of the PC that has a board, or series of boards, with an integral real-time operating system and its own onboard microprocessor for data acquisition and control. This operating system would contain all the necessary components to allow data exchange with a host PC running a standard Windows operating system.
Such a system provides guaranteed response times because it has its own RTOS on a dedicated processor that operates independently of the computer. If the host computer operating system crashes, operation of the RTOS is unimpaired.
This configuration provides real-time capabilities for control and acquisition, coupled with the user-friendly interface common to the vast majority of PCs. For many applications, this solution can be implemented at a fraction of the cost of a DCS.
Several manufacturers offer controller boards that can provide guaranteed response times as low as 1 microsecond. Boards with even tighter response times are expected to be introduced.
Real time is defined by the requirements of the application and is used to describe an application that demands a guaranteed, deterministic response to an external event within a given interval. DCS systems provide real-time control using proprietary operating systems to process digital and analog signals. PLCs handle digital I/O signals in hard real time, but cannot adequately manage analog signals without special provisions. Both systems are proprietary, closed-end systems that usually cost more than open-system architectures.
Because of the nondeterministic nature of Windows, most plug-in computer boards operating in most Windows environments are not designed to provide true real-time functionality. Windows CE, however, shows promise. Software real-time extensions are available to improve the response times of Windows-based operating systems. Such solutions are typically costly and complicated to install and may not be able to handle the demanding response times required by certain applications.
The best way to obtain real-time control under Windows with guaranteed response times as low as 1 microsecond is to use controller boards that have their own microprocessors and operate independently of the host computer.
— Edited by Jeanine Katzel , Senior Editor, 630-320-7142 , j.katzel@cahners.com
Key concepts
Real-time control is defined in many ways but essentially falls into three categories: hard, firm, and soft.
Many users are turning from expensive, proprietary DCS and PLC systems to the PC as a cost-effective way to achieve real-time data acquisition and control.
Hard real-time control applications typically require deterministic performance that is difficult to achieve with Windows-based operating environments.
More info
Technical questions about this article may be directed to the author at 440-542-8018.
For more articles related to this topic, visit the “Instruments and controls” and “Computers and software” channels on our web site at www.plantengineering. com.
Do you have experience and expertise with the topics mentioned in this content? You should consider contributing to our WTWH Media editorial team and getting the recognition you and your company deserve. Click here to start this process.