
Our DSP application runs with 5kHz frequency so every 1/10sec we will new 500 samples from DSP and plot will be updated with new FFT result. Reading DSP samples and FFT calculation is done in a loop. The mdaqDSPSignalRead() will block Scilab until requested data is received. The mdaqDSPSignalRead() macro reads signal data from DSP, it needs one parameter which is data count which defines how many vectors will be read from DSP. The script will read 500 samples from DSP and makes FFT calculation on this data. In order to have access to signal data we have to register signal with mdaqDSPSignal() macro which takes two arguments, first one is signal ID defined in Xcos SIGNAL block and the second one is signal vector size which has to match with Xcos signal size. After this call DSP binary will be loaded and started on MicroDAQ DSP. When the user provides -1 as a rate argument model rate the default model rate defined in Xcos model will be used. Our script loads DSP application with mdaqDSPStart() macro which as an argument takes Xcos generated DSP binary path and model rate. = mdaqDSPSignalRead(sample_count) ĭisp( "ERROR: unable to read signal data!") į= FREQ*( 0:(N/ 10))/N //associated frequency vector Result = mdaqDSPStart( 'fft_demo_scig\fft_demo.out', 1.0/rate) Įnd // Register signal ID and signal sizeĭisp( "ERROR: unable to register signal") įig = figure( "Figure_name", "MicroDAQ FFT demo") MdaqDSPBuild(mdaqToolboxPath() + filesep() + "examples" + filesep() + "fft_demo.zcos") The example Scilab script which uses Xcos generated DSP application: mdaqDSPBuild(path) - builds DSP binary from Xcos model.mdaqDSPSignalRead(count) - reads Xcos signal.mdaqDSPSignal(id, size) - registers Xcos signal.mdaqDSPStop() - terminates DSP execution.mdaqDSPStart(path, rate) - starts DSP binary from path with rate.These macros can be used with a standard script to run DSP application in parallel with a Scilab script.

MicroDAQ toolbox for Scilab provides macros which manage DSP execution. Running DSP application from Scilab script The resulting application will be used in Scilab script for FFT calculation. Our model will run with 5kHz.Īfter model creation, we generate DSP application by selecting Tools->MicroDAQ build model. Data from ADC block is passed to SIGNAL block which sends data to host and this data can be read from Scilab script.


Then we use ADC block to read analog samples from DAC (analog input and output should be wired). The diagram contains two sine waveform generators which output is added and passed to DAC block. Our application will calculate FFT from real-time DSP data., we will start from creating example model which generates analog signal with two sine waveforms with different amplitude and frequency. The FFT example uses Xcos generated DSP application and Scilab FFT function which calculates FFT from real-time data. This way application can be divided into a real-time part, which is executed on MicroDAQ DSP and script which allows using all Scilab functions for calculations. MicroDAQ toolbox provides macros for managing DSP execution, a user can load DSP binary from Scilab script, register signal, read data from running DSP application and terminate its execution. We will show FFT example where the analog signal is generated on analog output and acquired with DSP management functions.
SCILAB FFT EXAMPLE HOW TO
In this article, we will show how to use DSP management tools.
