•Scilab 5.4.0 Beta 3 - 32 bits or higher
•20-sim 4C 2.1 or higher
Note: The installation path of 20-sim 4C (e.g. C:\Program Files\20-sim 4C 2.1) will be referred to as "the 20-sim 4C installation dir" below.
1.Install the Atoms-package that is shipped with 20-sim 4C: Start Scilab and run:
-> atomsInstall('<20-sim 4C installation dir>/contrib/scilab/20sim_4C_codegeneration-1.0.0.zip')
2. Restart Scilab.
Note: Sometimes, the installation script raises an error, in that case, Scilab needs to be restarted one more time.
In Scilab you can generate C-code from a sub-model:
1.Open a scilab model for code generation. A sample model found at '<20-sim 4C installation dir>\examples\scilab\demo.xcos' can be used for testing.
2.Select the desired sub-model from the scilab model.
3.Start the code generation from the menu bar > tools > 20-sim 4C code generation.
This will open a dialog on where to save the sub-model.

A project file saving dialog in Scilab
3.Select a directory and Click OK
This starts the code generation process and 20-sim 4C will be opened.
4.Select your target (Note: Scilab code generation currently works with RTAI targets only) and Run the code.
So far, the event-time triggering the square source is not exported from the Xcos model to 20-sim 4C. Therefore, add the proper event duration to the square block named gensqr.
In the 20-sim 4C variables section a variable 'solver type' can be found, which can be used to select the desired continuous time solver method by the following values:
•1 results in ode1
•2 results in ode2
•4 results in ode4
•The correct event time of external activated blocks within Xcos should be entered manually into 20-sim 4C.
•Block names from within Xcos are not transferred to 20-sim 4C.
•The first model calculation is executed at model initialization. This causes, for example, a square wave to start with the opposite sign.
•The superblock used for code generation cannot itself contain superblocks.
•Continuous time systems
oCLINDUMMY_f
oTCLSS
oTIME_DELAY. Note that the discrete time delay z-1 can be used.
oVARIABLE_DELAY
oPDE
•Discontinuities
oDELAYV_f. This block is not supported because it generates events.
oRATELIMITER.
oQUANT_f. The quantizer is not supported yet.
•Discrete time systems
oAUTOMAT. This block is not supported because it generates events.
oDELAYV_f. This block is not supported because it generates events.
oDELAY_f. Note that a delay can be realized by using the z-1 block.
oDLRADAPT_f. This block is not supported yet.
oSAMPHOLD_m. Note that in general a sample and hold is used for an analog signal input
oTCLSS
oREGISTER
•Lookup tables
oThis palette is not supported yet.
•Event handling
ono blocks are supported. Note that every clock-triggered block has its own clock within 20-sim 4C. (as long as the desired activation time is >= stepsize of the complete model.
•Mathematical Operations
oMATMAGPHI. This block is not supported yet.
oMATZREIM. This block is not supported yet.
oMAXMIN. This block is not supported yet.
oMAX_f. This block is not supported yet.
oMIN_f. This block is not supported yet.
oPOWBLK_f
•Matrix
oMatrices are not supported yet.
•Electrical
ono blocks are supported
•Integer
oNo blocks are supported
•Zero crossing detection
ono blocks are supported
•Signal Routing
oso far: no blocks are supported
•Signal Processing
oNot supported. Note that the functions within this palette are in particular useful for the interface between an analog and a digital system.
•Implicit
ono blocks are supported
•Annotations
oTEXT_f annotations are not taken into account for the code generation
•Sinks
ono blocks are supported
•Sources
oFROMWSB
oRAND_m
oREADAU_f
oREADC_f
oRFILE_f
oSigbuilder. This block is not supported because it generates events.
•Thermo-Hydraulics
ono blocks are supported
•Demonstrations Blocks
ono blocks are supported
•User-Defined Functions
ono blocks are supported