Using PLECS Blockset

The main element of PLECS Blockset is the PLECS Circuit block in the PLECS Library. This block constitutes the interface between the PLECS simulation engine and the Simulink solver.

To open the PLECS library, type plecslib at the MATLAB command prompt or click on the Library Browser icon in a Simulink window and click on PLECS in the Simulink Library Browser window.

../../_images/plecslib.png

Fig. 27 The PLECS library in Simulink

Creating a New Circuit

To create a new circuit, copy the PLECS Circuit block from the PLECS library into your Simulink model, then double-click the block to open the schematic editor.

Note

You cannot place Simulink blocks in a PLECS schematic or PLECS components in a Simulink model because the two programs do not share the same Graphical User Interface.

Importing a Schematic From PLECS Standalone

To facilitate data exchange between PLECS Blockset and PLECS Standalone, you can import the schematics of a PLECS Standalone model into a PLECS Blockset schematic. To do so, choose Import from Standalone… from the File menu.

Opening a PLECS Standalone Model

You can also directly open a PLECS Standalone model in the PLECS Blockset schematic editor. This is useful if you want to work with the Model Reference block.

To open a PLECS Standalone model, choose Open… from the File menu of a schematic editor or the PLECS Library Browser and change the file type filter in the file dialog to PLECS Standalone model files (*.plecs). Note that the schematic editor of a PLECS Standalone model does not have a Simulate menu in PLECS Blockset because you cannot run a simulation without a Simulink model.

Customizing the Circuit Block

You can customize the mask of the Circuit block to a certain extent, e.g. in order to change the block icon or to define mask parameters. For information on Simulink block masks please refer to the Simulink documentation.

Note

You may not change the mask type or remove the callback from the initialization commands. Doing so will break the interface and may lead to loss of data.

If you define mask parameters for the Circuit block, PLECS evaluates component parameters in the mask workspace rather than the MATLAB base workspace. The mask workspace contains both the mask parameters and any additional variables defined by the mask initialization commands. For details on parameter evaluation see Specifying Component Parameters.

By default, a double-click on the Circuit block opens the schematic editor. This can be changed by editing the OpenFcn parameter of the block. To change the behavior so that a double-click opens both the schematic editor and the mask dialog,

  1. Select the block, then choose Block Properties from the Edit menu or from the block’s context menu.

  2. On the Callbacks pane of the block properties dialog, select OpenFcn from the function list and change the content of the callback function to

    plecs('sl', 202); open_system(gcb, 'mask');
    

Alternatively, you can change the behavior so that a double-click opens only the mask dialog. Then, add a checkbox to the dialog that will open the schematic editor when you click on it:

  1. Select the block, then choose Block Properties from the Edit menu or from the block’s context menu.

  2. On the Callbacks pane of the block properties dialog select OpenFcn from the function list and clear the content of the callback function.

  3. Select the block, then choose Edit Mask from the Edit menu or from the block’s context menu.

  4. On the Parameters pane of the mask editor add a checkbox parameter with the prompt Open schematic and the variable name openschematic. As a dialog callback for the new parameter, enter

    if (strcmp(get_param(gcb, 'openschematic'), 'on'))
        set_param(gcb, 'openschematic', 'off');
        plecs('sl', 202);
    end