Acquire data from multiple analog channels of data acquisition device
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.
The Analog Input 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 acquires data either synchronously (deliver the current block of data the device is providing) or asynchronously (buffer incoming data).
The block has no input ports. It has one or more output ports, depending on the configuration you choose in the Source Block Parameters dialog box. 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.
Use the Analog Input block to incorporate live measured data into Simulink for:
System and algorithm modeling
Model and design validation
Note: You can use the Analog Input block only with devices that support clocked acquisition. The block will error out when the model is run with a device that does not support clocking. To acquire data using devices that do not support clocking, use the Analog Input (Single Sample) block.
You can use this block for signal applications by using it with basic Simulink and DSP System Toolbox™.
You can use the Analog Input block either synchronously or asynchronously. Select the acquisition mode in the Source Block Parameters dialog box.
The following diagram shows the basic analog input usage scenario, in which you would:
Acquire data at each time step or once per model execution.
Analyze the data, or use it as input to a system in the model.
Optionally display results.
For an example of creating a model using the Analog Input block, see Example: Bringing Analog Data into a Model.
The Analog Input block supports the use of Simulink Accelerator™ mode. This feature speeds up the execution of Simulink models.
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.
Use the Source Block Parameters dialog box to select your acquisition mode and to set other configuration options.
Initiates the acquisition when the simulation starts. The simulation runs while data is acquired into a FIFO (First in, First out) buffer. The acquisition is continuous; the block buffers data while outputting a scan/frame of data at each time step.
Initiates the acquisition at each time step. The simulation will not continue until the requested block of data is acquired. This is unbuffered input; the block will synchronously output the latest scan/frame of data at each time step.
The following diagrams show the difference between synchronous and asynchronous modes for the Analog Input block.
Synchronous Analog Input
At the first time step (T1), the acquisition is initiated for the required block of data (B1). The simulation does not continue until B1 is completely acquired.
Asynchronous Analog Input – Scenario 1
Scenario 1 shows the case when simulation speed outpaces data acquisition speed. At the first time step (T1), the required block of data (B1) is still being acquired. Therefore, the simulation does not continue until B1 is completely acquired.
Asynchronous Analog Input – Scenario 2
Scenario 2 shows the case when data acquisition speed outpaces simulation speed. At the first time step (T1), the required block of data (B1) has been completely acquired. Therefore, the simulation runs continuously.
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.
The data acquisition device from which you want to acquire 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.
The rate at which samples are acquired from the device, in samples per second. This is the sampling time for the hardware. The default is defined when a device is selected.
The sample rate must be a positive real number, and be within the range allowed for the selected hardware.
The desired number of data samples to output at each time step for each channel. Block size corresponds to the SamplesPerTrigger property for an analog input device. The default value for block size depends on the hardware selected. It must be a positive integer, and be within the range allowed for the selected hardware.
Specifies the hardware channel configuration, such as single-ended, differential, etc. The input type is defined by the capabilities of the selected device.
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 acquire data from. These parameters are specified for each selected channel:
Hardware Channel — Displays the hardware channel ID specified by the device. The Hardware Channel column is read only and the parameters are defined when the device is selected.
The 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.
Input Range — Specifies the input ranges available for each channel supported by the hardware, and is defined when a device is selected.
Select 1 for all hardware channels (default) or 1 per hardware channel.
Using 1 for all hardware channels outputs data from a single port as a matrix, with a size of Block size x Number of Channels selected.
Using 1 per hardware channel outputs data from N ports, where N is equal to the number of selected channels. Each output port will be a column vector with a size of Block size x 1. For naming, each output port will use the channel name if one was specified, or otherwise use [HWChannel + channel ID], for example, HWChannel2.
Select Sample-based or Frame-based. This option determines whether the signal type is sample-based or frame-based. Sample-based is the default.
Select your data type to output from the block. The Analog Input block supports double and native data types, as supported by the hardware. double is the default. Native data types will be dynamically populated in this list based on the hardware that is selected. For example, if int16 is a native data type of a specific hardware device, then one of the entries for Data type will be int16 (native).