C Block
The C Block enables users to input C code directly without the need for compilation. A C interpreter engine will interpret and execute the C code at runtime. This feature simplifies the process of writing custom C code.
C Block Code Consists of Four Sections:
In this case, the controlled current source and C Block are employed to construct a three-phase current source, which demonstrates the function of the C Block. Specifically, the C Block defines the output for each simulation step within the SimulationStep function, namely the three-phase sinusoidal signal. Subsequently, it outputs the three-phase sinusoidal current through the controlled current source.
The following figure shows the three-phase current waveform of the output of the controlled current source.
| Predefined | Global variables and user-defined functions. |
| SimulationStep function | Code that is called by DSIM at every time step. |
|
SimulationBegin function |
Code that is called only once at the beginning of the simulation. |
| SimulationEnd function | Code that is called only once at the end of the simulation. |
A Case of the C Block