Libraries
Libraries enable you to ensure that the custom components or masked subsystems used in your circuit are always up-to-date. Or, the other way round, if you are developing your own custom components you can use a library to ensure that changes you make to your component models are automatically propagated to a user's circuit upon loading.Creating a New Library in PLECS Blockset
To create a new component library, open the PLECS Extras library and copy the PLECS Library block into a Simulink model or library. The Simulink model must be named (i.e. saved) before you can copy components from the component library.
To add the new library to the library browser it has to be added to the list of user libraries in the PLECS Preferences (see chapter Configuring PLECS for details).
Creating a New Library in PLECS Standalone
Any model file in PLECS Standalone can be used as a library file. Additionally it is also possible to use PLECS Blockset libraries in PLECS Standalone. To make model file available as a library the file has to be added to the library list in the PLECS preferences (see chapter Configuring PLECS for details).
To create a new library file, create a new model file, copy the desired components into it and save it in a directory on the library path. The library path is also set in the PLECS preferences.
Creating a Library Reference
When you copy a library component - either into a circuit schematic or into another or even the same component library - PLECS automatically creates a reference component rather than a full copy. You can modify the parameters of the reference component but you cannot mask it or, if it is already masked, edit the mask. You can recognize a library reference by the string "(link)" displayed next to the mask type in the dialog box or by the string "Link" displayed in the title bar of the underlying schematic windows.
The reference component links to the library component by its full path, i.e. the Simulink path of the PLECS Library block and the path of the component within the component library as they are in effect at the time the copy is made. If PLECS is unable to resolve a library reference it highlights the reference component and issues an error message.
You can fix an unresolved library reference in two ways
- Delete the reference component and make a new copy of the library component.
- In the PLECS Blockset, add the directory that contains the required Simulink model to the MATLAB path and reload the circuit.
Updating a Library Reference
Library references are resolved upon loading of a circuit. Afterwards, any changes that you make to a referenced library component are automatically propagated to the referencing components when you start a simulation or (in the PLECS Blockset) when you update the simulation model.
Breaking a Library Reference
You can break the link between a library reference and the library component. The reference then becomes a simple copy of the library component; changes to the library component no longer affect the copy.
In order to break the link between a reference and its library component, select the reference component, then choose Break library link from the Subsystem submenu of the Edit menu or the component's context menu.
It is often desirable to break the links to all user-defined libraries in a model, for example when sending a model to another PLECS user who does not have all the libraries that the model depends on. This can be done by selecting Break all library links... from the Edit menu. Library links to the PLECS component library are not affected by this functionality.