Documentation

Analog Output

Output data to multiple analog channels of data acquisition device

Library

Data Acquisition Toolbox™

    Note:   You cannot use certain devices with Data Acquisition Toolbox Simulink® blocks. Refer to the Supported Hardware page to see if your device supports Simulink use.

Description

The Analog Output block opens, initializes, configures, and controls an analog data acquisition device. The opening, initialization, and configuration of the device occur once at the start of the model's execution. During the model's run time, the block outputs data to the hardware either synchronously (outputs the block of data as it is provided) or asynchronously (buffers output data).

    Note:   You need a license for both Data Acquisition Toolbox and Simulink software to use this block.

The block has one or more input ports, depending on the option you choose in the Sink Block Parameters dialog box. It has no output ports. The following diagram shows the block configured with one port for both channels and with one port for each channel, in the case of a device that has two channels selected.

    Note:   You can use the Analog Output block only with devices that support clocked generation. The block will error out when the model is run with a device that does not support clocking. To send data using devices that do not support clocking, use the Analog Output (Single Sample) block.

The Analog Output block inherits the sample time from the driving block connected to the input port. The valid data types of the signal at the input port are double or native data types supported by the hardware.

Other Supported Features

The Analog Output block supports the use of Simulink Accelerator™ mode. This feature speeds up the execution of Simulink models.

    Note:   You need the C++ Compiler to use Simulink Accelerator mode.

The block supports the use of model referencing. This feature lets your model include other Simulink models as modular components.

For more information on these features, see the Simulink documentation.

Dialog Box

Use the Sink Block Parameters dialog box to select your acquisition mode and to set other configuration options.

Output Mode

Asynchronous

Initiates data output to the hardware when simulation starts. The simulation runs while data is output from a FIFO (First In, First Out) buffer. This mode buffers and outputs data from the block, letting you perform a frame-based or sample-based output.

Synchronous

Initiates data output to the hardware at each time step. The simulation will not continue running until the current block of data is output. In synchronous mode, the block synchronously outputs a vector or frame of samples provided at each time step.

The following diagrams show the difference between synchronous and asynchronous analog output.

Synchronous Analog Output

At the first time step (T1), data output is initiated and the corresponding block of data (B1) is output to the hardware. The simulation does not continue until B1 is output completely.

Asynchronous Analog Output – Scenario 1

Scenario 1 shows the case when data output speed outpaces simulation speed. At the first time step (T1), data output is initiated and the corresponding block of data (B1) is output to the hardware. The simulation runs continuously in this mode.

Asynchronous Analog Output – Scenario 2

Scenario 2 shows the case when simulation speed outpaces data acquisition speed. At the first time step (T1), data output is initiated and the corresponding block of data (B1) is output to the hardware. Data is queued at successive time steps and is output to the hardware once the previous block completes. The simulation runs continuously in this mode.

    Note:   Several factors, including device hardware and model complexity, can affect the simulation speed, causing both scenarios 1 and 2 to occur within the same simulation.

Options

Device

The data acquisition device to which you want to output data. The items in the list vary, depending on which devices you have connected to your system. Devices in the list are specified by adaptor/vendor name and unique device ID, followed by the name of the device. The first available device is selected by default.

Hardware output rate

The rate at which samples are output to the device, in samples per second. This output rate for the hardware is defined when a device is selected. The output rate specified must be within the range supported by the selected device.

Channels

The channel configuration table lists your device's hardware channels and lets you configure them. Use the check boxes and selection buttons to specify which channels to send data to.

Hardware Channel — Displays the channel ID specified by the device, and is read only.

Name — specifies the channel name. By default the table displays any names provided by the hardware, but you can edit the names. For example, if the device is a sound card with two channels, you can name them Left and Right.

Output Range — Specifies the output ranges available for each channel supported by the hardware, and is defined by the selected device.

Initial Value — Specifies the initial value to be output at the start of the simulation, if you are using Asynchronous mode. The default value is 0. In Synchronous mode, the Initial Value column does not appear in the table.

    Note:   For AC-coupled devices like a sound card, this column is not used and is read only.

Number of ports

Select 1 for all hardware channels (default) or 1 per hardware channel.

Using 1 for all hardware channels inputs data from a single port as a matrix, with a size of [S x Number of Channels selected], where S is number of samples provided as input.

Using 1 per hardware channel inputs data from N ports, where N is equal to the number of selected channels. Each input port will be a column vector with a size of [S x 1], where S is the number of samples provided as an input. For naming, each output port will use the channel name if one was specified, or otherwise use ["HWChannel" + channel ID], for example, HWChannel2.

See Also

Analog Input, Analog Input (Single Sample), Analog Output (Single Sample), Digital Input, Digital Output

Was this topic helpful?