Starts DSP application on MicroDAQ
This function loads and starts DSP application generated from Xcos diagram. User hast to provide two parameters, 'path' where generated DSP application (*.out file) is located and 'sampleTime' parameter which allows to run DSP application with different model sample rate. When 'sampleTime' parameter is -1, DSP application will be executed with model sample rate defined in Xcos model, if different value provided Xcos model sample time will be overwritten.
Function loads Ext and Standalone mode DSP applications.
After DSP application is started (in Ext mode) it starts to send data to host and Scilab script can receive data with mdaqDSPSignalRead() function.
mdaqDSPStart(path, sampleTime); mdaqDSPStart(linkID, path, sampleTime);
linkID: Valid connection link id (optional)
path : DSP application path
sampleTime: DSP application sample rate (in seconds)
// Script execution duration in seconds TIME = 20; // Model execution frequency in Hertz FREQ = 5000; // Build DSP binary from Xcos model mdaqDSPBuild(mdaqToolboxPath() + filesep() + "examples" + filesep() +"fft_demo.zcos"); // Start DSP application mdaqDSPStart('fft_demo_scig\fft_demo.out', 1.0/FREQ); first_time = 1; a = []; s = []; // Process data from DSP sample_count = FREQ/10; fig = figure("Figure_name","MicroDAQ FFT demo"); for i=1:(TIME*10) s = mdaqDSPSignalRead(1, 1, sample_count, 1000); N=size(s,'*'); //number of samples s = s - mean(s);//cut DC y=fft(s'); f= FREQ*(0:(N/10))/N; //associated frequency vector n=size(f,'*'); if is_handle_valid(fig) then if first_time == 1 then clf(); plot(f,abs(y(1:n))); title("FFT", "fontsize", 3); xlabel("frequency [Hz]","fontsize", 3); first_time = 0; a = gca(); else a.children.children.data(:,2) = abs(y(1:n))'; end else break; end end // Stop DSP execution mdaqDSPStop(); // Close plot mprintf("\nFFT demo has been stopped."); if is_handle_valid(fig) then close(fig); end | ![]() | ![]() |