In this tutorial we will extend the Permanent Magnet DC machine model. First we will add blocks so the user can easily enter the parameters for the block. Second we will add a look-up table to make the inductance current dependent based on results from a FEM analysis.
We start with the PM model that is available in the library. Choose the Permanent Magnet model from Components/Library/ElectricalMachines/DC
This model has two electrical connections, a mechanical shaft and a connection for a .Model database. You can create a simulation for this model by adding inertia and a bearing from Components/Circuit/Rotational, a shaft by drawing a wire and a voltage source from Components/Circuit/Sources
If you open the Permanent Magnet model by clicking it with the right mouse button you will see the list of parameters.
These parameters are dfined in the block using MPAR blocks. If we open the PM model by clicking the [Edit] button, we see the total model.
The MPAR blocks create the parameters that can be entered by the user. They are a replacement for the constant block CON and will appear in the list of parameters that is shown in the component properties dialog box. You specify the name of the parameter and its default value. For example the value for the rotor inertia has a default value of 2m and the name of the parameter is JM. This value is used to change the value of the circuit component Crotor.
The input of the MPAR block is also exported. You can use this node to connect it to a MNAME block where you can specify the name of the .model database parameters. Parameters defined by a .Model database overwrite the parameters given by the user. If you would connect a MNAME block to the input of the MPAR block and would define, for example, MyPM as model name, your .model database could look like:
.Model MyPM user La=5mH Ra=10m JM=3m
In this case the value of 3m for JM would overwrite the default value and the value entered by the user.
If you open the properties dialog box for the MPAR block for JM, you can enter the name JM and the default value of 2m.
Behind the MPAR block is a ChangeE block that is used to change the value of the circuit component. In this case it is the rotor intertia modeled by the circuit component Crotor. Define a 0 at the second input of the ChangeE block and enter the name of the circuit element in the component properties dialog box of the ChangeE block.
If we run the simulation we seethe angular speed in the scope.
To see what is happening inside the Permanent Magnet model during the simulation, we can open the model for viewing by selecting Project/Schematic/PERMANENTMAGNET1 being the name of our model. If the name of the model is not appearingin the project manager, press the [F5] Refresh function key on your keyboard.
Our next step is to include a look-up table for the inductor value. In FEM we have calculated the inductor as function of the current and we observed a saturation. WE will use a LookUp1D block to model the inductance. Therefore we remove the changeE and Mpar blocks for La and build a new structure usingthe blocks ABS, LOOKUP1D, FileSet and ChangeE
The ABS block is used to get the absolute value of the inductor, so the lookup table only has to be created for positive currents. The LookUp1D block reads the data pairs from the lookup file from FEM. A Spline interpolation is used to read the inductance from a small set of calculated data pairs. Define the parameters for the Lookup1D block as
The block FileSet is used to set the name of the lookup file outside of the library bock. Connect the second input to the block for which we want to change the file name and the first input will be exported. Outside of the library block we will connect a FileName block to this connection. The output from the LookUp1D block is the actual inductance that is set by using the ChangeE block. Here the name of the inductor circuit model LA is specified and the second input is set to 0. The 0 for the second input indicates that the value is always updated in the inductor model.
Export the schematic by selecting Edit/Export Library from the menu. Select [NO] when you are asked to export the whole schematic or only a part of it. Since we want to export the complete schematic, we select [No].
In the properties dialog box for exporting we can add some extra data for our component and select[Export] to export it.
Select the [Export] button to save the library file. Save it under a new name, since we do not want to overwritethe old file.
The new block will be exported under the name PM_FEM.lib. If you store it in the library in the electrical machines section, it will appear in the list of components in the project manager. Close the window where you edited the library block and return to your main schematic.
If you press the [F5] refresh button, the Project Manager will be updated and the newly build model will be listed among the other electrical machines blocks. (If you saved it in the directory \\Caspoc\Library\ElectricalMachines) If it is not stored in the Caspoc Library, you can use Edit/Import Library
to read you new component.
If it is stored in the list of library components in the Project Manager, you can select it directly from there.
Select the new component and place it on the schematic.
To connect the lookup file to the model we first have to define where we store the lookup file. We saved the sample under the name PM_FEM.csi. If we create a folder with the same name and store our data files in that folder, the files become easily accessible from the Project Manager.
Save your data file in the new folder and press the [F5] refresh function key on your keyboard to refresh the Project Manager. If you open the Project Manager and open the section Files, you will see your data files listed.
Double clicking our data file in the Project Manager will open it in the default Scope.
We can see the numerical values also in a tabulated form by selecting Edit/Edit from the menu. Take care that your lookup file should include at least one Carriage Return in the file.
WE build the new schematic where we add the FileName block and connect it to the PM model.
Specify the filename PM_FEM\LA.dat at Text2 in the properties dialog box of the FileName block. If the file LA.dat exist, you can start the simulation. If you encounter an error, with the message that the file PM_FEM\LA.dat can not be found, reopen the sample (First save it!) It is possible that you started with this sample from scratch and in that case the system does not know where to search for the relative path for the data file. If you reopen the sample, the relative path will be known.
You can now run the simulation and if you open the scope, you will see the angular speed during start-up of the Permanent Magnet machine.
If you have the Replay function enabled, you can also view the functioning of our look-up for the inductor value. For example around a current of 2kA, the inductance should be around 4mH. Move the replay track bar to see the output from the LookUp1D block for various input currents.
Other parameters can be defined by LookUp1D blocks as well, for example the machine constant.
To create a nice icon for our new block, we will copy the icon from the PM motor model and extend it for our new block.
The easiest way to do this is to place the library block from which we want to copy the icon on the schematic and to open it with the right mouse button. In the properties dialog box click the button [Picture] to open the bitmap in your graphics program. Default Microsoft-Paint is opened, but if you have installed other graphics software, that software is opened. (You can always go to the folder where the library component *.lib is stored and copy or create the icon in there. Note that you have to create a bitmap *.bmp with the same name as the library block.)
After it is opened in our graphics program we will first increase the size. Since the new icon has one input extra on the left side, its height is 20 pixels increased. Therefore we first increase the size of the icon.
To increase the size of the icon, select Image/Attributes from the menu and change the height from 78 into 98.
Extend the line for the elctrical connection and add the text file to indicate that a FileName block should be connected to the first input. Save the new icon under the same name as the library block, in our case PM_FEM.bmp.
Close the graphics program and in the properties dialog box for the PM_FEM block, you enable the display of a bitmap, instead of the labels.
If you close the properties dialog box the schematic will show the new icon for the Permanent Magnet model.