Export Embedded C Code from the block diagram.

You can create ANSI C Code from you block diagram, which you can use in any controlling microcontroller, DSP or microprocessor which has a compiler for ANSI C code.

Since only the function of the block diagram is exported, the input and output routines in your control application have to programmed separately. This makes the exported code hardware independent.

Caspoc will export the file filename.c, which has the same name as your Caspoc file. You have to include this file by adding it in the file list in the program manager of your compiler.

It starts with the variable declarations. The global public variables are declared first. Here all labels defined at the nodes in the block diagram are exported as double. You can access these variables in your main code by using the extern variable declaration.

After the public variables, the Private variables are declared. They start with the static prefix and are declared only within the scope of the filename.c file. Generally speaking the two variables t and h for the simulation time and the step size respectively are declared. These variables can only be accessed within the code defined in the filename.c file.

The function caspocInit(void) should be called during initialization. There is no memory allocated, so no cleaning of memory is required.

The function caspocFunction(void) should be called each time from in the loop in your control application. It simply executes all the calcluations of the blocks and at the end updates the simulation time t with the step size h.

A sample main program could look like:

void main(void)
//default console application
   // Read input
   // Set output
   // Delay(h);

© 2018 CASPOC, All rights reserved. Home   |   Terms and Conditions   |   Legal   |   Export Compliance   |   Privacy Policy   |   Site Map