Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | File Exchange
ATOMS : Arduino details
Login with GitLab

Arduino

Arduino Communication through Serial
(41230 downloads for this version - 254004 downloads for all versions)
Details
Version
1.8
A more recent valid version exists: 1.9
Author
Bruno JOFRET
Owner Organization
Scilab Enterprises
Maintainers
Samuel GOUGEON
Chin Luh Tan
Samuel Gougeon
Stéphane MOTTELET
Clément DAVID
Bruno JOFRET
Categories
License
Creation Date
February 16, 2020
Source created on
Scilab 6.0.x
Binaries available on
Scilab 6.0.x:
Linux 64-bit Windows 64-bit
Scilab 6.1.x:
Linux 64-bit Windows 64-bit
Scilab 2023.0.x:
Windows 64-bit
Install command
--> atomsInstall("arduino")
Description
            This toolbox provides Arduino communication blocks for Xcos.

Source code hosted at : https://github.com/tanchinluh/arduino

Communication is performed through Serial port.

Report bugs @ https://gitlab.com/scilab/forge/arduino/-/issues

For version 1.8, the Arduino board must be flashed with the file
toolbox_arduino_v5.ino (shipped in the module and downloadable from the ATOMS
page).

TUTORIALS (in english)
----------------------
* Blinking LED Tutorial (created for older version, minor modification might be
required): 
https://atoms.scilab.org/toolboxes/arduino/1.5/files/Scilab_Arduino_Blinking_LED_Tutorial.pdf
* Temperature monitoring Tutorial:
 https://atoms.scilab.org/toolboxes/arduino/1.5/files/Scilab_Arduino_Temperature_monitoring_Tutorial.pdf

RESOURCES
---------
* Demosciences project (in french):
  http://www.demosciences.fr/projets/scilab-arduino

NOTE
----
* toolbox_arduino_v5.ino is shipped within the toolbox, including the
  MPU6050 bloc and filtering. Thanks to David VIOLEAU.

CHANGES 1.7.1 => 1.8
====================  
  BUGS FIXED
  * Fixed issue of extra figure popup when demo figure is on

  NEW FEATURES
  * Add command lines control support for common interface.
  * Translate help pages in english
  * Translate demos
  
  TODO:
  * Change the firmware to get multiple channels and sent all back to host for
performance improvement
  * Translate blocks interfaces and error messages

CHANGES 1.7 => 1.7.1
====================
  BUGS FIXED
  * Fixed 2206 Problem with Servo_Write Block
  * Restore MPU6050 block

CHANGES 1.6.2 => 1.7
====================
  BUGS FIXED
  * Fixed Scilab 6 compatibility issues
  * Change the serial to Scilab from char to double to solved ascii issues.
  * Fixed port >9 not supported issue
  
  NEW FEATURES
  * Multiple boards support (Set to 2 currently as more board yields slow
response)
  * Linux/MacOS(?) Support (Thanks to Nikolay Strelkov link in http://forge.scilab.org/index.php/p/arduino/issues/1556/)

  
  TODO:
   * Change the firmware to get multiple channels and sent all back to host for
performance improvement
   * Translate help pages in english
   * Translate blocks interfaces and error messages
   * Translate demos

CHANGES 1.5 => 1.6.2
====================
 BUGS FIXED
 * toolbox_arduino_v4.ino file shipped in the module was bad.
   Replaced with the right file.
 * ARDUINO_pre_simulate() was expecting arduino_v3.ino instead of 
   arduino_v4.ino and yielded an error 'Il faut charger avec le logiciel
   arduino le sketch toolbox_arduino_v3.ino dans la carte Arduino'
   when actually dealing with the v.4
 * The DESCRIPTION file that was removed from v.1.4 is actually 
   needed to instal the module offline. Restored.
 * Demos: Examples for Scilab 6.0 are displayed with wrong ports 
   positions with Scilab 5.5. The versions for Arduino 1.1 are 
   restored in the binary for the Scilab 5.5.
  
TODO:
  * Extend the module to Linux users (through the serial toolbox based on TCL)
  * Translate help pages in english
  * Translate blocks interfaces and error messages
  * Translate demos
            
Files (7)
[1.81 MB]
Linux 64-bit binary for Scilab 6.1.x
Linux binary for Scilab Arduino 1.8 (Scilab 6.1)

[1.81 MB]
Linux 64-bit binary for Scilab 6.0.x
Linux binary for Scilab Arduino 1.8
[1.25 MB]
Source code archive

[1.20 MB]
Windows 64-bit binary for Scilab 2023.0.x

[1.80 MB]
Windows 64-bit binary for Scilab 6.1.x
Windows binary for Scilab Arduino 1.8 (Scilab 6.1)
[1.80 MB]
Windows 64-bit binary for Scilab 6.0.x
Windows binary for Scilab Arduino 1.8
[40.87 kB]
Miscellaneous file
Firmware for Arduino to match Scilab Arduino Module 1.8
News (0)
Comments (20)     Leave a comment 
Comment from Olmer Garcia-Bedoya -- March 3, 2020, 08:04:12 PM    
Spanish Tutorial 
https://youtu.be/CJgPg6oiC1Q
Comment from Christoph Weber -- March 25, 2020, 03:11:03 PM    
Dear all,

I sucessfully installed the arduino toolbox and I also flashed
"toolbox_arduinio_v5.ino" on the UNO but download of my "blinking
example" in xcos failes.
Connection with com3 serial bus is working, but no function. 
Scilab gives me the information:
"You have to load the toolbox_arduino_v5-x.ino sketch with the arduino software in
the
Arduino board"
Scilab Console says:
""communication with card 1 on com 3 is ok"
Serial port closed SUCCESSFULLY.

  "Error occurred in pre_xcos_simulate: Cancelling simulation."
 at line 80 of function pre_xcos_simulate"
Any ideas?
Why do I have to deliver "toolbox_arduino_v5-x.ino". And where can I find this
file?

Kind regards
Christoph
Answer from Chin Luh Tan -- March 26, 2020, 01:21:37 AM    
This answer has been deleted.
Answer from Chin Luh Tan -- March 26, 2020, 01:42:40 AM    
Hi, 

We have notice some issue running the board for 1st time after uploading the 
"toolbox_arduinio_v5.ino". Could you try the command line functions below?

Execute following line by line.

--> h = open_serial(1,3,115200);
--> cmd_digital_out(h,13,0);
--> cmd_digital_out(h,13,1);
--> close_serial(h);

This should turn off the on board LED, and then turn it on again. 

It this fail, repeat the second time after closing the serial. 

Let us know the outcome.

Thanks.

Chin Luh
ByteCode
Comment from Christoph Weber -- March 26, 2020, 07:30:58 AM    
Hi Chin,

thank you for your reply.

these lines work properly. LED switches on and off.

Xcos-model runs now on my UNO!
Also Data is stored in the Workspace/Variable-Space in Scilab. Great!

Kind regards

Christoph

Kind regards
Chris
Answer from Chin Luh Tan -- March 26, 2020, 07:54:19 AM    
great to hear that. 

rgds,
CL
Answer from Chin Luh Tan -- March 26, 2020, 12:36:35 PM    
great to hear that. 

rgds,
CL
Comment from David SCHUMACHER -- March 30, 2020, 09:29:41 PM    
Hi all,

  I just installed Scilab 6.1.0, Arduino IDE 1.8.11 and Arduino toolbox 1.8 in order to use
my Arduino Leonardo. I don't manage to run a very simple XCos simulation (to blink a LED).

  First, I tried to upload toolbox_arduino_V5.ino, but compilation failed with many
warnings and notes around MPU6050 library.

  Nevertheless, I try to execute Xcos simulation. Few seconds after starting, the scilab
message "You have to load the toolbox_arduino_v5-x.ino sketch with the arduino
software in the Arduino board" is displayed." ... It's logic because first step
is failed.

  Could you please tell me if Arduino Leonardo is compatible ? What are MPU6050 library
pre-requisites ? Am I missed a step to configure Scilab / Arduino ? 

Thank you very much for your help.

Best regards,

David
Answer from Chin Luh Tan -- March 31, 2020, 03:20:15 AM    
One of the user did a nice video on this, it is in Spanish, but should be no problem to 
get the info you need. please refer to his video. 

/////////
Comment from Olmer Garcia-bedoya -- March 3, 2020, 08:04:12 PM    
Spanish Tutorial 

https://youtu.be/CJgPg6oiC1Q

/////////

Rgds,
CL
Comment from David SCHUMACHER -- March 31, 2020, 01:50:04 PM    
This comment has been deleted.
Comment from David SCHUMACHER -- March 31, 2020, 02:34:29 PM    
Thank you Chin for this link. I missed it during my first read of the forum. 
Comment from Tomonori Mashimo -- May 7, 2020, 07:03:11 PM    
Hello,

I am using Arduino module under the following environment.
Windows 10 pro japanese
Scilab 6.1.0 atoms arduino 1.8
arduino ide 1.8.12

I'm trying ANALOG_WRITE_SB.
From 0 to 128 works fine.
However, if you enter 129 or more, 0 is output.

Here are the results I checked.
Scilab5.5.2 + atoms arduino 1.6.2 works fine.

Probably ascii () behaves differently in Scilab 5.x and Scilab 6.x.

http://bugzilla.scilab.org/show_bug.cgi?id=16142
In the above URL, ARDUINO_ANALOG_READ_sim.sci is modified to change temp = ascii (values);

to temp = values ​​;.

Maybe a similar fix is ​​needed for ARDUINO_ANALOG_WRITE_sim.sci.
line 16
            code_sent = "W" + ascii (48 + block.rpar (1)) + ascii
(255);
line 19
            code_sent = "W" + ascii (48 + block.rpar (1)) + ascii
(abs (ceil (u1)));

Maybe this is a problem under Japanese Windows environment. I have no other environment so

I couldn't confirm.

Could someone please confirm?

Kind regards
Tomonori Mashimo
Answer from Chin Luh Tan -- July 27, 2020, 03:52:30 AM    
Dear Mashimo San,

Sorry to have overlooked your message posted here. 

you're right that the ascii giving quite some issue for Arduino module, that's the reason 
the codes have been modified to workaround on this issue. 

For the read and write case, it is quite different the READ command getting the data from 
Arduino into Scilab and the ascii gives some issue when converting back to the number we 
need. As for the WRITE operation, converting a number to symbol and transmit to arduino 
should not be an issue. 

If you still working on this or going to work on this in the future, it will be great if 
you could show the model you're using, how you inspect the values (loop back scope or 
monitor with external device) , and also what's the value for 130 .... 255. (some samples)

Thanks again.

Regards,
Chin Luh
Comment from Ivan Petrov -- July 26, 2020, 05:23:54 PM    
Hello,
I'm trying to connect Arduino UNO to Scilab Xcos. My configuration:
- Ubuntu 16.04
- Scilab 6.1.0
I downloaded and installed "Linux 64-bit binary for Scilab 6.1.x".
I am able to open the serial port using "openserial("/dev/ttyUSB0",
"115200, n, 8, 1")" but 
I am not able to open the serial port via the Scilab Xcos Arduino block. It only lets me to

input the number of port (say 3 or 5) which I think is for COM (under Windows). I want to 
be able to select/enter "/dev/ttyUSB0" into the Scilab Xcos Arduino block.
How to fix the problem?

Regards,
Ivan
Answer from Chin Luh Tan -- July 27, 2020, 03:13:13 AM    
Hi,

For a quick workaround, I would suggest you recompile the module for your machine by :

1. downloading the source code and put them into the SCI/contrib.
2. modify the source sci_gateway\c\main_linux.c, goto line 130 and change the 
//dev/ttyACM0 to //dev/ttyUSB0, so did others if you wish. 
3. save and close the file, and go the the Scilab console and execute the builder under 
Arduino folder.
4. once it is completed, run the generated loader.sce file and you're set to go. 


Hope this helps.

Regards,
Chin Luh
Answer from Chin Luh Tan -- July 27, 2020, 03:20:07 AM    
This answer has been deleted.
Comment from syukri muhammad -- August 10, 2020, 06:08:14 AM    
hi guys..
i need your help please..

I want to configure hc sr04 + arduino uno with xcos scilab so that it can display the 
distance graph curve in xcos.
which xcos blocks should i choose.

big thanks for all of you guys.
Comment from Sadeq H. Lafta -- October 6, 2020, 12:40:48 PM    
Dear friends in ATOMS,

I sucessfully installed the arduino toolbox and I also flashed
"toolbox_arduinio_v5.ino" on the UNO but no execution to my xcos.

Arduino board Connection is good in com3 serial bus andworking. but 
Scilab Console says:

  "Error occurred in pre_xcos_simulate: Cancelling simulation."
 at line 80 of function pre_xcos_simulate"

Any help?
Comment from Ramon Sanchez -- October 15, 2020, 07:28:08 PM    
hello everybody

I tried to install the Arduino toolbox on Scilab 6.1.0 & Win 7(32 bits...) and: 

at line    52 of function atomsError       ( C:\Program Files\scilab-
6.1.0\modules\atoms\macros\atoms_internals\atomsError.sci line 66 )
at line    78 of function atomsInstallList ( C:\Program Files\scilab-
6.1.0\modules\atoms\macros\atoms_internals\atomsInstallList.sci line 117 )
at line   233 of function atomsInstall     ( C:\Program Files\scilab-
6.1.0\modules\atoms\macros\atomsInstall.sci line 249 )

Any chance to work on 32bits?
or it is something else?

Thanks a lot
Regards
 
Comment from Alexander Kraus -- November 25, 2020, 11:43:21 AM    
Hello guys,

I tried to install the toolbox on Scilab 6.1.0 but the download is running without any 
effects. Do you know how to fix the issue.

It worked on version 5.5.2 but there I can only use one Arduino but I need more of them.

Ah, one more question: Is there any way to adjust the inputs for analog write except tk-
scale while the simulation is running (maybe with Scilab and the GUI-Builder)?


Thanks advance and best regards
Comment from Irfan Majid -- November 19, 2021, 05:14:22 PM    
Hello All,
After installing all the requisite toolboxes for Communicating with Arduino Uno Board and 
following the tutorials, when I try to use the Pulse_SC block to write to Digital Pin 13 I

get following messages (I am using Version 5.5.2 on Windows 10)
communication with card 1 on com 4 is ok   
 
 Version arduino_v4-x.ino utilisée   
 
 Fin pre_simulate arduino   
 
 Acquisition en cours...   
 !--error 999 
msprintf: Wrong number of input arguments: data doesn't fit with format.
 
 
 do_eval: Error while calling block ARDUINO_DIGITAL_WRITE [uid='-4ae23247: 
      17d38bc6dcd:-7f96']: invalid parameter (ier=999.000000, %scicos_prob 
      =%F).    
Any suggestions to remove this error please                                  
Answer from Anderson Hirata -- December 9, 2021, 03:36:55 PM    
> Hello All,
> After installing all the requisite toolboxes for Communicating with Arduino Uno Board
> and 
> following the tutorials, when I try to use the Pulse_SC block to write to Digital Pin
13
> I 
> get following messages (I am using Version 5.5.2 on Windows 10)
> communication with card 1 on com 4 is ok   
>  
>  Version arduino_v4-x.ino utilisée   
>  
>  Fin pre_simulate arduino   
>  
>  Acquisition en cours...   
>  !--error 999 
> msprintf: Wrong number of input arguments: data doesn't fit with format.
>  
>  
>  do_eval: Error while calling block ARDUINO_DIGITAL_WRITE [uid='-4ae23247: 
>       17d38bc6dcd:-7f96']: invalid parameter (ier=999.000000, %scicos_prob 
>       =%F).    
> Any suggestions to remove this error please

I have the same problem here. I'm using Scilab 6.1.1 (I also tried 6.0.2), and I installed

the Arduino 1.8 version of this toolbox. I downloaded the .ino file in my Arduino Uno, and

it was working fine yesterday when I tested a simple program to read an analog input with 
a potentiometer, and also a PWM. After all these small tests, I was building a control 
system simulation with encoder block, dc motor block, but I got a similar error:

msprintf: Quantidade incorreta de argumentos de entrada: o dado não é adequado para o 
formato.

  "do_eval: Error while calling block ARDUINO_SETUP
[uid='-b00e5cd:17d9f94faa4:-7ff4']: 
invalid parameter (ier=999.000000, %scicos_prob=%F)."

The part after msprintf is in portuguese, it says "Wrong number of input arguments:
data 
doesn't fit with format".

It was working fine, but now I get this error. I tried to install the Scilab 6.0.2 
version, reinstall Scilab, download the .ino to Arduino again, change the USB port, 
restart my computer, but I get the same error. I appreciate if someone can give me a help.

Thanks
                                   
Answer from Anderson Hirata -- December 9, 2021, 03:56:16 PM    
> > Hello All,
> > After installing all the requisite toolboxes for Communicating with Arduino Uno
> Board
> > and 
> > following the tutorials, when I try to use the Pulse_SC block to write to
Digital
> Pin 13
> > I 
> > get following messages (I am using Version 5.5.2 on Windows 10)
> > communication with card 1 on com 4 is ok   
> >  
> >  Version arduino_v4-x.ino utilisée   
> >  
> >  Fin pre_simulate arduino   
> >  
> >  Acquisition en cours...   
> >  !--error 999 
> > msprintf: Wrong number of input arguments: data doesn't fit with format.
> >  
> >  
> >  do_eval: Error while calling block ARDUINO_DIGITAL_WRITE [uid='-4ae23247: 
> >       17d38bc6dcd:-7f96']: invalid parameter (ier=999.000000, %scicos_prob 
> >       =%F).    
> > Any suggestions to remove this error please
> 
> I have the same problem here. I'm using Scilab 6.1.1 (I also tried 6.0.2), and I
> installed 
> the Arduino 1.8 version of this toolbox. I downloaded the .ino file in my Arduino
Uno,
> and 
> it was working fine yesterday when I tested a simple program to read an analog input
> with 
> a potentiometer, and also a PWM. After all these small tests, I was building a control

> system simulation with encoder block, dc motor block, but I got a similar error:
> 
> msprintf: Quantidade incorreta de argumentos de entrada: o dado não é adequado para
o
> 
> formato.
> 
>   "do_eval: Error while calling block ARDUINO_SETUP
> [uid='-b00e5cd:17d9f94faa4:-7ff4']: 
> invalid parameter (ier=999.000000, %scicos_prob=%F)."
> 
> The part after msprintf is in portuguese, it says "Wrong number of input
arguments:
> data 
> doesn't fit with format".
> 
> It was working fine, but now I get this error. I tried to install the Scilab 6.0.2 
> version, reinstall Scilab, download the .ino to Arduino again, change the USB port, 
> restart my computer, but I get the same error. I appreciate if someone can give me a
> help.
> 
> Thanks
>

I found the problem: Since I knew that the "ARDUINO_SETUP" block is loaded with
the 
default values of Arduino card number 1, and serial COM Port 5, I started the project 
without open those blocks. To solve this error, you need to open the block (even if you 
are not going to change anything) and click "OK", the parameters of the block
will appear 
in the diagram. I made a simple program using a "PULSE_SC" and the
"DIGITAL_WRITE" block 
to make a blink in the 13 pin LED, and it is working now.

I hope this helps somebody.

Thanks

                                    
Comment from Giuseppe Trainiti -- November 24, 2021, 05:40:54 PM    
Hi guys, 
i just installed the arduino toolbok using atoms, but it doesn't seem to work. When i start
Scilab, i get the message: 

Start Arduino 1.8
	Load macros
	Load help
	Load gateways
L'archivio condiviso è stato caricato.
Il collegamento è stato effettuato.
	Load palette
atomsLoad: Si è verificato un errore durante il caricamento di 'arduino-1.8':
	exec: error on line #92: "xcosPalLoad: 'void
org.scilab.modules.types.GetScilabVariableJNI.getScilabVariable(java.lang.String, int,
int)'"


some lines are in italian, 

L'archivio condiviso è stato caricato.  --> the shared archive has been loaded
Il collegamento è stato effettuato.     --> The connection has been established

Si è verificato un errore durante il caricamento di 'arduino-1.8': --> an error
occoured      d                                                                     
loading arduino-1.8

can anyone help? Thanks!

OS: linux mint
Answer from Maksim Salau -- February 9, 2022, 11:28:31 AM    
Hi Giuseppe,

> 	exec: error on line #92: "xcosPalLoad: 'void
> org.scilab.modules.types.GetScilabVariableJNI.getScilabVariable(java.lang.String,
int,
> int)'"

I have the same issue on Ubuntu with the package from the repository.
My solution was to download and use a pre-built package from 
https://www.scilab.org/download/

Please keep in mind that serial ports are expected to be /dev/ttyACM[0-7].
See https://atoms.scilab.org/toolboxes/arduino#comment3307 for details.

Regards,
Maksim
Comment from Harold van den Oever -- April 12, 2022, 03:40:10 PM    
Dear all,

I am using an Arduino Uno board with the following software:
-Windows 10 
-Scilab 6.1.1 (64bit) and Atoms Arduino 1.8
-Arduino ide 1.8.19
-toolbox_arduino_v5.ino

Just like in the comment above by Tomonori Mashimo, I also have the same issue:
-I'm using in XCOS a CONST_F block connected to the ANALOG_WRITE_SB.
-From 0 to 127 everything works fine
-These values give 0 volt on the pin: 128,130-140,142,145-156,158,159
-The other values from 128 to 255 work fine (ie 129,141,143,144,157,160-255).

The board itself is tested and ok.

Was anyone able to solve this issue?

Kind regards,
Harold van den Oever
Comment from S G -- March 24, 2023, 09:10:22 AM    
Hello,
The arduino module was recompiled yesterday for Scilab 2023.0 on Windows and is now 
available in ATOMS for this version.
For the time being, i have no Linux environment. Any other maintainer is welcome to 
recompile the module for Linux and upload it.
Regards
Samuel
Comment from Juan Alca -- October 23, 2023, 10:39:42 PM    
Hello, the error persists in Scilab 6.1 on Ubuntu Linux 22.04. 

Start Arduino 1.8
	Load macros
	Load help
	Load gateways
Shared archive loaded.
Link done.
	Load palette
atomsLoad: An error occurred while loading 'arduino-1.8':
	exec: error on line #92: "xcosPalLoad: 'void
org.scilab.modules.types.GetScilabVariableJNI.getScilabVariable(java.lang.String, int,
int)'"
at line   346 of function        atomsLoad (
/usr/share/scilab/modules/atoms/macros/atomsLoad.sci line 362 )
at line     1 of executed string 

When trying the 2023.1.0 version from Scilab the programm crashes before starting
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.