perform live acquisition, signal processing, and generation -凯发k8网页登录
this example shows how to use 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 a data acquisition device. it shows how a simulink model can communicate with different subsystems in the same model. in this case, the data acquisition device used is from national instruments®.
note: this example requires matlab®, data acquisition toolbox, and simulink to open and run the model.
live data input
the input signal is acquired from a 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 acquisition, 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 an analog input channel. to correctly interpret the data, in the downstream processing/visualization blocks, you need to use 'columns as channels (frame-based)' as input processing method.
signal processing
the acquired data is processed using a discrete filter. the discrete filter uses pre-computed coefficients to implement a bandpass filter with a bandwidth 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 . 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.
live data output
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.