Insights into the PSIM C Block: Differences between the simplified and regular one - Insert GetPsimValue & Insert SetRunTimeValue functions

NikosDimitrakopoulos
NikosDimitrakopoulos
Altair Employee
edited May 31 in Altair HyperWorks

Insights into the PSIM C Block

 

This article aims to clarify two main topics of discussion concerning PSIM's "C block":

  1. How to use the C block's Insert GetPsimValue and Insert SetRunTimeValue functions
  2. What is the difference between the regular "C block" and the "Simplified C block"

Starting with the first question, let me first provide you with the definitions of what those functions do and then a simple example to showcase their potential.

  • Insert GetPsimValue

Retrieve the parameter value of an element in the same schematic but outside the C block. This button will open a dialog which lists all the elements on one side, and the parameters of each element on the other side

  • Insert SetRunTimeValue

Set the parameter value of an element during simulation runtime. This button will open a dialog which lists all the elements on one side, and the parameters of each element on the other side.

__________________________________________________________________________________________________________________________

I suspect that those definitions do not mean much to you, so let me provide a simple example:

Let us consider a simple sinusoidal voltage source block inside a simulation containing a "C block" and a step source. The Vsin source contains the following values and parameters:

 

image

 

In certain simulations, it's helpful to read parameters from within the C block for calculations and change block parameters while the simulation runs to test different scenarios.

In this example, we have a step function, and we will double the amplitude of the Vsin source (50V to 100V) when the step source transitions from 0 to 1. We can read the "Tstep" parameter of the step source.

 

image

image

And then we can use this "Tstep" info to change the peak amplitude of the Vsin to 100V while the simulation is running and after the "Tstep" point.

 

image

The results are the following:

image

 

What is more, C blocks can access variables saved in a parameter file inside PSIM. Let's consider, for example, this parameter file 

image

 

Then the C block or the Simplified C block can access variable "x" with the GetPsimValue built in option:

image

 

Important Note:

The use of the C block isn't the sole or simplest method for toggling variables mid-simulation. While the C block offers advanced customizations and parameter toggling options, your toolkit is powered with other options:

1. Consider exploring the potential of the Parameter file. Follow this tutorial video on how to use the parameter files in PSIM:

How to Use Parameter Files in PSIM

You can also access more detailed information by clicking on the 'Help' button within the parameter file. 

image

 

2. Leverage the Load/Save flags to deal with long simulations and to come up with "smarter" workflows. Follow this link for more information:

Strategies for long simulations and large simulation result files

 

___________________________________________________________________________________________________________

Now to answer the second question:

The simplified C block has two major differences with the C block.

a) It is easier to use as it provides a friendlier GUI. The t , delt variables are easily accessible and the strict C environment is generally abstracted.

b)The simplidied C block can be used for automatic code generation, while the C block can't. To make sure you know which blocks can be used for code gen, you can navigate to Options >> Settings >> Advanced, if the option box "Show image next to elements that can be used for code generation" is checked, a small "CG" image will appear next to these elements that can be used for code generation.

image

Every block in PSIM has a "Help" button. I often find this very informative. In the case of the simplified C block, if you click on help, you will observe that the InsertGetPSIMValue and InsertSetRunTimeValue are NOT supported for automatic code generation.


image