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.
WARNING: TCP/IP protocol is used for data exchange in Ext mode - make sure that the mdaqDSPStop() is called after/during DSP execution, otherwise next mdaqDSPStart() call will fail!
result = mdaqDSPStart(path, sampleTime); result = mdaqDSPStart(connectionId, path, sampleTime);
connection_id : Connection ID returned by mdaqOpen() (OPTIONAL)
path : DSP application path
result : dsp_start() execution result
// 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 result = mdaqDSPStart('fft_demo_scig\fft_demo.out', 1.0/FREQ); if result < 0 then abort; end // Register signal ID and signal size result = mdaqDSPSignal(1, 1); if result < 0 then disp("ERROR: unable to register signal"); abort; end first_time = 1; a = []; // Process data from DSP sample_count = FREQ/10; fig = figure("Figure_name","MicroDAQ FFT demo"); for i=1:(TIME*10) [result, s] = mdaqDSPSignalRead(sample_count); if result < 0 then disp("ERROR: unable to read signal data!"); abort; end 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 |