This example shows how to use Analog Input block to acquire live signals from a data acquisition device into Simulink. In this example, a National Instruments® device (USB-6211) is selected as the input device in the Analog Input block. The Simulink model use a spectrum estimator to output a power spectrum estimate of a time-domain input using Welch's method of averaged modified periodograms.
Note: This example requires MATLAB®, Simulink, Data Acquisition Toolbox and DSP System Toolbox™ to open and run the model.
The input signal is a real-time analog signal sampled at 10000 samples per second. The Analog Input block is configured to do Asynchronous acquisiton, which buffers the data from the analog channels and streams the buffered data to Simulink. Each timestep Analog Input block outputs a chunk of 1024 samples. Each chuck of data is processed by a Spectrum Estimator to calculate the power spectrum. You can adjust the settings in the Spectrum Estimator such as different window functions.
In this example the captured signal contains three major frequency components: sine waves at 50Hz, 250Hz and 500Hz. The time domain signal, frequency domanin signal from Sprectrum Analyzer and the one-side power spectrum estimate by spectrum estimator are shown below.
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.