Menu

coupling with SciLab-xcos/ScicosLab-scicos for virtual hardware in the loop simulations

2019-02-22
2019-03-20
  • Foad S. Farimani

    SciLab/ScicosLab have a nice GUI bulding capability as well as SIMULINK like visual programing environment xcos/scicos. plus there is an Arduino plugin. I was wondering if SimulIDe could provide a virtual interface to have a complete PC in the loop (hardware in the loop) simulation?

     
  • Santiago

    Santiago - 2019-02-22

    What exactly do you want to do?

     
    👍
    1
    • Foad S. Farimani

      Consider this for example.

       

      Last edit: Foad S. Farimani 2019-02-25
  • Santiago

    Santiago - 2019-02-26

    Do you mean conecting Arduino by serial port?
    if so, please have a look here (Serial comunications);
    http://simulide.blogspot.com/p/blog-page_4.html

    In this video interfacing Arduino with Processing:
    https://youtu.be/JgdfjDlYJL0

     
    👍
    1
    • Foad S. Farimani

      Awsome. I will look into this. Thanks
      btw the second video is broken.

       
    • Foad S. Farimani

      some points:
      1. It would be great if you could open the comments section of the weblog.
      2. It would be great if you could link to the original example you have mentioned in this page.
      3. the toolbar icons are unintuitive/unconventional IMHO. A conventional menu bar would also be great.
      4. Windows binary for the latest version would be great. or built instructions.
      5. is the example analog_serial.simu just for Linux?

       

      Last edit: Foad S. Farimani 2019-02-26
    • Foad S. Farimani

      As I mentioned earlier I'm having difficulties running the examples:

      and when I try to open ttyS0 for example get the below error:

      error no such a file or directory

       

      Last edit: Foad S. Farimani 2019-02-28
  • Santiago

    Santiago - 2019-02-28

    The analog serial example is for Linux or Windows, the diference is how you create virtual serial port pairs in each system.

    The idea in this example is create a pair of virtual serial ports that will act like the cable you use to conect an Arduino to your PC: You connect Arduino (in simulide) to one end of this"cable" and anything you want to other end.

    In Windows you can create virtual serial port pairs using com0com: https://sourceforge.net/projects/com0com/
    But there are other options.

     
    👍
    1
    • Foad S. Farimani

      Would you be kind enough to elaborate on the setup of the Null-modem emulator (com0com)? I understand that when I install the software it immulates a pair of com ports (for example Com1 and Com2). Then what should I do? should I put one in the SimulIDE and the other on the SciLab-xcos?

       
      • Foad S. Farimani

        figured it out myself. I had two issues, first I could not see the new ports in the ports section in the device manager:

        but it was in the com0com - serial port emiulators above:

        and the drivers were not installed by default so right click update drivers solved this problem. Second issue was that when using the com0com GUI to Add pair it did not assign them to COM* ports! as a result that no such a file or directory error happens.

        So I opened the cli version Setup Command Promt/setupc.exe and then running the command install PortName=COM6 PortName=COM7 for example would do the job. Then in SimulIDE you can select one of these and then open. and on the other side the other pair. For example Arduino IDE from the menuTools > port select and then Tools > Serial Monitor to read the port.

         
        • Santiago

          Santiago - 2019-02-28

          Nice to know you got it working.

          And thanks for the explanations, it will be very useful for other people.

          Regards.

           
          👍
          1
          • Foad S. Farimani

            As a follow up, now I can read the serial port in SciLab and pars the CSV data:

            Here you may find more information. This code for Arduino:

            long randNumber;
            
            void setup() {
              Serial.begin(9600);
              randomSeed(analogRead(0));
            }
            
            void loop() {
              randNumber = random(1000);
              Serial.print(randNumber);
            
              Serial.print(", ");
            
              randNumber = random(1000);
              Serial.println(randNumber);
            
              randNumber = random(1000);
              delay(randNumber);
            }
            
             
          • Foad S. Farimani

            Again as a Follow up on this matter, I decided to rewrite the Scilab / ScicosLab serial port communication toolbox from scratch to have similar functionalities as MATLAB. It took me a couple of weeks and almost a thousands lines of spaghetti code but now I have an early prototype. Here you can see live plotting of potentiometer readings.

             
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.