Scilab Arduino Blinking LED Tutorial
Scilab Arduino Blinking LED Tutorial
This
tutorial
aims
at
showcasing
the
capabilities
of
Scilab
for
prototyping
electronic
embedded
systems
with
Arduino.
Configuration/Arduino
Setup
In
order
to
follow
this
tutorial
you
need
the
following
configuration:
Software:
-‐ Scilab
on
Windows
32
or
64
bits
(Version
>=
5.4)
-‐ Arduino
toolbox
http://atoms.scilab.org/toolboxes/arduino
Help
on
the
installation
of
the
module
(in
French):
https://www.scilab.org/en/community/education/si/install
-‐ Arduino
IDE
http://arduino.cc/en/Main/Software
Hardware:
Plug
your
Arduino
Board
to
your
PC,
open
the
Arduino
IDE
and
flash
the
file
toolbox_arduino_v3.ino
on
the
Arduino
Board.
Set
up
the
following
hardware
configuration:
Configuration
blocks
In
order
to
acquire
the
Port
number
linked
with
the
Arduino
board,
look
in
the
bottom
right
corner
of
your
Arduino
IDE:
Start to build the Xcos schema, with the configuration blocks:
Double
click
on
the
block
to
let
the
following
dialog
box
appear:
Set the Serial com port number with the information acquired in the previous step.
The
sampling
of
the
signal
for
the
blocks
of
the
model
and
the
time
of
acquisition
are
configured
by
this
block:
The
sampling
period
can
be
specified
and
has
to
be
at
least
twice
smaller
than
the
period
of
evolution
of
the
model
(Nyquist-‐Shannon
sampling
theorem)
Xcos
model
Simulating
an
input
signal
for
the
LED
can
be
done
with
the
Pulse
Generator
block
PULSE_SC:
http://help.scilab.org/docs/5.5.2/en_US/PULSE_SC.html
• Amplitude
The
amplitude
of
the
pulse.
It
can
support
all
scicos
types.
Properties
:
Type
'mat'
of
size
[-‐1,-‐1].
As
specified
in
the
configuration
blocks,
the
period
of
the
signal
(1s)
is
more
than
twice
the
period
of
sampling
(0.1s).
In
our
example,
we
plugged
the
LED
in
the
digital
I/O
13
of
the
Arduino
board,
so
we
will
have
to
set
the
pin
13
successively
to
1
and
0
(electrically
speaking
to
5V
or
0V),
to
turn
respectively
the
LED
on
and
off.
Behavior
visualization
In
order
to
display
the
signal
turning
on
and
off
the
LED
while
the
command
of
the
circuit,
we
will
add
a
scope
to
the
model:
We
need
to
use
here
a
scope
provided
by
the
Arduino
module’s
blockset,
which
doesn’t
require
a
clock
parameter
input,
as
it
is
directly
synchronized
with
the
sampling
period
of
the
configuration
block.
Simulation/Acquisition
of
the
signal
After
linking
all
of
the
previously
described
blocks,
the
Xcos
schema
should
look
like
this:
After hitting on the play button, the LED blinks at the same time as the following curve is plotting:
Sources
-‐
TP3
:
Acquérir
et
piloter
des
systèmes
à
l'aide
de
cartes
Arduino
et
d'une
Toolbox
Xcos
dédiée
-‐
TP3
Démosciences
2012.pdf
http://www.demosciences.fr/projets/scilab-‐arduino
-‐ Scilab
/
Xcos
pour
l’enseignement
des
sciences
de
l’ingénieur
–
©
2013
Scilab
Enterprises
chapitre
«
4-‐
acquisition
et
pilotage
de
moteur
(module
arduino)
»
-‐
livret_Xcos.pdf
www.scilab.org/fr/content/download/1017/9485/file/livret_Xcos.pdf
-‐ Contributors
:
Bruno
Jofret,
Scilab
Enterprises,
Alain
Caignot,
Lycée
Stanislas
(Paris),
Vincent
Crespel,
Lycée
Saint
Louis
(Paris),
Marc
Derumaux,
Lycée
Saint
Louis
(Paris),
Cédric
Lusseau,
Lycée
Hoche
(Versailles),
Gilles
Moissard,
Lycée
Janson
de
Sailly
(Paris),
Pascal
Serrier,
Lycée
Benjamin
Franklin
(Orléans)
et
David
Violeau,
Lycée
Janson
de
Sailly
(Paris).