Documente Academic
Documente Profesional
Documente Cultură
1
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Agenda
MicroDAQ device and software overview
MicroDAQ toolbox for Scilab
Features overview
Code generation for MicroDAQ DSP core
Tools
Examples
Q& A
2
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ device
Real-time control and measurement system
Dedicated DSP core for signal
and real-time processing
Ethernet, USB2.0 and WiFi connectivity
ADC, DAC, DIO, PWM, Encoder,...
3
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ device
MicroDAQ E1100 MicroDAQ E2000 MicroDAQ OEM
4
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ device
Processing units
TI C6000 DSP core with floating/fixed point unit C6000 DSP ARM
ARM core with Linux OS for handling communication, 375/456MHz
Floating/fixed
375/456MHz
file storage, web interface point with Linux
two PRU 32-bit RISC cores for real-time processing
Storage up to 32GB PRU0 PRU1
187/228MHz 187/228MHz
Digital I/O 32-bit RISC 32-bit RISC
MLink software
Windows/Linux support
Access to MicroDAQ resources
Loading DSP
Scilab support functions
DSPLib
LabVIEW support package
Matlab/Simulink Embedded Coder target
MicroDAQ toolbox for Scilab
Available at: https://github.com/microdaq
6
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ toolbox features
Automatic code generation for MicroDAQ DSP
Xcos blocks for MicroDAQ peripherals
Live data access from generated DSP
application via Ethernet and WiFi
with standard Xcos sinks
Application loading with Ethernet and WiFi
Standalone mode
Easy integration of custom user C code
7
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ toolbox features
8
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ toolbox components
MLink
Texas Instruments
Loading DSP binary
Code Composer Studio 5
TCP data communication
C6000 DSP compiler
SYS/BIOS RTOS
MicroDAQ
Toolbox
Scilab libs DSPLib
Precompiled Scilab DSP drivers for MicroDAQ
libraries for DSP core TCP data communication
9
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Installation
Atoms → Instrumentn Control → MicroDAQ Toolbox
Install Code Composer Studio 5.5 – with C6000 DSP compiler
and SYS/BIOS RTOS
microdaq_setup
Code Composer Studio
installation paths
SYS/BIOS RTOS compilation
connect MicroDAQ device
and setup IP settings
check connection
-->mdaq_ping
Connecting to MicroDAQ@10.10.1.1...OK!
Ready to go! 10
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ toolbox blocks
MicroDAQ blocks for
hardware access
Special MicroDAQ blocks for
setup model parameters
Standard Xcos blocks
compiled for DSP
Host simulation mode
and code generation
11
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
MicroDAQ special blocks
SETUP block
Simulation duration
Build type: debug/release
Build mode: Ext/Standalone
Execution profiling
ODE solver type
SIGNAL block
receive live data from DSP
STOP block
12
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Xcos diagram for code generation
SETUP block
Event generator to set step time
Superblock for code generation
Tools → MicroDAQ build
and load model
Execution mode
Standalone – load and start model
on DSP immediately
Ext – load model on DSP and wait
for user action
13
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Model execution modes
DSP application
Standalone mode
Model
(Real-time task)
DSP application
Model
Ext mode
(Real-time task)
14
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Code generation
Xcos
diagram ### Generating block structure...
SYS/BIOS RTOS
DSPLib
15
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Running DSP application with Xcos
simulation
MicroDAQ DSP Xcos
Xcos diagram
Code generation
Execute model
and send data with Xcos simulation
SIGNAL block receive data with SIGNAL block
16
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Running DSP application with Xcos
simulation
Generated DSP code Xcos simulation
int sin_demo_isr(double t)
{
● When DSP is loaded
int local_flag;
int i;
SIGNAL input is ignored
double *args[100];
/* Output computation */
/* Discrete activations */
● SIGNAL block receives
/* Blocks activated on the event number 1 */
/* Call of 'mdaq_sinus' (type 4 - blk nb 2) */ data from MicroDAQ
block_sin_demo[1].nevprt = 1;
local_flag = 1;
mdaq_sinus(&block_sin_demo[1],local_flag); ● When DSP in not loaded
/* Call of 'mdaq_signal' (type 4 - blk nb 3) */ copy SIGNAL block input
block_sin_demo[2].nevprt = 1;
local_flag = 1; to output
mdaq_signal(&block_sin_demo[2],local_flag);
● Discrite PD controller
18
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Execution profiling
19
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Custom user code
For new user creating custom block is a tough task
Block code and C code generation
Created code can be compiled for debug and
release
Block creation utility macros
mdaq_block();
mdaq_block_add();
mdaq_block_build( %t );
20
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
User custom code
/* Generated with MicroDAQ toolbox ver: 1.0. */
-->my_block = mdaq_block(); #include "scicos_block4.h"
Xcos
Scilab script
LabVIEW C/C++
application
23
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Utilizing DSP model in Scilab script
// Start DSP application
result = dsp_start('fft_demo_scig\fft_demo.out') ;
// Register signal ID and signal size
dsp_signal(123, 1);
first_time = 1;
a = [];
// Process data from DSP
sample_count = 500;
for i=1:500
[result, s] = dsp_signal_get(sample_count);
t = 0:1/sample_count:1;
N=size(t,'*'); //number of samples
y=fft(s');
f=sample_count*(0:(N/2))/N; //associated frequency vector
n=size(f,'*')
if first_time == 1 then
clf()
plot(f,abs(y(1:n)))
first_time = 0;
a = gca();
else
a.children.children.data(:,2) = abs(y(1:n))';
end
end
24
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Utilizing model with C/C++ application
Embed Xcos generated model in Windows/Linux
application
MLink interface functions
●
Example code
scilab_dsp_start("10.10.1.1", &port, "q:\\analog_loop.out", &link_id);
scilab_signal_register(&link_id, &id, &size, &result);
for (count = 0; count < 100; count++)
{
scilab_signal_read(&link_id, buf, &size, &result);
/* process DSP data */
scilab_mem_write(&link_id, 1, param, 2);
}
scilab_dsp_stop(&link_id, &result);
25
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Utilizing model with LabVIEW
Analog loop
SIGNAL block
MEM read block for model parameter change
26
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Utilizing model with LabVIEW
● Real-time processing
27
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Conclusions
28
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Q &A
29
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
Thnak you!
30
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl