Use Analog I/O Drivers

Control systems have unique requirements for I/O devices used with Real-Time Windows Target™ applications. For information about writing custom I/O device drivers to work with Real-Time Windows Target applications, see Custom I/O Driver Basics.

Configure I/O Driver Characteristics

Real-Time Windows Target applications use off-the-shelf I/O boards provided by many hardware vendors. These boards are often used for data acquisition independently of Real-Time Windows Target software. In such environments, board manufacturers usually provide their own I/O device drivers for data acquisition purposes. This use differs significantly from the behavior of drivers provided with Real-Time Windows Target software.

In data acquisition applications, data is often collected in a burst or frame consisting of many points, possibly 1,000 or more. The burst of data becomes available once the final point is available. This approach is not suitable for automatic control applications, because it results in unacceptable latency for most of the data points.

In contrast, drivers used by Real-Time Windows Target applications capture a single data point at each sample interval. Considerable effort is made to minimize the latency between collecting a data point and using the data in the control system algorithm. This is why a board might specify a maximum sample rate (for data acquisition) higher than the rates achievable by Real-Time Windows Target applications. For data acquisition, such boards usually acquire data in bursts and not in the point-by-point fashion required by control systems.

Normalize Scaling for Analog Inputs

Real-Time Windows Target software allows you to normalize I/O signals internal to the block diagram. Generally, inputs represent real-world values such as angular velocity, position, temperature, pressure, and so on. This ability to choose normalized signals allows you to

  • Apply your own scale factors

  • Work with meaningful units without having to convert from voltages

When using an Analog Input block, you select the range of the external voltages that are received by the board, and you choose the block output signal. For example, the voltage range could be set to 0 to +5 V, and the block output signal could be chosen as Normalized unipolar, Normalized bipolar, Volts, or Raw.

If you prefer to work with units of voltage within your Simulink® block diagram, you can choose Volts.

If you prefer to apply your own scaling factor, you can choose Normalized unipolar or Normalized bipolar, add a Gain block, and add an offset to convert to a meaningful value in your model.

If you prefer unrounded integer values from the analog-to-digital conversion process, you can choose Raw.

0 to +5 Volts and Normalized Bipolar

From the Input range list, choose 0 to +5 V, and from the Block output signal list, choose Normalized bipolar. This example converts a normalized bipolar value to volts, but you could also easily convert directly to another parameter in your model.

0 to 5 volts --> ([-1 to 1] normalized + 1) * 2.5 

In your block diagram, you can do this as follows.

0 to +5 Volts and Normalized Unipolar

From the Input range list, choose 0 to +5 V, and from the Block output signal list, choose Normalized unipolar. This example converts a normalized unipolar value to volts, but you could also easily convert directly to another parameter in your model.

0 to 5 volts --> ([0 to 1] normalized * 5.0 

In your block diagram, you can do this as follows.

-10 to +10 Volts and Normalized Bipolar

From the Input range list, choose -10 to +10 V, and from the Block output signal list, choose Normalized bipolar. This example converts a normalized bipolar value to volts, but you could also easily convert directly to another parameter in your model.

-10 to 10 volts --> [-1 to +1] normalized * 10

In your block diagram, you can do this as follows.

-10 to +10 Volts and Normalized Unipolar

From the Input range list, choose -10 to +10 V, and from the Block output signal list, choose Normalized unipolar. This example converts a normalized bipolar value to volts, but you could also easily convert directly to another parameter in your model.

-10 to 10 volts --> ([0 to 1] normalized - 0.5) * 20

In your block diagram, do this as follows.

Normalize Scaling for Analog Outputs

Analog outputs are treated in an equivalent manner to analog inputs.

If the voltage range on the D/A converter is set to 0 to +5 volts, and the Block input signal is chosen as Normalized bipolar, then a Simulink signal of amplitude -1 results in an output voltage of 0 volts. Similarly, a Simulink signal of amplitude +1 results in an output voltage of +5 volts.

A voltage range on the D/A converter is set to -10 to +10 volts, and the Block input signal is chosen as Normalized bipolar, then a Simulink signal of amplitude -1 results in an output voltage of -10 volts. Similarly, a Simulink signal of amplitude +1 results in an output voltage of +10 volts.

This may require that you adjust your signal amplitudes using a Gain block, Constant block, and Summer block depending on the selected voltage range.

Was this topic helpful?