SlideShare a Scribd company logo
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
1
Utilizing Scilab and Xcos
for real-time control
and measurement applications
Grzegorz Skiba
Embedded Solutions
skiba.g@embedded-solutions.pl
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
2
Agenda
 MicroDAQ device and software overview
 MicroDAQ toolbox for Scilab
 Features overview
 Code generation for MicroDAQ DSP core
 Tools
 Examples
 Q&A
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
3
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,...
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
4
MicroDAQ device
MicroDAQ E1100
 375MHz CPU
 4GB flash memory
 Ethernet
 Wi-Fi
 USB2.0
 32 DIO lines
 8 analog inputs
 8 analog outputs
 Matlab/Simulink, LabVIEW
and Scilab support
 Price from 200€
MicroDAQ E2000
 up to 456MHz CPU
 up to 32GB flash memory
 Ethernet
 Wi-Fi
 USB2.0
 16 DIO lines
 up to 16 analog inputs
 8 analog outputs
 Matlab/Simulink, LabVIEW,
Scilab support
 Price from 400€
MicroDAQ OEM
 375MHz CPU
 4GB flash memory
 Ethernet
 USB2.0
 USB1.1
 32 DIO lines
 8 analog inputs
 8 analog outputs
 Matlab/Simulink, LabVIEW,
Scilab support
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
5
MicroDAQ device
 Processing units
 TI C6000 DSP core with floating/fixed point unit
 ARM core with Linux OS for handling communication,
file storage, web interface
 two PRU 32-bit RISC cores for real-time processing

Storage up to 32GB

Digital I/O
 16/32 DIOs, 6 PWMs, 2 Encoders, UART

Analog I/O
Analog input Analog output
166ksps, 8 channel, 12-bit, ±10V range
166ksps, 8 channel, 16-bit, ±10V range
600ksps, 8 channel, 12-bit, ±10V range
600ksps, 16 channel, 12-bit, ±10V range
500ksps, 16 channel, 16-bit, ±10V range
4000ksps, 2 channel, 16-bit, ±10V range
8 channel, 12-bit, 0-5V range
8 channel, 12-bit, ±10V range
8 channel, 16-bit, ±10V range
Simultanious sampling ADCs
C6000 DSP
375/456MHz
Floating/fixed
point
ARM
375/456MHz
with Linux
PRU0
187/228MHz
32-bit RISC
PRU1
187/228MHz
32-bit RISC
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
6
MicroDAQ software
 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
Host
MLink library
Linux/Windows
UDP/TCP
Ethernet
Wi-Fi
Scilab/Xcos
LabVIEW
Matlab/Simulink
C/C++ application
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
7
MicroDAQ toolbox features
 Automatic code generation for MicroDAQ DSP
 Xcos 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
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
8
MicroDAQ toolbox features
 MicroDAQ hardware (ADC, DAC...) access
macros
 DSP model utilization with Scilab script, C/C++
application and LabVIEW
 Execution profiling
 Toolbox as a part for Atoms installer
 Support for Linux and Windows
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
9
MicroDAQ toolbox components
Texas Instruments
Code Composer Studio 5
C6000 DSP compiler
SYS/BIOS RTOS
MicroDAQ
Toolbox
Loading DSP binary
TCP data communication
MLink
DSP drivers for MicroDAQ
TCP data communication
DSPLib
Precompiled Scilab
libraries for DSP core
Scilab libs
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
10
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!
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
11
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
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
12
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
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
13
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
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
14
Model execution modes
Model
(Real-time task)
TCP communication
(Idle task)
DSP application
MLink
TCP communication
Xcos
Model
(Real-time task)
DSP application
Ext mode
Standalone mode
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
15
Code generation
### Generating block structure...
### Writing generated code...
### Generating Makefile...
### Generating binary file...
"C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740…
"C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740…
"C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740…
"C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740…
<Linking>
"MicroDAQ DSP application led_demo.out created successfully"
Xcos
diagram
mdaq_ext_main.c or
mdaq_standalone_main.c
C code generation
C6000 DSP compiler
C6000 linker
SYS/BIOS RTOS
DSPLib
MicroDAQ blocks
Scilab libs
DSP binary
Makefile generation
SETUP block
Loading DSP binary
User blocks lib
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
16
Running DSP application with Xcos
simulation
MicroDAQ DSP Xcos
Code generation
Loading DSP on targetInitialize model execution
create TCP server
Wait for connection
Xcos Start button action
connects to MicroDAQ and
starts Xcos simulation
Create connection with host
Execute model
and send data with
SIGNAL block
Xcos simulation
receive data with SIGNAL block
Xcos diagram
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
17
Running DSP application with Xcos
simulation
Generated DSP code
int sin_demo_isr(double t)
{
int local_flag;
int i;
double *args[100];
/* Output computation */
/* Discrete activations */
/* Blocks activated on the event number 1 */
/* Call of 'mdaq_sinus' (type 4 - blk nb 2) */
block_sin_demo[1].nevprt = 1;
local_flag = 1;
mdaq_sinus(&block_sin_demo[1],local_flag);
/* Call of 'mdaq_signal' (type 4 - blk nb 3) */
block_sin_demo[2].nevprt = 1;
local_flag = 1;
mdaq_signal(&block_sin_demo[2],local_flag);
/* Call of 'cscope' (type 4 - blk nb 4) */
block_sin_demo[3].nevprt = 1;
local_flag = 1;
cscope(&block_sin_demo[3],local_flag);
return 0;
}
Xcos simulation
● When DSP is loaded
SIGNAL input is ignored
● SIGNAL block receives
data from MicroDAQ
● When DSP in not loaded
copy SIGNAL block input
to output
● mdaq_signal() funciton puts data
to IDLE communication task
● cscope() function is empty
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
18
DC motor controller
● Sample time: 0.001s
● Discrite PD controller
● H-bridge for driving
DC motor
● Live data with standard
CSCOPE block
● Loging data to workspace
with standard 'To
workspace' block
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
19
Execution profiling
 Measure model execution time
 Optimization
 How 'fast' we can run model
 Execution profiling macros
 mdaq_exec_profile
 mdaq_exec_profile_show
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
20
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 );
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
21
User custom code
-->my_block = mdaq_block();
-->my_block
my_block =
name: "new_block"
desc: "Set new_block parameters"
param_name: [2x1 string]
param_size: [2x1 constant]
param_def_val: list
in: 1
out: 1
-->my_block.param_name
ans =
!param1 !
! !
!param2 !
-->mdaq_block_add(my_block);
/* Generated with MicroDAQ toolbox ver: 1.0. */
#include "scicos_block4.h"
extern double get_scicos_time( void );
/* This function will executed once at the beginning of model execution */
static void init(scicos_block *block)
{
/* Block parameters */
double *params = GetRparPtrs(block);
/* param size = 1 */
double param1 = params[0];
/* param size = 1 */
double param2 = params[1];
/* Add block init code here */
}
/* This function will be executed on every model step */
static void inout(scicos_block *block)
{
/* Block parameters */
double *params = GetRparPtrs(block);
/* param size = 1 */
double param1 = params[0];
/* param size = 1 */
double param2 = params[1];
/* Block input ports */
double *u1 = GetRealInPortPtrs(block,1);
int u1_size = GetInPortRows(block,1); /* u1_size = 1 */
/* Block output ports */
double *y1 = GetRealOutPortPtrs(block,1);
int y1_size = GetOutPortRows(block,1); /* y1_size = 1 */
/* Add block code here (executed every model step) */
}
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
22
MicroDAQ hardware access macros
link_id = mdaq_open();
ai_data = mdaq_ai_read(link_id, [1 2 3 4 5 6 7 8], 10, 1)
mdaq_close(link_id);
 Access to MicroDAQ hardware
without code generation
 Example
 IP settings managment
 Switching from Ethernet to Wi-Fi
mdaq_pwm_write
mdaq_pwm_init
mdaq_pru_set
mdaq_pru_get
mdaq_led_write
mdaq_key_read
mdaq_hs_ai_read
mdaq_hs_ai_init
mdaq_enc_read
mdaq_enc_init
mdaq_dio_write
mdaq_dio_read
mdaq_dio_func
mdaq_dio_dir
mdaq_ao_write
mdaq_ai_read
Scilab macros: mdaq_ping, mdaq_set_ip
mdaq_set_ip('10.10.2.1');
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
23
Model utilization
LabVIEW
Scilab script
Xcos
C/C++
application
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
24
Utilizing DSP model in Scilab script
// Start DSP application
result = dsp_start('fft_demo_scigfft_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
// Stop DSP execution
dsp_stop();
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
25
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);
●
/* Scilab interface funcations */
EXTERNC MDAQ_API void scilab_dsp_start( const char *addr, int *port, const char *dspapp, int *link_id );
EXTERNC MDAQ_API void scilab_dsp_stop( int *link_id, int *result );
EXTERNC MDAQ_API void scilab_signal_register( int *link_id, int32_t *id, int32_t *size, int *result );
EXTERNC MDAQ_API void scilab_signal_read( int *link_id, double *data, int32_t *count, int *result );
EXTERNC MDAQ_API int scilab_mem_read( int *link_id, int start_idx, int len, float *data );
EXTERNC MDAQ_API int scilab_mem_write( int *link_id, int start_idx, float data[], int len );
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
26
Utilizing model with LabVIEW
 Analog loop
 SIGNAL block
 MEM read block for model parameter change
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
27
Utilizing model with LabVIEW
● Real-time processing
● Live DSP data
● Parameter change during DSP
execution
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
28
Conclusions
 Code generation from Xcos diagram
 Real-time procesing
 Execution profiling
 DSP binary utilization with LabVIEW and
Windows/Linux C/C++ applications
 Different hardware options avaliable
 Easy to use
 Free alternative for commercial solutions
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
29
Q&A
Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015
Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl
30
Thnak you!

More Related Content

PDF
ScilabTEC 2015 - KIT
PPTX
Project P Open Workshop
PDF
ScilabTEC 2015 - Scilab
PPT
Sci scada toolbox
PDF
ScilabTEC 2015 - Evidence
PDF
ScilabTEC 2015 - Noesis Solutions
DOCX
Punit_Shah_resume
ScilabTEC 2015 - KIT
Project P Open Workshop
ScilabTEC 2015 - Scilab
Sci scada toolbox
ScilabTEC 2015 - Evidence
ScilabTEC 2015 - Noesis Solutions
Punit_Shah_resume

What's hot (18)

PDF
Getting started with RISC-V verification what's next after compliance testing
PDF
vlsi projects using verilog code 2014-2015
PDF
ScilabTEC 2015 - Xilinx
PPTX
Scilab Challenge@NTU 2014/2015 Project Briefing
PPT
scilab
PDF
FPGAs as Components in Heterogeneous HPC Systems (paraFPGA 2015 keynote)
PPTX
PPTX
Cape2013 scilab-workshop-19Oct13
PDF
VLSI IEEE PROJECTS LIST 2015 - 2016 / IEEE VLSI PROJECTS LIST 2015 - 2016
PDF
Modeling an Embedded Device for PSpice Simulation
PPT
Verification Automation Using IPXACT
PPTX
LEGaTO: Software Stack Programming Models
PPT
Magillem marcos av_silva
PDF
Ripes: Teaching Computer Architecture Through Visual and Interactive Simulators
PPTX
GNAT Pro User Day: QGen: Simulink® static verification and code generation
PPTX
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
PPTX
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
PDF
GNAT Pro User Day: Ada at Ansaldo STS
Getting started with RISC-V verification what's next after compliance testing
vlsi projects using verilog code 2014-2015
ScilabTEC 2015 - Xilinx
Scilab Challenge@NTU 2014/2015 Project Briefing
scilab
FPGAs as Components in Heterogeneous HPC Systems (paraFPGA 2015 keynote)
Cape2013 scilab-workshop-19Oct13
VLSI IEEE PROJECTS LIST 2015 - 2016 / IEEE VLSI PROJECTS LIST 2015 - 2016
Modeling an Embedded Device for PSpice Simulation
Verification Automation Using IPXACT
LEGaTO: Software Stack Programming Models
Magillem marcos av_silva
Ripes: Teaching Computer Architecture Through Visual and Interactive Simulators
GNAT Pro User Day: QGen: Simulink® static verification and code generation
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
GNAT Pro User Day: Ada at Ansaldo STS
Ad

Similar to ScilabTEC 2015 - Embedded Solutions (20)

PDF
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
DOC
CV_Arshad_21June16
PDF
Qualcomm Hexagon SDK: Optimize Your Multimedia Solutions
PDF
UplinQ - qualcomm® hexagon™ sdk optimize your multimedia solutions
DOCX
Lalit Singh FPGA resume
PPT
FPGA_prototyping proccesing with conclusion
PPTX
Developing a NodeBot using Intel XDK IoT Edition
PDF
Advanced View Pic Microcontroller Projects List _ PIC Microcontroller.pdf
PDF
AXONIM 2018 embedded systems development
PPTX
Андрій Озгович “IoT Cypress solution. Low cost, low power” {R0boCamp}
PPTX
Introducing the CrossLink Programmable ASSP
DOCX
Bindu_Resume
PDF
DCC Labs Company Presentation
PPT
Marek Suplata Projects
PPS
DACHSview++features
ODP
Multipilot pres-ufficiale alpago 2011
PDF
Pradeep_Embedded
DOCX
Assignmentdsp
PPTX
Postgraduate Projects in Scilab
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
CV_Arshad_21June16
Qualcomm Hexagon SDK: Optimize Your Multimedia Solutions
UplinQ - qualcomm® hexagon™ sdk optimize your multimedia solutions
Lalit Singh FPGA resume
FPGA_prototyping proccesing with conclusion
Developing a NodeBot using Intel XDK IoT Edition
Advanced View Pic Microcontroller Projects List _ PIC Microcontroller.pdf
AXONIM 2018 embedded systems development
Андрій Озгович “IoT Cypress solution. Low cost, low power” {R0boCamp}
Introducing the CrossLink Programmable ASSP
Bindu_Resume
DCC Labs Company Presentation
Marek Suplata Projects
DACHSview++features
Multipilot pres-ufficiale alpago 2011
Pradeep_Embedded
Assignmentdsp
Postgraduate Projects in Scilab
Ad

More from Scilab (20)

PDF
Statistical Analysis for Robust Design
PPTX
Electric motor optimization
PDF
Asteroidlanding - Scilab conference 2019 Keynote
PPTX
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
PDF
Scilab and Xcos for Very Low Earth Orbits satellites modelling
PPTX
X2C -a tool for model-based control development and automated code generation...
PPTX
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
PPTX
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
PPT
Scilab for real dummies j.heikell - part3
PPT
Scilab for real dummies j.heikell - part 2
PPT
Scilab for real dummies j.heikell - part 1
PDF
Multiobjective optimization and Genetic algorithms in Scilab
PDF
Scilab optimization workshop
PDF
INRA @ Scilab Conference 2018
PDF
Qualcomm @ Scilab Conference 2018
PDF
Sanofi @ Scilab Conference 2018
PDF
University of Applied Science Esslingen @ Scilab Conference 2018
PPTX
DLR @ Scilab Conference 2018
PPTX
Fraunhofer IIS @ Scilab Conference 2018
PDF
Arcelormittal @ Scilab Conference 2018
Statistical Analysis for Robust Design
Electric motor optimization
Asteroidlanding - Scilab conference 2019 Keynote
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
Scilab and Xcos for Very Low Earth Orbits satellites modelling
X2C -a tool for model-based control development and automated code generation...
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 1
Multiobjective optimization and Genetic algorithms in Scilab
Scilab optimization workshop
INRA @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018
University of Applied Science Esslingen @ Scilab Conference 2018
DLR @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018

Recently uploaded (20)

PPTX
Introduction-to-Food-Packaging-and-packaging -materials.pptx
PDF
natwest.pdf company description and business model
PPT
The Effect of Human Resource Management Practice on Organizational Performanc...
PPTX
Effective_Handling_Information_Presentation.pptx
PDF
Swiggy’s Playbook: UX, Logistics & Monetization
PPTX
lesson6-211001025531lesson plan ppt.pptx
PPTX
water for all cao bang - a charity project
PDF
Presentation1 [Autosaved].pdf diagnosiss
PPTX
Self management and self evaluation presentation
DOC
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
PPTX
Relationship Management Presentation In Banking.pptx
PPTX
Primary and secondary sources, and history
PPTX
ART-APP-REPORT-FINctrwxsg f fuy L-na.pptx
PPTX
S. Anis Al Habsyi & Nada Shobah - Klasifikasi Hambatan Depresi.pptx
PPTX
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
PPTX
Intro to ISO 9001 2015.pptx wareness raising
PPTX
nose tajweed for the arabic alphabets for the responsive
PPTX
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
PPTX
Human Mind & its character Characteristics
PPTX
worship songs, in any order, compilation
Introduction-to-Food-Packaging-and-packaging -materials.pptx
natwest.pdf company description and business model
The Effect of Human Resource Management Practice on Organizational Performanc...
Effective_Handling_Information_Presentation.pptx
Swiggy’s Playbook: UX, Logistics & Monetization
lesson6-211001025531lesson plan ppt.pptx
water for all cao bang - a charity project
Presentation1 [Autosaved].pdf diagnosiss
Self management and self evaluation presentation
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
Relationship Management Presentation In Banking.pptx
Primary and secondary sources, and history
ART-APP-REPORT-FINctrwxsg f fuy L-na.pptx
S. Anis Al Habsyi & Nada Shobah - Klasifikasi Hambatan Depresi.pptx
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
Intro to ISO 9001 2015.pptx wareness raising
nose tajweed for the arabic alphabets for the responsive
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
Human Mind & its character Characteristics
worship songs, in any order, compilation

ScilabTEC 2015 - Embedded Solutions

  • 1. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 1 Utilizing Scilab and Xcos for real-time control and measurement applications Grzegorz Skiba Embedded Solutions skiba.g@embedded-solutions.pl
  • 2. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 2 Agenda  MicroDAQ device and software overview  MicroDAQ toolbox for Scilab  Features overview  Code generation for MicroDAQ DSP core  Tools  Examples  Q&A
  • 3. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 3 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,...
  • 4. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 4 MicroDAQ device MicroDAQ E1100  375MHz CPU  4GB flash memory  Ethernet  Wi-Fi  USB2.0  32 DIO lines  8 analog inputs  8 analog outputs  Matlab/Simulink, LabVIEW and Scilab support  Price from 200€ MicroDAQ E2000  up to 456MHz CPU  up to 32GB flash memory  Ethernet  Wi-Fi  USB2.0  16 DIO lines  up to 16 analog inputs  8 analog outputs  Matlab/Simulink, LabVIEW, Scilab support  Price from 400€ MicroDAQ OEM  375MHz CPU  4GB flash memory  Ethernet  USB2.0  USB1.1  32 DIO lines  8 analog inputs  8 analog outputs  Matlab/Simulink, LabVIEW, Scilab support
  • 5. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 5 MicroDAQ device  Processing units  TI C6000 DSP core with floating/fixed point unit  ARM core with Linux OS for handling communication, file storage, web interface  two PRU 32-bit RISC cores for real-time processing  Storage up to 32GB  Digital I/O  16/32 DIOs, 6 PWMs, 2 Encoders, UART  Analog I/O Analog input Analog output 166ksps, 8 channel, 12-bit, ±10V range 166ksps, 8 channel, 16-bit, ±10V range 600ksps, 8 channel, 12-bit, ±10V range 600ksps, 16 channel, 12-bit, ±10V range 500ksps, 16 channel, 16-bit, ±10V range 4000ksps, 2 channel, 16-bit, ±10V range 8 channel, 12-bit, 0-5V range 8 channel, 12-bit, ±10V range 8 channel, 16-bit, ±10V range Simultanious sampling ADCs C6000 DSP 375/456MHz Floating/fixed point ARM 375/456MHz with Linux PRU0 187/228MHz 32-bit RISC PRU1 187/228MHz 32-bit RISC
  • 6. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 6 MicroDAQ software  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 Host MLink library Linux/Windows UDP/TCP Ethernet Wi-Fi Scilab/Xcos LabVIEW Matlab/Simulink C/C++ application
  • 7. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 7 MicroDAQ toolbox features  Automatic code generation for MicroDAQ DSP  Xcos 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
  • 8. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 8 MicroDAQ toolbox features  MicroDAQ hardware (ADC, DAC...) access macros  DSP model utilization with Scilab script, C/C++ application and LabVIEW  Execution profiling  Toolbox as a part for Atoms installer  Support for Linux and Windows
  • 9. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 9 MicroDAQ toolbox components Texas Instruments Code Composer Studio 5 C6000 DSP compiler SYS/BIOS RTOS MicroDAQ Toolbox Loading DSP binary TCP data communication MLink DSP drivers for MicroDAQ TCP data communication DSPLib Precompiled Scilab libraries for DSP core Scilab libs
  • 10. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 10 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!
  • 11. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 11 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
  • 12. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 12 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
  • 13. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 13 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
  • 14. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 14 Model execution modes Model (Real-time task) TCP communication (Idle task) DSP application MLink TCP communication Xcos Model (Real-time task) DSP application Ext mode Standalone mode
  • 15. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 15 Code generation ### Generating block structure... ### Writing generated code... ### Generating Makefile... ### Generating binary file... "C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740… "C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740… "C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740… "C:ticcsv5toolscompilerc6000_7.4.4/bin/cl6x" -c -g -mv6740… <Linking> "MicroDAQ DSP application led_demo.out created successfully" Xcos diagram mdaq_ext_main.c or mdaq_standalone_main.c C code generation C6000 DSP compiler C6000 linker SYS/BIOS RTOS DSPLib MicroDAQ blocks Scilab libs DSP binary Makefile generation SETUP block Loading DSP binary User blocks lib
  • 16. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 16 Running DSP application with Xcos simulation MicroDAQ DSP Xcos Code generation Loading DSP on targetInitialize model execution create TCP server Wait for connection Xcos Start button action connects to MicroDAQ and starts Xcos simulation Create connection with host Execute model and send data with SIGNAL block Xcos simulation receive data with SIGNAL block Xcos diagram
  • 17. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 17 Running DSP application with Xcos simulation Generated DSP code int sin_demo_isr(double t) { int local_flag; int i; double *args[100]; /* Output computation */ /* Discrete activations */ /* Blocks activated on the event number 1 */ /* Call of 'mdaq_sinus' (type 4 - blk nb 2) */ block_sin_demo[1].nevprt = 1; local_flag = 1; mdaq_sinus(&block_sin_demo[1],local_flag); /* Call of 'mdaq_signal' (type 4 - blk nb 3) */ block_sin_demo[2].nevprt = 1; local_flag = 1; mdaq_signal(&block_sin_demo[2],local_flag); /* Call of 'cscope' (type 4 - blk nb 4) */ block_sin_demo[3].nevprt = 1; local_flag = 1; cscope(&block_sin_demo[3],local_flag); return 0; } Xcos simulation ● When DSP is loaded SIGNAL input is ignored ● SIGNAL block receives data from MicroDAQ ● When DSP in not loaded copy SIGNAL block input to output ● mdaq_signal() funciton puts data to IDLE communication task ● cscope() function is empty
  • 18. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 18 DC motor controller ● Sample time: 0.001s ● Discrite PD controller ● H-bridge for driving DC motor ● Live data with standard CSCOPE block ● Loging data to workspace with standard 'To workspace' block
  • 19. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 19 Execution profiling  Measure model execution time  Optimization  How 'fast' we can run model  Execution profiling macros  mdaq_exec_profile  mdaq_exec_profile_show
  • 20. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 20 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 );
  • 21. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 21 User custom code -->my_block = mdaq_block(); -->my_block my_block = name: "new_block" desc: "Set new_block parameters" param_name: [2x1 string] param_size: [2x1 constant] param_def_val: list in: 1 out: 1 -->my_block.param_name ans = !param1 ! ! ! !param2 ! -->mdaq_block_add(my_block); /* Generated with MicroDAQ toolbox ver: 1.0. */ #include "scicos_block4.h" extern double get_scicos_time( void ); /* This function will executed once at the beginning of model execution */ static void init(scicos_block *block) { /* Block parameters */ double *params = GetRparPtrs(block); /* param size = 1 */ double param1 = params[0]; /* param size = 1 */ double param2 = params[1]; /* Add block init code here */ } /* This function will be executed on every model step */ static void inout(scicos_block *block) { /* Block parameters */ double *params = GetRparPtrs(block); /* param size = 1 */ double param1 = params[0]; /* param size = 1 */ double param2 = params[1]; /* Block input ports */ double *u1 = GetRealInPortPtrs(block,1); int u1_size = GetInPortRows(block,1); /* u1_size = 1 */ /* Block output ports */ double *y1 = GetRealOutPortPtrs(block,1); int y1_size = GetOutPortRows(block,1); /* y1_size = 1 */ /* Add block code here (executed every model step) */ }
  • 22. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 22 MicroDAQ hardware access macros link_id = mdaq_open(); ai_data = mdaq_ai_read(link_id, [1 2 3 4 5 6 7 8], 10, 1) mdaq_close(link_id);  Access to MicroDAQ hardware without code generation  Example  IP settings managment  Switching from Ethernet to Wi-Fi mdaq_pwm_write mdaq_pwm_init mdaq_pru_set mdaq_pru_get mdaq_led_write mdaq_key_read mdaq_hs_ai_read mdaq_hs_ai_init mdaq_enc_read mdaq_enc_init mdaq_dio_write mdaq_dio_read mdaq_dio_func mdaq_dio_dir mdaq_ao_write mdaq_ai_read Scilab macros: mdaq_ping, mdaq_set_ip mdaq_set_ip('10.10.2.1');
  • 23. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 23 Model utilization LabVIEW Scilab script Xcos C/C++ application
  • 24. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 24 Utilizing DSP model in Scilab script // Start DSP application result = dsp_start('fft_demo_scigfft_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 // Stop DSP execution dsp_stop();
  • 25. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 25 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); ● /* Scilab interface funcations */ EXTERNC MDAQ_API void scilab_dsp_start( const char *addr, int *port, const char *dspapp, int *link_id ); EXTERNC MDAQ_API void scilab_dsp_stop( int *link_id, int *result ); EXTERNC MDAQ_API void scilab_signal_register( int *link_id, int32_t *id, int32_t *size, int *result ); EXTERNC MDAQ_API void scilab_signal_read( int *link_id, double *data, int32_t *count, int *result ); EXTERNC MDAQ_API int scilab_mem_read( int *link_id, int start_idx, int len, float *data ); EXTERNC MDAQ_API int scilab_mem_write( int *link_id, int start_idx, float data[], int len );
  • 26. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 26 Utilizing model with LabVIEW  Analog loop  SIGNAL block  MEM read block for model parameter change
  • 27. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 27 Utilizing model with LabVIEW ● Real-time processing ● Live DSP data ● Parameter change during DSP execution
  • 28. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 28 Conclusions  Code generation from Xcos diagram  Real-time procesing  Execution profiling  DSP binary utilization with LabVIEW and Windows/Linux C/C++ applications  Different hardware options avaliable  Easy to use  Free alternative for commercial solutions
  • 29. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 29 Q&A
  • 30. Utilizing Scilab and Xcos for real-time control and measurement applications – ScilabTEC 2015 Embedded Solutions; Skiba Grzegorz; skiba.g@embedded-solutions.pl 30 Thnak you!