## Choosing and selecting library blocks

In order to simulate your own schematics, CASPOC provides many different components. All the components are divided into three groups: Circuit, Blocks and Library. In the previous tutorials, we already talked about how to use Circuit and block components. This tutorial, we will focus on library blocks and introduce their categories. The library block includes all the components built by Circuits or Blocks. Understanding the library categories is very important so that users can easily find out some complex library blocks they need without rebuilding it by themselves. Each library block provides several parameters which depend on the theorems or certain existing models. Users can also customize their own library block in CASPOC by defining the labels and export directions. We will show one example in this tutorial in the end.

### The categories of library blocks

The library blocks in CASPOC are located in the tree view of Components/library. Unfold the tree view and find the category list as below. Besides “AdvancedElectricalDrives” is the collection of the using components in the two books “Fundamentals of Electrical Drives” (ISBN: 978-1-4020-5503-4) and “Advanced Electrical Drives” (ISBN: 978-94-007-0179-3), all the others are put according to their properties. We will explain them one by one.

• AC: Includes one component “phasors” to deal with the input signal by Fourier and ab-dq transformation.
• AdvancedElectricalDrives: Includes the components which is used in the books “Fundamentals of Electrical Drives” and “Advanced Electrical Drives”.
• Automotive: Includes all the components which can simulate hybrid/electrical vehicles, like Lima alternator, battery, ICE (internal combustion engine), lamp, spark plug, and super capacitor.
• Bcd: Include two components “AtoD” which converts analog signal to digital and “BCDto7” which converts 4-bit binary coded decimal to 7 segment signal.
• Control: Includes all the components which is used for designing a control system, like all different kinds of controllers (PI, PID, ALS, VOC, PWM, Gate and so on), the components for Field Oriented Control and digital control (Flip-Flop, Delay), different signal sources (sinusoid, square, triangle, pulse, saw, step, and so on), stepper motor, and some transformations (ab-dq, ab-rst, dq-ab, rst-ab).
• Electric: Includes some specific circuit components which don't exist in Components/Circuit, like nonlinear capacitor, ESD(Electrostatic discharge), impedance, ground (only for icon display, equal to label =0), nonlinear and three-phase inductance, nonlinear and three-phase resistance, and switch.
• ElectricalMachines: Includes all kinds of electrical machines, like DC, Stepper, IM, SRM, BLDCM, PMSM, BLACM, IRTF and so on. Choose any one kind of electrical machine, like PMSM, you will find there are probably two or more than two kinds PMSM models in the folder. Depending on your requirement, choose the most suitable one. For example, some simple electrical machines only need to give a three-phase current source and then export an angular speed with a torque sensor. But while you want to consider some internal magnetic parameters (like Ld and Lq) and add one more position sensor, you will be able to choose some complex electrical machines like BLACM. There are also certain transformation models that users are able to implement their control method on these electrical machines. The transformation models are much more complete than these in the previous category “Control”.
• Filters: Includes some basic filters, like bandpass, bandstop, highpass, lowpass, and transfer function (from 1st to 6th order).
• GreenEnergy: Includes all the components which is related to renewable energy, like solar cell, wind turbine and fuel cell.
• Inverters3phase: Includes the necessary components for three-phase inverters, like PWM controller.
• Lighting: Includes some lighting components, like CCFL, EEFL, HCFL, LED.
• Magnetic: Includes the components for designing your own transformers, like airgap, winding, reluctance, and different materials.
• Main: Includes single-phase and three-phase mains 50 or 60 Hz with/without ground terminal.
• Mechanic: Includes all kinds of mechanic components according to the properties. The category “Rotational” stands for the components which rotate during the simulation, like gearbox, mechanic loads, brake, and so on. The category “Transformation” stands for the components which change the state of the force during the simulation (i.e. change the rotation to translation), like elevator, wheel. The category “Translational” stands for the components which move during the simulation, like hanging or pressing mass.
• OptoCoupler: Includes one opto coupler.
• PowerConverters: Includes all kinds of power converters, like two-phase inverters, three-phase inverters, two-phase rectifiers, three-phase rectifiers, AC/DC, DC/AC and DC/DC converters.
• PowerSystems: Includes the components of electricity distribution. While delivering the electricity to end users, users have to consider some filters (like double tuned filter), transmission lines, load (series or parallel), breaker, fault and switch.
• Probes: Includes all kinds of probes which users can use to measure voltage, current, power, harmonic distortion and their corresponding average or RMS values.
• Semiconductor: Includes all kinds of different semiconductors, like 555, BJT, Diode, GTO, IGBT, MOSFET, SCR and so on. Especially IGBT and MOSFET, users can choose simple or complex models depending on their requirement. For example, considering the thermal problem or not will relate to choose a semiconductor with or without the thermal connection.
• Sensor: Includes all kinds of common sensors which can retrieve the simulation results during the simulation. There are current, voltage, power, harmonics, position, torque, angular speed, hall, force, speed, weight and so on. The use of sensors is very important for evaluating the system performance because we can get the data from sensors by using SCOPE and also use mathematical operators to calculate some useful information.
• Source: Includes circuit sources and signal sources. We already saw all of them in the previous categories, here just rearrange the common sources in order to find them out easily.
• Thermal: Includes all the components which is related to thermal, like heatsink, layer material, model parameters from ANSYS, heat source, ambient, air or water convection, radiation and so on.
• Transformers: Includes some common transformers, like ideal, piezo, single-phase and three-phase.

### The contents of the library blocks

In CASPOC, users can use project manager to manage the using library blocks. Unfold the tree view of “PROJECT” behind “Components”. Go to PROJECT/Schematic/Main Schematic which is the current schematic we're using. Because we have not put any library block in the workscreen, there is only the main schematic.

Go to Components/Library/PowerConverters/Inverters3phase/Inverter. Left-click the inverter and release your mouse button. Choose a suitable place and left-click to put the inverter in the workscreen.

Currently we can still see the main schematic in the schematic. Left-click the button in the right of the search button to refresh the tree view (or click View/Refresh TreeView in the menu bar).

Then unfold the tree view of “PROJECT/Schematic" and find out the library block “INVERTER1” which is in the workscreen now.

Left-click the INVERTER1, we can see the content of the library block shown in the right workscreen. The background of the library content is different from the main schematic in order to identify the different workscreens.

You can go back to the main schematic by left-clicking “Main schematic” (step 1). Then right-click the library block “INVERTER1” to see its property window (step 2).

In the property window, click the button “Edit” and we can also see the content of the library block which was shown in PROJECT/Schematic/INVERTER1. Here we can see the file name is INVERTER.LIB. (Note that .lib is the standard file extension of library block in CASPOC.)

Compare the model parameters of the library block to its content. We can find all the model parameters are read by MPARSETALL (the component for setting all model parameters) in the right side. And in the left side, there is the circuit with 11 exports (see the blue, green, and pink arrows) which can connect to other components in CASPOC. We will practice how to use in the fourth part of this tutorial.

Besides the model parameters, we can also find other settings of the library block: Set the display picture (step 1) and rotate the library (step 2). If you don't understand the function of the library block, you can click the button “Help Lib” (step 3) to launch a pop-up window (Quick online help) and a html page.

### Folder, File name, *.lib & *.csi

Close the property window of the library block and save this schematic in C:\CASPOC2009\Samples. Then we will see the filename of this schematic is *.csi. (Note that the standard file extension of schematic is .csi). Remember that the file extension .lib stands for library block in previous part.

Go to C:\CASPOC2009\ and we can find two folders “Library” and “Samples” which is used for library blocks and schematics respectively. All the library blocks (.lib) are located in the folder “Library” and classified according to their properties. We already introduced the categories in the first part of this tutorial. As well as the folder “Samples”, all the schematics are located here and classified according to their properties. In CASPOC, we use the same categories in “Library” and “Samples” so that users can easily refer to the corresponding samples according to any certain library block.

Go to C:\CASPOC2009\Library\PowerConverters\Inverters3phase\ (the same path while we select inverter from Components/Library/PowerConverters/Inverters3phase). And find out “Inverter.lib” and “Inverter.bmp”. The two files include the main configuration for the library block Inverter. Inverter.lib specifies the circuit, the components and their corresponding parameters. Inverter.bmp provides the icon display for Inverter.lib in CASPOC workscreen.

### Create your own library block

Now we can practice one example to know how to build your own library block in CASPOC. Left-click an inductor in Components/Circuit/RLC/L and release your mouse button. Left-click in the workscreen as below, then do the same step to put a capacitor from Components/Circuit/RLC/C.

Connect the inductor and the capacitor by the following steps.

Right-click the anode of the inductor (step 1) and enter the label “IN_A” (step 2). Click OK (step 3).

Do the same steps with the other three nodes as below and give them labels “IN_B”, “OUT_A” and “OUT_B”. Click OK in each window after typing the label.

Right-click the node “IN_A” again, now we can find the option of export direction behind the label name. Set the export direction of node IN_A to left, and click OK. As well as the other three nodes, the export directions of node “IN_B”, “OUT_A” and “OUT_B” are left, right and right respectively.

After specifying the export directions, we can see a flag around the node according to its direction (step 1). Then go to Edit/Export Library (step 2).

Select Yes or No depending on your need. Select “Yes” is to save only the selection part. Select “No” is to save all.

The Export library function will detect all the export labels in this schematic as below (step 1). You can also give a title and description to this library in following blank spaces. Click “Export” button to export the library (step 2) and go to C:\CASPOC2009\Library (step 3). Create a new folder (step 4) and name “user” (step 5). Then save this schematic in the folder “user” and name “LC” (step 6).

Go back to CASPOC software, and click “Create a new schematic” (step 1). Click the button “Refresh tree view” (step 2). Go to Components/Library/user/ (step 3) and find the library LC which we created just now. Left-click the library block LC and release your mouse button (step 4). Click the workscreen to put the LC library block as below (step 5). Currently we have not set the picture for LC, the default drawing only shows label name on the icon.

Click “Refresh tree view” again (step 1) and go to PROJECT/Schematic/LC1 (step 2). Left-click LC1 (step 3) and see the content of LC1 in the right side (step 4).

Then we make a drawing picture for LC.lib. Go go C:\CASPOC2009\Library\user and add a new bmp file with the filename LC. Note that the filename of the drawing picture has to be the same as the library block. You can simply draw the bmp file in Microsoft Paint or any other kind of software.

Make sure that your bmp file is in the same folder with your library block. Then go to CASPOC software and click again the LC library block. Now you can easily find the differences after adding the bmp file. Right-click the library block, you will find originally the picture setting of the previous LC is Labels and Block. Now the new setting is Bitmap and Block. You can also design your own drawing by writing a .vec file.