• Introduction
• What is in this manual
• What is Caspoc
• User interface
• Introduction
• Starting
• Simulation
• Editing
• Viewing and printing
• Getting Started
• Basic editing
• Simulation in the time domain
• Basic User Interface Topics
• Editing
• Simulation
• Viewing
• Library
• Reports
• Project management
• Circuit and Block Diagram Components
• Introduction
• Cscript and user defined functions
• Component parameters
• Modeling Topics
• Introduction
• Power Electronics
• Semiconductors
• Electrical Machines
• Electrical drives
• Power Systems
• Mechanical Systems
• Thermal Systems
• Magnetic Circuits
• Green Energy
• Coupling to FEM
• Experimenter
• Analog hardware description language
• Embedded C code Export
• Coupling to Spice
• Small Signal Analysis
• Matlab coupling
• Tips and tricks
• Appendices

## Experimenter.

Using a Cscript you can control the Simualtion in Caspoc. All you need is to define a Cscript file using ANSI-C where you define what actions should be taken to control the simulation.

Store this file with a ".cs" extension in the project directory belonging to your simulation file.

If your simulation file is called "C:/Caspoc/MySamples/MyExperiment.csi", store the Cscript file in the directory "C:/Caspoc/MySamples/MyExperiment", for example as " C:/Caspoc/MySamples/MyExperiment /MyFirstExperiment.cs"

In the project manager you have access to this file under the "Project/Files" where you can double click the file to open it in a text editor.

To run the experimenter:

1. Open the simulation file (*.csi)
2. Create or edit the (*.cs) file
3. Run the experimenter by selecting "Tools/Start Cscript" from the menu

  main() { int a; int i; int Vc; a=500; Vc=4; CaspocSetTscreen(a); Caspocfopen("cscript_output.txt"); for(i=2;i<10;i=i+1) { print(i); CaspocSetParameter("D",1,i); CaspocSetComponentValue("R1","5"); CaspocSetComponentIC("C1",Vc); CaspocStartSimulation("Some Description"); /* CaspocContinueSimulation("notice"); */ a=CaspocGetOutput("VoutmV"); Vc=a/1000; Caspocfprintf3("outputfile",1,i,a); } Caspocfclose("cscript_output.txt"); print("script finished at i="); print(i); CaspocMessageBox("Title: Cscript","Message: Cscript finished!"); return a; } 

The API calls are explained below.

(These Calls are beta-functions and are subject to changes/improvements)

You always need a main() function which called in the first place. Inside the {} you can define integer variables and initialize them, as deined in the ANSI C standard.

  main() { int a; int i; int Vc; a=500; Vc=4; 

The total time of the simulation is defined using CaspocSetTscreen(int Tscreen). Tscreen is defined in ms.

  a=500; CaspocSetTscreen(a); 

Open text file for storing results from the simulation. The argument is the file name.

  void Caspocfopen("cscript_output.txt"); 

Write numerical results to the message window at the bottom of the Caspoc User Interface

  void print(int i); 

Display a text message to the message window at the bottom of the Caspoc User Interface

  print("script finished at i="); 

Set a parameter in block. The arguments are to be filled as:

1. Name of the block
2. Number of the parameter
3. Value to be set

  CaspocSetParameter("D",1,i); 

Set a circuit component value. The arguments are to be filled as:

1. Name of the circuit component
2. Value to be set

  CaspocSetComponentValue("R1","5"); 

Set the initial condition for a circuit component. The arguments are to be filled as:

1. Name of the block
2. Initial value to be set. (Initial voltage for a capacitor, initial current for an inductor)

  CaspocSetComponentIC("C1",Vc); 

Start the simulation. The argument is not used.

  CaspocStartSimulation("Some Description"); 

Continue the simulation. The argument is not used.

  CaspocContinueSimulation("notice"); 

When the simulation is finished, you can get the output values from the blocks in the block-diagram, by calling CaspocGetOutout();, where the argument is the name of the block. This function returns the value as an integer.

  int CaspocGetOutput("VoutmV"); 

Writes numerical results to the file opened previously with Caspocfopen();. The first argument is reserved for the file pointer and is not used in this beta version. The other arguments are written as numerical values in the text file opened with Caspocfopen(); A newline constant is added by this function.

  Caspocfprintf3("outputfile",1,i,a); 

Close text file for storing results from the simulation. The argument is not used in this beta version

  Caspocfclose("cscript_output.txt"); 

Displays a message box on the screen. The first argument is the title of the message box and the second argument is the displayed message.

  CaspocMessageBox("Title: Cscript","Message: Cscript finished!");