This example shows how to uses the Analog Input block to acquire live analog data from a data acquisition device into Simulink. The acquired data is processed in Simulink and uses the Analog Output block to output data to an analog data acquisition device. Its shows how a Simulink model can communicate with different subsystems in the same model. In this case, the data acquisition devices used is from National Instruments®.
Note: This example requires MATLAB®, Data Acquisition Toolbox and Simulink to open and run the model.
The input signal is acquired from an National Instruments data acquisition device (USB-6211). Signal is acquired from channel ai0 at the rate of 8000 samples/second. The Analog Input block is configured to do Synchronous acquisiton, which does blocking read from the device and at each timestep it acquires a chunk of 1600 samples from the hardware.
Note: Each column in the output of Analog Input block corresponds to data from a analog input channel. To correctly inpretprete the data, in the downstream processing/visualization blocks, you need to use 'Columns as Channels (frame based)' as Input Prosessing method.
The acquired data is processed using a discrete filter. The discrete filter uses pre-computed coefficients to implement a bandpass filter with a bandwith of 50Hz around 100Hz and an attenuation of 60dB elsewhere, for input signals sampled at 8kHz. To design digital filters, to select specific implementation structures, use blocks from the "Filtering" library in DSP System Toolbox The capture data has three major frequency components: sine waves at 100Hz, 500Hz and 1000Hz. After the discrete filter, you would see a clear 100Hz sine wave in the output. A plot of the input and the filtered signals are shown below.
The processed data is output to a single channel of a National Instruments device (PCI-6211) at a rate of 8000 samples/second.
Even though a National Instruments device was used for this example, this model can be easily updated to connect to other supported data acquisition devices. This provides you the flexibility to reuse the same Simulink model with different data acquisition hardware.