Code Generation

Code Generation allows you to generate C-code out of any 20-sim model. Using built in templates, C-code can be generated for various targets.

20-sim 4C

The package 20-sim 4C helps you to run C-code on hardware to control machines and systems. 20-sim 4C enables rapid prototyping for control engineers. With 20-sim 4C you can run c-code on hardware to control machines and systems. 20-sim 4C imports models (c-code) from 20-sim, Simulink and Scilab and runs them on hardware like embedded arm boards, PC 104 systems and much more.

20-sim 4C can be used by students and professionals. With only a few mouse-clicks you can load c-code and run it on hardware. From 20-sim 4C you can start and stop the code, inspect variables and log data. 20-sim 4C is versatile. With 20-sim 4C you can do measurements, run actuators and control machines. A wide range of hardware is supported allowing you to perform every task.

Matlab Simulink

Generating C-code for use in MATLAB Simulink also includes a submodel block with input and output terminals. 20-sim uses the MEX-compiler, to compile this code directly into an S-function. These S-functions can also be used in the Real-Time Workshop in order to generate code for a specific platform, for instance xPC Target.


20-sim can generate standalone C-code for use in C and C++ programs. The generated C-code is supplied with several fixed step simulation algorithms to assure that it will run in real-time. The Euler and RungeKutta methods are supported by default.


All C-code templates are open and can be adapted by the user to assign compilers, run ftp-sessions and automate almost everything between the 20-sim code generation and the actual running of the code on a (remote) machine. During C-code generation support code is generated for 20-sim operators like matrix calculations and trigonometric functions.