Real-Time Tutorial (from National Instruments)

sanatoriumdrumElectronics - Devices

Nov 25, 2013 (3 years and 10 months ago)

120 views

-

1

-

Real
-
Time Tutorial (from National Instruments)


Numerous measurement and automation applications require real
-
time performance. To
differentiate these real
-
time applications, you must first understand the core of real
-
time
performance and how it is used in

real
-
time control, real
-
time signal processing, and real
-
time
event response.

Table of Contents:




Real
-
Time Performance




Real Time Control




Control Loop Cycle Time




Determinism and jitter




Hard Real
-
Time and Soft Real
-
Time




Real
-
Time Signal Processing




Real Time E
vent Response




Real
-
Time Operating Systems




Embedded and Headless Applications





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 performance can be achieved through either hardware or softwar
e. To implement a
hardware real
-
time system, you need an accurate clock driving some hardware circuitry. For
example, NI DAQ hardware has onboard timing circuitry that regulates the acquisition rate. A
real
-
time operating system and programming environment

can create a real
-
time software
solution. This software solution offers more flexibility and convenient debugging tools. With it,
you can incorporate real
-
time decision making into your application with a custom algorithm
instead of relying on existing ha
rdware circuitry. With some systems, you can achieve a hybrid
in which you have the precise timing of hardware controlled real
-
time combined with the
flexibility of software real
-
time.







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. There are

many real
-
time control systems in the world around you such as the
cruise control in your car or the thermostat controlling the temperature in your home. There are
different ways to measure or describe a real
-
time control application
-

control loop cycle
time,
determinism, jitter, and soft real
-
time.



-

2

-





Control Loop Cycle Time


Most real
-
time control systems monitor the physical system, compare the current state w
ith 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 and jitter


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.






Hard Real
-
Time and Soft Real
-
Time


Real
-
time control applications can be mapped onto a spectrum of performance. On one side,
hard real
-
time systems are very deterministic and n
ever miss an event. An example of a hard
real
-
time system in an engine dynamometer. If an event were missed. the data collected or the
road conditions simulated would be incorrect. On the other side of the spectrum, soft real
-
time
systems do not require th
e same degree of determinism and occasionally miss events without
malfunctioning. For example, missing a single data point in a temperature monitoring system
does not impact the overall trend because the general trend of temperature changes slowly.






Real
-
Time Signal Processing


Real
-
time signal processing has many of the same characteristics as real
-
time control. It
requires deterministic time intervals between re
petitive events. But instead of calculating a
response, it performs signal processing on the acquired data. An example of such a system is
calculating the frequency of a signal. The example deterministically acquires a collection of
values that represents
a waveform and then performs a power spectrum on that data in a loop.
While this example analyzes a waveform in blocks of data, it could also have analyzed each
data value as it was acquired with a point by point analysis routine.

In many applications, po
int by point analysis routines provide better performance. Instead of
analyzing blocks of data, these routines maintain a memory of previous data and calculate a
new output based on the history of the data and the current value. Hard real
-
time performance
is necessary in these systems because missing input values or even acquiring these values
after a small time delay destroys the integrity of the historical data for future calculations. These
routines reduce the time delay between acquiring the data and ge
nerating a result. For
instance, a simple digital filter application acquires 1000 points of data in one second, filters the
data, then generates the filtered waveform. While the filtered waveform is accurate, it is
generated an entire second after it is i
nitially acquired., introducing a large time delay or phase
difference. With a point by point filter, the waveform is filtered after each data point is acquired,
reducing the time delay to microseconds.

By filtering after each point is acquired, you can al
so increase the resolution in the decision
making process, and improve the performance of the overall system.

-

3

-






Real Time Event Response


With real
-
time event res
ponse, 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
sa
fety 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
d
eterminism in real
-
time control applications. With real
-
time event response, you are
guaranteed a worst case latency.






Real
-
Time Operating Systems


At the core o
f a software real
-
time system is a real
-
time operating system. One of the main
differences between real
-
time operating systems and general
-
purpose operating systems is the
ability to guarantee a worst case latency. On a general
-
purpose OS, an external inte
rrupt could
be put into a queue and then serviced later after the OS has finished its current operation and
any other interrupts in the queue.


On the other hand, a real
-
time OS can halt its current process to handle an interrupt
immediately. In essence, t
he real
-
time OS guarantees event response within a certain interval.
To do this, the real
-
time OS assigns priorities to processes and interrupts. If a high priority
interrupt occurs, the OS immediately halts its process and services the interrupt.






Embedded and Headless Applications


Many real
-
time applications are embedded, but not all embedded applications exhibit real
-
time
performance. While real
-
time applicati
ons always adhere to strict timing characteristics,
embedded systems are not as simple to categorize.


An embedded system is usually small in physical dimensions and has fewer features than a
regular computer. While there is not a defining feature of embed
ded systems, they often have
smaller memory units, smaller processors, and fewer peripherals. Because they lack the
general
-
purpose nature of desktop computers, you program them to act as dedicated devices.


Headless devices are embedded systems without pe
ripherals. Programs are often downloaded
to these devices through a network connection. This same network connection is often used as
a means of configuring these devices. While this might seem like a limiting feature, with
broadband networks and intellige
nt application software, you can now create headless devices
with a simple pull down menu.