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! <br>Click to close the image

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. <br>Click to close the image

Inside Caspoc you can read parameters from the exported file when you specify 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 <br>Click to close the image



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 <br>Click to close the image

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
<br>Click to close the image

Power system load parameters

Matlab script for exporting the parameters to Caspoc Example:Download example grid.m
Example:Download example grid.csi
<br>Click to close the image

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:

  1. filename_results.m
    Contains all system block output values, electric circuit voltages and currents in Caspoc
  2. 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

To wait until the Caspoc simulation is finished before continuing the Matlab script, omit the ampersand symbol & in the system call system()

© 2018 CASPOC, All rights reserved. Home   |   Terms and Conditions   |   Legal   |   Export Compliance   |   Privacy Policy   |   Site Map