Matlab to Caspoc parameter export introduction.
NOTE!First save all files before running them!
In Matlab you can calculate parameters and use these parameters in a simulation example that you can start in Caspoc. Both exporting the parameters in a file and starting Caspoc can be done from the same m script. Important is that in the xml file the parameters are exported exactly as shown in the examples below, in Caspoc you have to specify the filename:name with a colon : in between!
Below is a simple example of simulation of a motor drive system, where the Power of the motor and the power factor of the motor are specified in a Matlab script and exported into a Caspoc simulation.
MyFile:MyName
instead of a numeric value in a block diagram block or in a library block. The filename MyFile
is the filename of the exported xml file, the parameter name MyNname
is specified within the tag <name>MyName</name>
.
Below an example xml file is shown
In library blocks you can directly specify the filename:name combination to get he parameters. Belwo an example how to get the parameters Kabel01.L Kabel01.R Kabel01.X from the file intelec.xml
Matlab script for exporting the parameters to Caspoc
Example:Download example RunCaspoc.m
Example:Download example buck.csi
This will produce the following parameter file
The following line in the matlab script runs Caspoc and simulates the file buck.csi
Buck converter
Matlab script for exporting the parameters to Caspoc
Example:Download example RunCaspoc.m
Example:Download example buck.csi
Power system load parameters
Matlab script for exporting the parameters to Caspoc
Example:Download example grid.m
Example:Download example grid.csi
To export results from the Caspoc simulation back to Matlab, the matlab command system()
is expanded with \matlab
Two files are generated when the simulation in Caspoc is finished:
- filename_results.m
Contains all system block output values, electric circuit voltages and currents in Caspoc - filename_scope.mat
Contains all simulation results from the scopes in Caspoc
If the results from the Caspoc simulation have to be post-processed in Matlab, you have to wait inside the matlab script until Caspoc is ready and returned the *_results.m file. In the script you can load this file and post-process the data. The prefix for the data in the file is
- y_XXXXX
Output from a block diagram block XXXXX - v_XXXXX
Voltage over component XXXXX - i_XXXXX
Current through component XXXXX
system()