Basics of real-time measurement, control, and communication using IEEE 1588Editor's Note: This is the first in an on-going series about the use of IEEE 1588, and the explicit representation of time in the design and operation of synchronized time-stamped measurement, control, and communication systems.
IEEE 1588 is a relatively new real-time networking synchronization protocol that was originally designed for local systems in instrumentation and industrial applications requiring very high accuracies beyond those attainable using the current network time protocols (NTP), and now finding wider use in communications and wide area networking.
These systems share a common feature in that they interact with devices or processes that themselves operate based on real-world time. Such systems are often termed "hard real-time systems" because their actions must meet time constraints imposed by the application space, rather than by the operation of the measurement or control devices.
Examples of such hard real-time systems abound. In the measurement world, complex test systems composed of many electronic instruments operating in concert are used to verify the performance of even more complex electronic or electromechanical devices such as radar systems, electronic engine controls, power generators, and heart pacemakers.
In the field of control, combinations of computers, controllers, sensors, and actuators collaborate to regulate printing presses, oil refineries, packaging machines, traffic lights, and home heating equipment. Communications systems operate to pass information from source to destination and are governed by the laws of physics, the operation of the communication protocols, and the vagaries of users, all of which result in unpredictable traffic flows.
The use of time in measurement and control is actually very familiar, as our everyday life seems to be governed by the clock. Alarm clocks have been with us for ages. Does there exist a businessman that can function without the ever-present meeting reminder pop-ups on the computer screen? Lawns are watered, coffee is brewed, and favorite television programs are recorded; all based on some sort of mechanical or electronic clock.
In programming these devices, the time at which something is to happen is entered, as well as the time at which the activity is to cease, or in some cases, the duration of the activity. Never is there a list of activities executed based on the speed at which the device operates.
|Table 1.1. Summary of hard real-time design patterns|
The varieties of system temporal specifications
It may come as a surprise to those not familiar with the field that in programming test and measurement and control systems, it is usually difficult or impossible to specify actions based on time. It is true that some systems provide crude schedulers for starting a task based on time. Others are based on timers that may used to provide notification for a fixed time after the timer is set.
However, there are few examples in which detailed specifications of the system behavior as a function of time can he expressed, and even fewer mechanisms for enforcing such behavior, or even recognizing when the specifications have not been met. The reason is that most, modern test, measurement, control, and communication systems are operated by computers based on the latest microprocessors, operating systems, and programming languages.
For example, microprocessors provide little support for real-time specifications. Typically, support is limited to timed interrupts that can be used to form a clock or to implement timers. These interrupts invariably operate based on the oscillator used to drive the local processor, and therefore will be asynchronous to similar devices in other microprocessors in the system. To make matters worse microprocessors implement numerous optimizations that make their operation non-deterministic in time. Examples are memory cache, speculative execution; and interrupt priority.
Given the available support in hardware, even the so-called real-time, operating systems are best-effort systems with only statistical guarantees of temporal behavior. System clocks are typically implemented at the operating system level based on timed interrupts from the supporting hardware.
In most cases, the granularity of these clocks is not sufficient for applications of interest. There are synchronization protocols that enable clocks in one system to agree with other clocks in the system at accuracies useful in business and commerce. The common languages used in programming these systems do not support any form of temporal semantics. These languages are designed for data processing for business and commerce and mathematical manipulations for the scientific community.
There are simply no mechanisms in these languages for specifying actual simultaneity, parallel execution, temporal deadlines, or other time-related concepts. If time must be referenced, then this is always as an operating system call outside of the programming language.
State of the art in Implementing real-time systems
To overcome the lack of support for time-based specification in modern computing environments, a number of techniques have evolved and form the basis for the practice usually referred to as embedded systems programming. "These techniques include:
1) Ignoring high-level languages and operating systems. Program the microprocessors in a low-level or assembly language where more explicit control of the underlying hardware is possible. System-wide timing is often accomplished by means of special purpose hardware support accessible to the control microprocessors, such as the IRIG-B and GPS protocols.
2) Using the time support available in the general computing environment. In general, this tactic requires trial-and-error adjustment of the code to produce the desired temporal behavior. This technique is fragile in that the results are dependent on the speed of execution of code in the microprocessor, which is subject to all manner of abuse from the underlying hardware. If communication between computers or devices is required, then additional time variations will be introduced, making it even harder to hold to tight temporal specifications.
3) Generating a system-wide ordering mechanism for enforcing temporal relationships. These systems are called time- slotted systems. The time-slots may, or may not, be tied to real-world time.