Tutorial: Simulate and then generating code from a Scicos diagram

From ErikaWiki

Jump to: navigation, search

Introduction

Before execute this simple tutorial follow installation procedure described in installig scicoslab tutorial

How to simulate and then generating code from a Scicos diagram

Note: The images showed below refer to the example for FLEX named DCmotor_Simulation.cos in the 'DCMotor' folder.

To simulate a diagram and then use the same diagram to generate code is advisable to proceed in this way.

  • Create your diagram using a superblock that contains the diagram of your embedded application.
  • Outside the superblock put your simulation blocks.
  • To link the outer blocks with the inner blocks you can use Goto and From blocks.

See the images below.

Outer blocks.
Inner blocks.

By clicking on Simulate menu and selecting Run you can start the simulation. In this case you obtain the graph showed below.

To start the simulation.
Results of the simulation.

To generate code there are two ways:

  1. Copy the superblock and create another diagram to be used for code generation.
  2. Remove Goto blocks and substitute From blocks with zero-constants source blocks.

The second approach is showed in the images below.

Outer blocks.
Inner blocks.

From the CodeGen menu, by clicking on the superblock, you can launch code generation.

Outer blocks.
Personal tools