My blog

sgJavaSci - Java Based Scilab/Xcos Diagram Importer and C-Code Generator for GeneAuto

What is Scilab ?
Scilab is free and open source software for numerical computation providing a powerful computing environment for engineering and scientific applications.

What is Scilab/Xcos ?
Scilab includes a toolbox called Xcos which is based on Scicos.

What is Scicos ?
Scicos is a graphical dynamical system modeler and simulator. Users can create block diagrams to model and simulate the dynamics of hybrid dynamical systems (both continuous and discrete time) and compile these models into executable code. Applications include signal processing, systems control, queuing systems, and the of study physical and biological systems.

What is GeneAuto ?
Gene-Auto is an open-source toolset for real-time embedded systems. The toolset takes as input a functional description of an application specified in a high-level modelling language (Simulink/Stateflow/Scicos) and produces C (in close future also Ada) code as output.

What is sgJavaSci ?
sgJavaSci is a tool for binding Scilab and Java. The first module if the toolbox is C Code Generator by using above tools.

Currently it has the features as follow

Supported Xcos Blocks

  • SUPER_f defines a system
  • CONST_m defines a constant
  • DOLLAR_m defines a unit delay
  • IFTHEL_f calls a system block according to condition based on an input value (u>0)
  • SUMMATION adds or subtracts inputs
  • SWITCH2_m selects an inputs from two according to conditions based on an input value and a trishold value (u>a, u>=a, u~=a)
  • OUT_f defines an output variable
  • CLKINV_f defines an event or action input


Supported Data Types

  • Double


Supported Block Parameter Types

  • Real Expression
  • Integer Expression
  • Binary Expression
  • String Expression


Features

  • Block Names


Usage

Before using the tool you shoul have programs as follow

  • Eclipse Java Development Environment
  • Java RTE 1.7
  • Java JDK 1.7
  • Scilab


There is no published binaries or Java Byte Code of the tool. You can get it as Eclipse project as follow.

  • You can clone the tool from Git repository

git clone https://bitbucket.org/ierturk/sgjavasci.git

  • You can download as zip from

https://bitbucket.org/ierturk/sgjavasci


Then you can import the project into your Eclipse workspace. If you have Git plugin with Eclipse you can directly import project from above git repository.

Creating Scilab/Xcos diagram
We assume that you are familiar with Scilab/Xcos diagrams. Diagram should be created by using only supported blocks. Parameters should be in type of double and scalar. An example diagram are given below.

image

image

image

Code Generation Process
After creating diagram or already you have a diagram which comply with the condition above, you can run the tool within Eclipse. The window will be displayed as follow.

image

At this stage, the process is as simple as press button and select input diagram and output folder by means menu or toolbar buttons. The steps should be in sequences as in the image below.

image


In the end everything were go well. You will be found C Files in output folder “cfiles”, and GeneAuto XML file in output folder “XML”. Output folder is the one you were select at the step 2.

Other windows you will see as follow along with process

image

image

image

image

After all, c files in output folder, trees views of input diagram XML file and GeneAuto XML file in main window of the tool and a generated C file in Eclipse will be shown as follow

image


I hope that the tool is useful and look for your valued feedback.

References

All rights reserved. COPYRIGHT 2014 StarGate Inc.

Share this
Share this
Permalink

sgJavaSci Scilab/Xcos Tools

image

We have started up a new project sgJavaSci Scilab/Xcos tools to manage Scilab from Java environment. Initially, JavaSci example was imported from Scilab installation. Also a class was created to display Xcos diagram in XML format as SWT/JFace treeviewer.

Current development environment on Windows 7 / 64bit machine as follow

  • Eclipse Luna Release (4.4.0) x86_64
  • IBM 64-bit SDK for Windows AMD64/EM64T architecture,
    Java Technology Edition, Version 7
  • Scilab-5.5.0 64bit

Source code can be downloaded from BitBucket repository.

Share this
Share this
Permalink

Versions of Scilab-5.x.x and Regional Settings Under Windows

A beta version of Scilab-5.4.0 has been released. Thanks for Scilab Development team.

But, a bug with Scilab-5.x.x (Xcos) has not been resolved so far. For more info please follow links below.
- http://bugzilla.scilab.org/show_bug.cgi?id=8692
- http://www.equalis.com/forums/posts.asp?topic=211772

I tried to test my old diagram on Scilab-5.3.3 and beta version of Scilab-5.4.0, this issue is emerged again under windows. This issue is not emerge under Linux machines.

I discovered that difference between of machines is Local Settings of them. Scilab can not operate properly for some regional settings. I also encountered this case for a few of programs other than Scilab under windows. It is related decimal notation. When set to English system for regional settings, everything is OK.

If you encounter a problem like that, It need to be set English system (USA or UK) on your windows machine for decimal notation.

Share this
Share this
Permalink

Modelling, Simulation and Controlling of Permanent Magnet Synchronous Machine under Scilab/Xcos

In this study, The model which is previously developed under ScicosLab PMSM d-q model is ported to Scilab/Xcos. Two model is developed to simulation as PMSM Machine and PMSM Controller. While, PMSM model is developed as a C-Block, standart Xcos blocks is used to create PMSM Controler.

Also, previous Xcos models (BLDC Machine and BLDC controler) are available in this study.

In PMSM Machine Model, rotor flux is sinusoidal. Instead of hall sensor, an output is added to model as indicate rotor position. Model is based on Matlab SimPowerSystem Blockset. Detailed information about model can be found at link below.

In PMSM Controller Model, Speed control is done. It based on filed oriented control (FOC), and DC bus voltage is adjusted by PI controller to acheive required speed.

Required simulation files can be downloaded from links below. Also, It includes source files of models.

To run model, it is sufficient execute RunFirst.sce after extract archive in Scilab/Xcos enviroment. Script creates libraries and interfaces and open xcos model.

Model Developed under Below Configuration

  • Scilab 5.3.2 Stable
  • Windows Vista 32Bit
  • Microsoft Visual C++ 2010 Express
    image

Model Archive Detail

Share this
Share this
Permalink

Modeling and Simulation of Brushless DC Machine Under Java Environment

In case of sinusoidal flux distribution, it is easier to modeling brushless dc machine (BLDC). Modeling of BLDC can be more complex in trapezoidal flux case, because of unbalanced flux linkage per phase. In this case, six step control is required.

Implemented machine model is based on PMSM model in Matlab/Simulink SimPowerSystem. For more information about this model please refer to links below.

Model is developed under below configuration

  • NetBeans 7.0
  • jDisco1.1 (Keld Helsgaun)
  • Java Development Kit (jdk1.6.0_24)

Compiled and source of model can be downloaded links below.

I hope it is useful.

image

Share this
Share this
Permalink

A Tutorial on jDisco – Ideal Parallel LC Circuit

jDisco is a Java framework for combined discrete and continuous simulation. This tutorial demonstrates its capability.

In ideal LC circuit, capacitor and inductor is lossless energy storage element so that they can transfer energy without loss to each other or enywhere you want.

jDisco report, more of tutorial and full source code can be downloaded from links below.

image

Share this
Share this
Permalink

Induction Machine Per-Unit Model Simulation under Java-jDisco

While I search a continuous simulation environment under Java, I came across with jDisco, and I have tried with my inductoin machine pu model which I have already simulated under other environment such as Matlab/Simulink, Scilab, ScicosLab.

When I was run my first model with jDisco, I was quite suprised from results and speed of it. I strongly advise you try it. Thanks to Keld Helsgaun.

You can find compiled and source code of model at links below.

image

Share this
Share this
Permalink

JFemm - Java Femm Magnetic Processor Implementation

JFemm is not a stand alone application. It is link between Java and FEMM. At the moment, magnetic LUA processors are implemented.

It can be use simply as import JFemm Library to your Java application or else. Moreover, It is depended on Java Native Access Library.

Related library and Java Documents are available at below links. Demo application also use JMathTools - JMathPlot
for visualization results from Femm analyze.

I hope it is useful.

image
Share this
Share this
Permalink

A Java Femm Link - BLDC Motor Cogging Torque Calculator Using Femm

Application is developed for demonstrate connection between Java and Femm. Link is done with JNA (Java Native Access). You must have Femm installation for run Java Application.

Femm and Java Application can be downloaded from links below. Full set of commands will be implemented at future version as Java Class. Thanks to Femm and JNA developers.

I hope it is useful. Please do not hesitate contact us. Your valuable feedback will be useful to improving our application.

image
Share this
Share this
Permalink

A Simple Java Application - Induction Machine Per Phase Equivalent Circuit Parameter Calculator

Induction machine per phase equivalent circuit is useful for calculation of various machine variable at some operation points. Parameters of this circuits can be determined as to be carried out test on machine. This tests are:
- DC Resistance Measurement on machine terminals
- No Load Test
- Locked Rotor Test

Parameters can be obtained as use values from resuls of tests. For test methods and calculations of parameters, refers to text book of Electric Machines, Drives, and Power Systems, Third Edition by Thedore Wildi. Methods can be found on Section 15.9 Tests to determine the equivalent circuit on page 325. It can be downloaded from links below.

image

I hope it was useful. Do not hesistate to contact me, in case you encounter any peroblem with application.

Share this
Share this
Permalink