PLECS 3.2 Online Help

Creating a New Circuit with the PLECS Blockset

Open the PLECS library by typing plecslib at the MATLAB command prompt. On Windows you can also use the Simulink library browser and click on the entry PLECS. Copy the Circuit block from the PLECS library into your Simulink model, then double-click the block to open the schematic editor.

[Picture]

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