100% found this document useful (1 vote)
787 views2 pages

Automatic Matlab and DIgSILENT

This document describes an example of automatic data exchange between Matlab and DIgSILENT power system simulation software. A Matlab script generates active and reactive power values for two loads in a power system model in DIgSILENT. These values and other data are written to a .csv file which is read by a DIgSILENT script. The script updates the loads and runs a load flow, writing voltage and angle results back to the .csv file. This establishes a loop between the programs with communication managed by a flag file that indicates when each program should run or wait. The process provides a template for bidirectional data transfer between Matlab and DIgSILENT that could be customized according to user needs.

Uploaded by

Lalo Pato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
787 views2 pages

Automatic Matlab and DIgSILENT

This document describes an example of automatic data exchange between Matlab and DIgSILENT power system simulation software. A Matlab script generates active and reactive power values for two loads in a power system model in DIgSILENT. These values and other data are written to a .csv file which is read by a DIgSILENT script. The script updates the loads and runs a load flow, writing voltage and angle results back to the .csv file. This establishes a loop between the programs with communication managed by a flag file that indicates when each program should run or wait. The process provides a template for bidirectional data transfer between Matlab and DIgSILENT that could be customized according to user needs.

Uploaded by

Lalo Pato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Automatic data exchange between Matlab and DIgSILENT

I created a simple example of automatic data exchange between Matlab and DIgSILENT that
could be modified according to the user needs. So, I attached two files, one is MatDIg.m file, which
contains the Matlab code for the automatic data exchange and where the user can design the algorithm
and the other is DIgMat.pfd file, that contains the power system model and the script (DIgMat script),
that contains the DIgSILENT code for the automatic data exchange. This communication between
software is realized throughout 2 .cvs files (Flag.csv and Data.csv).
Flag.csv - contains only one value (1 or 0). 1 - means that Matlab works and DIgSILENT
stays. 0 - means that Matlab stays and DIgSILENT works.
Data.csv - contains a vector of data and is divided in two. First 10 values can be filled with
variables that are necessary in the data exchange procedure, and from 11 forward are the variables of
interest that must be transferred in order to be used by DIgSILENT.
In figure, is represented the overall procedure.

Flag.csv

Matlab DIgSILENT

Data.csv

In this example, in order to describe the communication, I considered an algorithm modeled in


Matlab (in this case the algorithm are just some random generation of active and reactive power) and
the power system modeled in DIgSILENT. So, I created a loop between Matlab and DIgSILENT
which consists of:
- the algorithm in Matlab generates P and Q for the 2 loads in the power system from
DIgSILENT.
- these data are written in Data.csv along with other variables useful in the automatic data
exchange such as size of Data vector, number of iterations, current iteration.
- after that, Data.csv is read by the script in DIgSILENT, memorized into a vector called Data,
the P and Q of the two loads are written into each load interface, the load flow calculation is
executed and the voltages and the angles of the two buses are read and, after that, written into
Data.csv.
- These data (voltages and angles of the two buses) are read by Matlab and used further in the
analysis.
The communication protocol of the automatic data exchange is realized throughout Flag.csv which
is scanned and modified by both programs. When Matlab works (Flag.csv is 1), DIgSILENT waits and
scan Flag.csv. After Matlab finishes its work, it changes the value of Flag.csv to 0 and DIgSILENT
detects this change and its starts to work and Matlab stays and scan the Flag.csv to see when it is going
to change.
In order to run the procedure, follow the next steps:
- Place Matlab in the left half of the screen and DIgSILENT in the right half of the screen.
- Open MatDIg.m file.
- Activate DIgMat.pfd project.
- Open Data Manager, click on plus in the left side of the active Study Case called DIgMat,
click on plus in the left side of the Study Case, click on Study Case and in the right, search for
DIgMat script and double click it. The script will open.
- First click run on the MatDIg.m, and then click Execute on the button from the upper right of
the script.
- After that, you will see in the output window of DIgSILENT the number of iterations and the
voltages and angles that are transmitted to Matlab.

Obs.: to understand better the whole procedure, open these two files and follow the code carefully,
because it contains a large amount of comments regarding each sequence of code. Succes!

Dr. Ing. Stativa Andrei

You might also like