Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | File Exchange
ATOMS : Arduino details
Please login or create an account

Arduino

Arduino Communication through Serial
(7128 downloads for this version - 90291 downloads for all versions)
Details
Version
1.3
A more recent valid version with binaries for Scilab 6.0 exists: 1.5
Author
Bruno JOFRET
Owner Organization
Scilab Enterprises
Maintainers
Yann Debray
Bruno Jofret
Administrator Atoms
Samuel Gougeon
License
Creation Date
August 31, 2016
Source created on
Scilab 6.0.x
Binaries available on
This toolbox is in the process of being built
Description
            This toolbox provides Arduino communication blocks for Xcos.

You need to flash the arduino board with the following file:
toolbox_arduino_v3.ino  

Communication is performed through Serial port.

Only works under Windows platform.            
Files (1)
[1.45 MB]
Source code archive

News (0)
Comments (13)     Leave a comment 
Comment from Luis Ramos -- October 1, 2016, 02:36:38 PM    
Is there any new Windows x64 version?
Scilab 6, complain about an older dll and ask to recompile :(
Comment from Joel Soranzo -- January 25, 2017, 02:38:54 PM    
J'ai essayé Scilab 6.0.0 Beta 2 mais ce module n'apparaît pas dans ma list de module 
atoms. J'ai essayé en vain une installation  manuel à patir de "arduino-1.3.tar.gz	
Source code archive" mais sans résultat.
Qqun peut-il m'aider ?
Comment from Waleed El-badry -- February 19, 2017, 04:25:35 PM    
Thanks for building such a useful library for free.

I'm switching my students from MATLAB to SciLab thanks the endless contribution from 
community. I only confront minor problem with Arduino toolbox.

I run SciLab 6 which require Arduino library to be recompiled for that version. I hold 
no knowledge to achieve that and hence would appreciate any assistance regarding this 
issue if could be resolved.
Answer from Waleed El-badry -- February 19, 2017, 04:26:41 PM    
> Thanks for building such a useful library for free.
> 
> I'm switching my students from MATLAB to SciLab thanks the endless contribution from 
> community. I only confront minor problem with Arduino toolbox.
> 
> I run SciLab 6 which require Arduino library to be recompiled for that version. I hold

> no knowledge to achieve that and hence would appreciate any assistance regarding this

> issue if could be resolved.

Note: I use version 1.1 as we all have x86 Windows installed.
Comment from Kleiber Sousa -- February 24, 2017, 04:00:24 AM    
Please,

  I'd like to know how to install the Arduino Toolbox in SciLab 6.0.0 (Windows 32 bits). 
This Toolbox is not listed on SciLab 6.0.0 Module Manager.
Comment from Eduardo Salazar Hidalgo -- March 14, 2017, 02:32:07 PM    
Excellent toolbox. It has been so helpful to me.
Comment from Samuel Gougeon -- March 20, 2017, 09:06:33 AM    
Hello Yann,
The description says "Only works under Windows platform." while MSWindows is the
only 
plateform not supporting the toolbox for the time being..
Regards
Comment from Jean-paul Pique -- March 26, 2017, 10:01:19 PM    
Peut-on me guider pour installer le module "Arduino" dans Scilab 6.0.0, il n'est
pas dans
la liste des modules sous Atoms ?
Merci d'avance.
Comment from Güner Güvenç -- July 19, 2017, 08:53:31 PM    

--> exec('D:\PROJE KLASÖRÜM\SCILAB\arduino_1.1\loader.sce', -1)
Start Arduino
	Load macros
at line    33 of function startModule ( D:\PROJE 
KLASÖRÜM\SCILAB\arduino_1.1\etc\arduino.start line 37 )
at line   113 of executed file D:\PROJE KLASÖRÜM\SCILAB\arduino_1.1\etc\arduino.start
at line    10 of executed file D:\PROJE KLASÖRÜM\SCILAB\arduino_1.1\loader.sce

lib: Old binary lib detected. Please recompile it for Scilab 6.
Comment from Yerko Reyes -- April 15, 2018, 02:38:27 AM    

hello, I solved the problem for scilab 6.01.

You have to edit the builder.sce script as follows:

===============================================================================

// Copyright (C) 2008 - INRIA
// Copyright (C) 2009-2011 - DIGITEO

// This file is released under the 3-clause BSD license. See COPYING-BSD.

mode(-1);
lines(0);

function main_builder()

  TOOLBOX_NAME  = "arduino";
  TOOLBOX_TITLE = "Arduino toolbox";
  toolbox_dir   = get_absolute_file_path("builder.sce");

// Check Scilab's version
// =============================================================================

  // check minimal version (xcosPal required)
  if ~isdef('xcosPal') then
    // and xcos features required
    error(gettext('Scilab 5.3.2 or more is required.'));
  end

// Check modules_manager module availability
// =============================================================================

  if ~isdef('tbx_build_loader') then
    error(msprintf(gettext('%s module not installed.'), 'modules_manager'));
  end


  if ~isdir(toolbox_dir+filesep()+"images"+filesep()+"h5")
      [status, msg] =
mkdir(toolbox_dir+filesep()+"images"+filesep()+"h5");
      if and(status <> [1 2])
          error(msg);
      end
  end

// Action
// =============================================================================

  tbx_builder_macros(toolbox_dir);
  //tbx_builder_src(toolbox_dir);
  //tbx_builder_gateway(toolbox_dir);
  tbx_builder_help(toolbox_dir);
  tbx_build_loader(toolbox_dir);
  tbx_build_cleaner(toolbox_dir);
endfunction

if with_module('xcos') then
  main_builder();
  clear main_builder; // remove main_builder on stack
end

==================================================================================

then, compile the file again by running the script. a script called loaded.sce will be 
created.

Before executing it, you must edit in the arduino.start file in the folder etc /


the file arduino.start should be like this

====================================================================================
// Copyright (C) 2012 - Scilab Enterprises

// This file is released under the 3-clause BSD license. See COPYING-BSD.

function arduinolib = startModule()

  mprintf("Start Arduino\n");

  if isdef("arduinolib") then
    warning("Arduino toolbox library is already loaded");
    return;
  end
  
//  if win64() then
//    warning("Arduino toolbox library is only available for scilab 32 bits");
//    return;
//  end  

// check minimal version (xcosPal required)
// =============================================================================
  if ~isdef('xcosPal') then
    // and xcos features required
    error(gettext('Scilab 5.3.2 or more is required.'));
  end
// =============================================================================
// force to load some libraries (dependancies)
  loadScicos();
// =============================================================================
  etc_tlbx  = get_absolute_file_path("arduino.start");
  etc_tlbx  = getshortpathname(etc_tlbx);
  root_tlbx = strncpy( etc_tlbx, length(etc_tlbx)-length("\etc\") );

// Load functions library
// =============================================================================
  mprintf("\tLoad macros\n");
  pathmacros = pathconvert( root_tlbx ) + "macros" + filesep();
  arduinolib = lib(pathmacros);

// Load serial dll and link
// =============================================================================
  mprintf("\tLoad serial dll\n");
  pathdll = pathconvert( root_tlbx ) + "src" + filesep();
  chdir(pathdll)
  exec('loader.sce');
  chdir('..')

// Add blocks to the Xcos palette
// =============================================================================
  mprintf("\tLoad palette\n");
  pal = xcosPal("Arduino");

  sous_pal=["Configuration" "Digital" "Analog"
"Motors"]

  sous_blocks=cell(size(sous_pal));

  sous_blocks{1}=["ARDUINO_SETUP" "TIME_SAMPLE"
"ARDUINO_SCOPE"]
  sous_blocks{2}=["DIGITAL_READ_SB" "DIGITAL_WRITE_SB"
"ENCODER_SB" "INTERRUPT_SB"]
  sous_blocks{3}=["ANALOG_READ_SB" "ANALOG_WRITE_SB" ]
  sous_blocks{4}=["DCMOTOR_SB" "SERVO_WRITE_SB" ]

//  blocks = ["ARDUINO_SETUP" "TIME_SAMPLE"
"ARDUINO_ANALOG_READ" "ARDUINO_ANALOG_WRITE" 
"ARDUINO_DCMOTOR" ...
//            "ARDUINO_DIGITAL_READ" "ARDUINO_DIGITAL_WRITE"
"ARDUINO_ENCODER" ...
//            "ARDUINO_SERVO_READ" "ARDUINO_SERVO_WRITE"  ...
//            "ARDUINO_STEPPER" "ARDUINO_WRITE" ];

  for p=1:size(sous_pal,2)
     local_pal = xcosPal(sous_pal(p));
     blocks=sous_blocks{p};
     for i=1:size(blocks, "*")
        h5  = ls(root_tlbx + "/images/h5/"  + blocks(i) + "." +
["sod" "h5"]);
        gif = ls(root_tlbx + "/images/gif/" + blocks(i) + "." +
["png" "jpg" "gif"]);
        svg = ls(root_tlbx + "/images/svg/" + blocks(i) + "." +
["png" "jpg" "gif" 
"svg"]);

        local_pal = xcosPalAddBlock(local_pal, h5(1), gif(1), svg(1));
    end

      if ~xcosPalAdd(local_pal,'Arduino') then
        error(msprintf(gettext("%s: Unable to export %s.\n"),
"arduino.start", "pal"));
      end

  end

// Load and add help chapter
// =============================================================================
  if or(getscilabmode() == ["NW";"STD"]) then
    mprintf("\tLoad help\n");
    path_addchapter = pathconvert(root_tlbx+"/jar");
    if ( isdir(path_addchapter) <> [] ) then
        add_help_chapter("Arduino", path_addchapter, %F);
    end
  end

// Load demos
// =============================================================================
  if or(getscilabmode() == ["NW";"STD"]) then
    mprintf("\tLoad demos\n");
    pathdemos = pathconvert(root_tlbx+"/demos/arduino.dem.gateway.sce", %F, %T);
    add_demo("Arduino", pathdemos);
  end

// Display version
fd=mopen(root_tlbx+filesep()+"VERSION");
version=mgetl(fd,-1);
mclose(fd);
mprintf("\tArduino Version: "+version);


endfunction

if with_module('xcos') then
  arduinolib = startModule();
  clear startModule; // remove startModule on stack
end

==================================================================================

Now run the file loaded.sce and I will install the module

The problem was caused by changes in some commands in the last version.

I hope you serve the solution. Greetings from vallenar, Chile.

Comment from Serge Leaute -- May 3, 2018, 05:54:57 PM    
Bonjour,

je cherche à utiliser la toolbox arduino mais je n'y parvient pas.
J'ai la version 6.01.

Pourquoi cette Toolbox n'est pas disponible dans la gestion graphique des modules?

Si je telecharge arduino-1.3 et que je lance builder j'ai le message suivant :

-->// Copyright (C) 2008 - INRIA
-->// Copyright (C) 2009-2011 - DIGITEO
-->// This file is released under the 3-clause BSD license. See COPYING-BSD.
-->mode(-1);
 !--error 999 
get_absolute_file_path : Le fichier builder.sce n'est pas ouvert dans Scilab.
at line       5 of function main_builder called by :  
  main_builder();
at line      52 of exec file called by :    
INTO_SCILAB-782579156505322751.sce', 1
while executing a callback

j'ai essayer de modifier le fichier arduino.start dans le repertoire etc / avec le 
code proposé dans le message précédent. Les commentaires sont :


-->// Copyright (C) 2008 - INRIA
-->// Copyright (C) 2009-2011 - DIGITEO
-->// This file is released under the 3-clause BSD license. See COPYING-BSD.
-->mode(-1);
 !--error 999 
get_absolute_file_path : Le fichier builder.sce n'est pas ouvert dans Scilab.
at line       5 of function main_builder called by :  
  main_builder();
at line      52 of exec file called by :    
NTO_SCILAB-4380300239315846287.sce', 1
while executing a callback


Merci pour votre aide

Cordialement
Comment from Suzuki Hirotaka -- June 16, 2018, 02:54:54 AM    
There is an error when I executing loader.sce. 

exec: error on line #93: "xcosPalAddBlock: Unable to load block from 
"C:\Users\Hirotaka\Desktop\SCILAB~1\arduino\images\h5\ARDUINO_SETUP.sod": hdf5
file expected."

Do you know how I can solve it?
Answer from Samuel Gougeon -- September 6, 2018, 05:08:07 PM    
> There is an error when I executing loader.sce. 
> 
> exec: error on line #93: "xcosPalAddBlock: Unable to load block from 
> "C:\Users\Hirotaka\Desktop\SCILAB~1\arduino\images\h5\ARDUINO_SETUP.sod":
hdf5
> file expected."

I do get it as well, on Windows7. I am surprised that Stéphane Guibert (next commenter)
does not get it (on Windows10)..
 
> Do you know how I can solve it?
Not yet.
Answer from Samuel Gougeon -- September 6, 2018, 06:18:18 PM    
I restarted Scilab, and now it works.

I think that there is a synchronization issue.
xcosPalAddBlock() creates the .sod file, and just after having closed it, it loads its
content (so accesses to the same file that was just closed).
I have tried to add a sleep(500) just before loading the .sod file, but it did not help.

But restarting Scilab cleared the loading error...

Answer from Samuel Gougeon -- September 6, 2018, 07:01:22 PM    
And now again after restarting: Out of work.
In xcosPalAddBlock(), the true error message while doing load(Block) is:

!Function not defined for given argument type(s),                   !
!  check arguments or define function %Block_load for overloading.  !

So, maybe %Block_load() is defined in as a too private function or in a sublibrary not
loaded by default..
Answer from Samuel Gougeon -- September 6, 2018, 07:07:31 PM    
>So, maybe %Block_load() is defined in as a too private function or in a sublibrary
>not loaded by default..

That's the point: It is defined in the scicos_scicoslib that is not loaded by default.
I will fix it now in the Arduino start file, and in xcosPalAddBlock() later.
Comment from Stéphane Guibert -- August 19, 2018, 03:42:09 AM    
This comment has been deleted.
Comment from Stéphane Guibert -- August 19, 2018, 03:50:46 AM    
hello
These steps are ok for me: (Windows 10 and Scilab 6.0.1)

1. Download the file 'arduino-1.3.tar.gz', which is the archive of the module for Scilab.

2. Unzip the file (with 7-Zip for example: https://www.7-zip.org/).
This is a compressed (gzip) archive (tar). Sometimes, it need two steps: unzip (gzip),
then extract the archive (tar). We then obtain a file named 'arduino-1.3'.

3. Edit the file '..\arduino1.3\arduino\builder.sce'.
Replace the two lines 46 and 47:
  // tbx_build_loader(TOOLBOX_NAME, toolbox_dir);
  // tbx_build_cleaner(TOOLBOX_NAME, toolbox_dir);
with:
  tbx_build_loader(toolbox_dir);
  tbx_build_cleaner(toolbox_dir);
Save the change.

4. In Scilab 6.0.1 (Desktop), execute the file 'builder.sce', for example in the console
(replace ... with the exact path):
--> cd "c:\...\arduino1.3\arduino\"
--> exec("builder.sce")
The operation creates two files in the folder: 'loader.sce' and 'unloader.sce'.

5. Close Scilab. Edit the start menu shortcut (Properties), then change the target:
   "C:\Program Files\scilab-6.0.1\bin\WScilex.exe"
with (replace ... by the exact path of the file):
   "C:\Program Files\scilab-6.0.1\bin\WScilex.exe" -f
"c:\...\arduino1.3\arduino\loader.sce"

6. Restart Scilab. At startup, you must have in the console:
Start Arduino
   Load macros
   Load serial dll

7. Open Xcos. In the palette browser, you must have the arduino palette.

8. If not done yet, download the file 'toolbox_arduino_v3.ino' which contains the program
code for the Arduino board, on the Demoscience website:
http://www.demosciences.fr/projets/scilab-arduino

Note :
Point 5 loads the arduino module when Scilab starts. Do not change the tree!
Leave a comment
You must register and log in before leaving a comment.
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.