Search Sitemap Contact Order Home
   

Code Generation Toolbox

Generate C-code for embedded controllers.

20-sim, the dynamic modeling and simulation package for iconic diagram, bond graph, block diagram and equation models

Generate Matlab / Simulink S-functions.


Or generate code for Real Time Linux or your own target.

20-sim, the dynamic modeling and simulation package for iconic diagram, bond graph, block diagram and equation models

The Code Generation Toolbox provides you with C-code generation tools and templates for all kinds of different targets and platforms.

With 20-sim you are able to generate C-code as well as MATLAB code for every 20-sim model that you have created, whether it is a continuous or discrete-time model. The C-code can be created for several targets, like MATLAB Simulink, but also for Rapid Prototyping (RP) systems and Hardware-In-the-Loop (HIL) simulations.

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.

C-Code

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.

Templates

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.

Hardware-in-the-loop and rapid prototyping

You can use the generated C-code to do HIL simulations. 20-sim has a template that coordinates the C-code generation for the RTLinux software of CosateQ GmbH, which is based on RTAI. This make the template easily adaptable for other versions of RTLinux. The communication with the encoder cards and DA-convertors is performed by drivers from the open source Comedi library. The scope functionality in 20-sim allows you to display encoder and output data.

In general, generated C-code can be used for every other HIL or RP environment. Using the 20-sim code generation template, you can specify your code format, add your own libraries, define your compiler settings, and describe your own interface and I/O.


Example

20-sim, the dynamic modeling and simulation package for iconic diagram, bond graph, block diagram and equation models
Use 20-sim to generate C-code for Real-Time Linux

A demonstration set-up is constructed to indicate the hardware-in-the-loop (HIL) control possibilities of 20-sim for Rapid Prototyping (RP). Furthermore, several manufacturing and control principles for designing mechatronic systems are shown in this set-up.

The set-up

The set-up is a linear positioning device actuated by a DC motor on a frame. The frame is constructed with leaf springs, which give the frame extra flexibility. The belt that drives the load is very elastic. These design choices cause vibrations which result in position errors when the motor is actuated to move the load.

The system is build up with the following hardware; a 2GHz PC including a PCI encoder card, and DA converter, running SuSE Linux with a real time kernel based on RTAI and compiled by CosateQ GmbH. The communication with the hardware is performed by drivers from the open source Comedi library.

Practice

A dynamic model of the set-up including the controller is created in 20-sim. C-code is generated for the controller part of the model. The controller consists of a state machine which assigns different subcontrollers for different trajectories. The code is transferred to the Linux PC by means of a TCP/IP connection. CosateQ developed software to load the code in the real-time kernel and to communicate with the process. With this set-up sample frequencies up to 50 kHz can be reached.

Encoder and output data can be logged on the Linux PC, or sent to any computer by internet each time step. Scope functionality in 20-sim allows you to display this data. The response of the model and the actual machine can be compared to adjust the model and controller parameters.

Conclusion

With 20-sim you are able to generate code for HIL simulations. The generated code can be directly downloaded on al kinds of targets, like RTLinux.
This combination provides you with a fast and powerful method to test controllers on prototypes for a very competitive price.


Contact Us | Feedback | Legal Terms and Conditions

©2010 Controllab Products B.V. All rights reserved