International Conference on Energy Conversion and Application (ICECA’2001), Wuhan

A NOVEL APPROACH TO SIMULATING POWER ELECTRONIC SYSTEM BY EMBEDDING MATLAB OBJECTS INTO SABER Zhenhua Jiang and Roger Dougal Department of Electrical Engineering, University of South Carolina, Columbia, SC 29208 USA Email: [email protected] ABSTRACT: Matlab/Simlink is a powerful tool for designing control algorithms for power electronic systems. We describe here a method for inserting a matlab-based controller directly into a Saber circuit simulation, which then yields a means to prove the viability of a comprehensive power electronic system design. This approach combines the best aspects of these two powerful tools, making full use of the advantages of each. The major procedure is to convert the MATLAB model to a Saber model. We describe in detail the process for doing that, and then illustrate the process with an example. The results obtained by such mixed model simulation are compared to those obtained by an all-native Saber simulation; numerical results were the same, but the execution time was about 50% longer with the embedded MATLAB objects. Keywords: MATLAB, SABER, power electronic system, simulation 1 Introduction Simulation of power electronic systems presents peculiar challenges due to the need for detailed modeling of both circuitry and control algorithms [1]. Saber is a powerful platform for analyzing electric circuits, while MATLAB is an excellent tool for analyzing control systems. It is often desired to make full use of the advantages of each of these. Although a MATLAB command window can be invoked in the Saber environment, a Saber template cannot call a function in a MATLAB M-file. Therefore, Saber cannot directly refer to a MATLAB object. Fortunately, a MATLAB M-file can be compiled into a C function and a Saber template can call the foreign C function. This provides an approach to import matlab objects into Saber. A future extension of the work will lead to methods to import an entire Simulink model into Saber. The process to import a MATLAB model into Saber model involves the following steps:  Design the controller using MATLAB  Use the Matlab code generator to produce a C language program  Compile the C program into a dynamically linked library (DLL) file  Describe a Saber template that interfaces with the dll file for the controller, and  Design an icon for the controller in Saber and produce a new model for the controller inside the model library. This paper is organized as follows. Section 1 introduces the method. Section 2 describes the method of communication between Saber and MATLAB. Details of the process to convert a MATLAB model to a Saber model are presented in Section 3. In Section 4 we illustrate application of the technique in a typical power electronic circuit, and then compare the results against those obtained using only native Saber models. Section 5 concludes the paper. 2 Overview of Communication Between MATLAB and Saber Saber is a simulator for electrical/electronic and multi-technology circuits and systems. It can be used at many levels, from design of integrated circuits through to design of systems. It handles analog, mixed-analog/digital, and mixedtechnology devices. It is the first single-kernel simulator that allows simultaneous simulation of analog and digital devices, as well as simulation using non-electrical devices. Saber is widely used in the power electronics industry because it has many advantages such as a capability to model networks on a behavior level, good Differential Equation Solver, good Waveform Analysis Capability and a large library of models for electro-mechanical components. But it also has many disadvantages. For example, it has no front end for algorithmic modeling and no links to rapid prototyping or to operation with hardware in the simulation loop. 1

International Conference on Energy Conversion and Application (ICECA’2001), Wuhan

MATLAB/Simulink, on the other hand, is widely used for development of control algorithms. Its strong points include hardware independent functional modeling and fits into tool chain for rapid prototyping and hardware in the loop. It has a good front end for algorithmic modeling. However, MATLAB has a limited capability to model electrical networks and a limited Differential Equation Solver for electric networks. It is obvious, then, that power electronics simulation needs a combination of the capabilities of both Saber and MATLAB. Analogy Inc. (now called Avant!) has distributed the SaberLink Analysis Interface, which integrates MATLAB software into the SaberDesigner environment. It allows users to apply Matlab's tools for numerical analysis (including MATLAB's visualization and graphing tools) to Saber simulation data [2, 3, 4]. Despite this efficient interface, it remains difficult to use the Matlab functions during a simulation -- such as one would do to simulate a power electronic system including its controller. Because a Saber template can neither communicate with MATLAB/Simulink models nor call the function in a MATLAB M-file straightforwardly, Saber cannot refer to a MATLAB object directly. Power Fortunately, a MATLAB M-file can be compiled into a C Electronic Controller function and a Saber template can then call the foreign C System function. This makes it possible to indirectly use Matlab functions within the Saber simulator. A schematic MATLAB diagram of the desired hybrid simulation environment is Saber shown in Fig. 1. The two-headed arrow means exchange Fig.1 schematic diagram for simulation environment of simulation data between MATLAB and Saber environments. Matlab

C function DLL file 3 The approach to embed MATLAB into Saber Model compile The goal of this process is to import MATLAB objects into the Saber simulation environment. Five call Other templates steps are required, as shown in Fig. 2. The first step is to design the controller in Saber Saber MATLAB. Here, the input and output connections template Netlist Netlist provide the bridge to exchange simulation data between MATLAB and Saber. Fig. 2 diagram of model conversion process Implementation of the controller in MATLAB Mfile is performed in the second step. The name of the function that represents the characteristics of the controller is strictly designed to an expected format. This is the MATLAB terminal of data exchange. Thirdly, the MATLAB M-file must be exported to C code, and then compiled into a DLL file, which can be called by Saber. There are many restrictions on the compilation process. The MATLAB command Mcc invokes the MATLAB compiler using the syntax mcc [-options] mfile1 [mfile2 ... mfileN] [C/C++file1 ... C/C++fileN One or more MATLAB Compiler option flags can be specified. If the C programming language is being used to create a foreign routine for use with MAST and the Saber simulator, the routine header must appear exactly as follows: _declspec(dllexport) void _stdcall CROUTINE(double* inp, long* ninp, long* ifl, long* nifl, double* out, long* nout, long* ofl, long* nofl, double* aundef, long* ier) { } Note that the _declspec statement is important for Windows NT since it indicates that the routine is exported from the Dynamic Link Loader and can be found by the Saber simulator. When using, substitute the foreign routine name for CROUTINE. Note that the CROUTINE string must be entered in upper-case characters. In the fourth step, a Saber/MAST template for the controller will be created. This template is, in fact, a MAST wrapper for the controller model. The Saber/MAST language makes it available to use foreign functions or foreign subroutines that are outside of all templates. The procedure for doing this includes the following:  Declaring foreign subroutines in Saber template  Calling foreign subroutines in Saber template  Writing foreign subroutines. The foreign subroutines are written in MATLAB M-file. There are some requirements for the foreign routine. This has been explained in detail in the third step.

2

International Conference on Energy Conversion and Application (ICECA’2001), Wuhan  Compiling foreign subroutines into a DLL file  Making sure that the directory of the DLL file is in the SABER_DATA_PATH. The last step provides an interface for Saber to call the MATLAB object. It requires definition of a symbol to represent the matlab functions, including the input and output terminators, which are of the type to exchange data. The whole process of model conversion can be considered as the abstraction of model. All the components, which include generated C codes of MATLAB model, generated C code wrapper, differential solver, data logger and MATLAB data structure, are converted to a foreign model. The exported model is represented by two files: a MAST file and a dll file. The procedure of model Generated C-code of Exported model is abstraction is shown in Fig. 3. The entire MATLAB model represented by two procedure is involved in a batch file. What the files: MAST file & user should do is to push the button, which can .dll Generated C-code wrapper call the batch file to produce the dll file and Differential Solver (ODE) MTALAB Model Saber/MAST wrapper. There, however, are as .DLL still some limitations in the procedure of model Data Logger conversion. For example, the model conversion Generated Saber/ procedure is dependent on the manual interface. MAST wrapper MATLAB Data Structure Some work is under way to improve this procedure. Fig. 3 Generated model blocks 4 Case study We show here a case study that illustrates this technique. The example system consists of a circuit containing a voltage source, a buck converter, and a resistive load as shown in Fig. 4.

Vin is

L

Vin

C

Vload

Rload

the input voltage of the buck

converter, that is to say, the voltage of the voltage source.

VLoad

represents the voltage

across two ends of the load. The parameters of the circuit are as follows: L=100mH, C=100 uF, Frequency=20.0 kHz,

RLoad =10

ohms,

Controller

Fig.4 circuit diagram for the example system

vin =30 volts, Simulation time=100 ms, Time step=1 us. The expected load voltage is 15 volts. At t=60 ms, the load resistance is changed to 12 ohms. The input of the controller is the load voltage and the output is the voltage between the base and emitter terminals of the transistor, which controls the switching state of the transistor. The goal is to define in MATLAB a feedback function that measures the load voltage and controls the duty of the buck converter so that the load voltage is independent of the load resistance. For simplicity, we used a PID control strategy. We first wrote a MATLAB M-file that reads in the load voltage, performs the PID control calculations, and then writes out the commanded value of switch duty. The MATLAB M-file for the controller is listed below. Note that in(1) is the value of the current load voltage while in(2) is the value of the load voltage before exactly a time step and h is the time step. function mypidcontroller(in,nin,ifl,nifl,out,nout,ofl,nofl,aundef,ier) { outi_memory=in(3); % memory for integration h = in(4); %time step Kp=in(5); Ki=in(6); Kd=in(7); % coefficients of pid controller outp = in(1)*Kp; outi = outi_memory + in(1)*h*Ki; outd = (in(1)-in(2))*Kd/h; out(1) = outp+outi+outd; % output of the controller out(2) = outi; % to output the current integration } Then we converted the M-file to a C function, and then called the C function in a Saber MAST template that represents the PID controller object in a Saber simulation. The controller template is designed to call the foreign MATLAB model. The Saber/MAST template for the controller is listed below.

3

International Conference on Energy Conversion and Application (ICECA’2001), Wuhan template pid in1 in2 in3 out1 out2 = Kp, Ki, Kd input nu in1 in2 in3 output nu out1 out2 number Kp=1.0, Ki=1.0, Kd=1.0 { val v work1,work2 foreign mypidcontroller values{ (work1,work2) = mypidcontroller(in1,in2,in3,1u,Kp,Ki,Kd) } equations { out1: out1 = work1 out2:out2 = work2 } } The embedded pid controller was used together with a delay model. The remaining parts of the circuit were placed into the circuit using the standard models from the Saber model library. The parameters for pid controller are as follows: Kp=1.0, Ki=0.1, Kd=0.01. The computed load voltage is shown in Fig. 5. In order to verify the effectiveness of the embedded MATLAB object, the results were compared to a similar simulation that used a native Saber model for the PID controller. The same circuit and parameters were used. Simulating the entire circuit in Saber gives the load voltage as shown in Fig. 6. From Fig.5 and 6, it can be seen that the simulation results with foreign MATLAB objects in Saber simulation are similar to those with all native Saber objects.

Fig.5 Load voltage with the presented method

Fig.6 Load voltage in native saber simulation

The total CPU execution time was 20.2 seconds when using all native Saber models and 31.4 seconds when using the embedded Matlab object. 5 Conclusions There exists a reasonable routine for a Saber simulation to call a foreign MATLAB objects. The simulation results obtained using a foreign MATLAB object as the controller were similar to those obtained using a native Saber controller object. The execution time for simulations using embedded MATLAB code is longer than the time for the native saber function to complete the simulation. 6 Acknowledgement This work was supported by the Office of Naval Research under Grant N00014-00-1-0131. 7 References [1] R. Dougal, T. Lovett, A. Monti, E. Santi A Multilanguage Environment for Interactive Simulation and Development of Controls for Power Electronics, IEEE Power Electronics Specialists Conference, Vancouver, Canada, June 17-22, [2] SaberLink™ Analysis Interface to MATLAB - Interactive analysis interface for circuit simulation, http://www.mathworks.com/products/connections/product_main.shtml?prod_id=16. [3] SaberLink Analysis Interface to MATLAB, http://www.spsda.com.sg/analogy.htm [4] SaberLink™ Analysis Interface to MATLAB, Seamless Integration into SaberDesigner environment, http://www.analogy.com/Products/DataSheets/SaberLink_Datasheet.pdf

4

A NOVEL APPROACH TO SIMULATING POWER ELECTRONIC ...

method for inserting a matlab-based controller directly into a Saber circuit simulation, which ... M-file can be compiled into a C function and a Saber template can call the foreign C function. ... International Conference on Energy Conversion and Application (ICECA'2001), Wuhan. 2 .... Some work is under way to improve this.

199KB Sizes 11 Downloads 307 Views

Recommend Documents

A Novel Approach to the Electronic Nose Concept: the ...
makes possible the fabrication of electron nose preventing most common emergencies in residential ... J.H.Kim, J.S.Sung, Yu.M.Son, A.A.Vasiliev,. E.A.Koltypin,.

A Novel Approach to the Electronic Nose Concept: the ...
Datasheet presented in website of the company: www.figarosensors.com. 3. A.A.Vasiliev, S.Yu. ... B.I.Podlepetski,. A.V.Sokolov, A.V.Pislaikov. The mechanism of ...

A Velocity-Based Approach for Simulating Human ... - Springer Link
ing avoidance behaviour between interacting virtual characters. We first exploit ..... In: Proc. of IEEE Conference on Robotics and Automation, pp. 1928–1935 ...

A Novel Approach to Cloud Resource Management for Service ...
condition of illumination etc. The pricing scheme used in existing cloud system requires a kind of manual service differentiation, so there is a need ... Facing these problems, we proposed a new approach which is a novel cloud resource allocation fra

A Novel Approach To Structural Comparison of Proteins
Apr 13, 2004 - April, 2004. Abstract. With the rapid discovery of protein structures, structural comparison of proteins has become ... Science and Engineering, Indian Institute of Technology, Kanpur. No part of this thesis .... Using the QHull progra

Wireless QoSNC: A Novel Approach to QoS-based ...
services offer TV broadcasting, video telephony and other sorts of media ... where the broadcast nature of wireless medium and link losses are taken into ..... All nodes within this radius receive the transmitted symbol correctly and were considered

A Novel Approach to Cloud Resource Management for ...
A Novel Approach to Cloud Resource Management for ... the jobs employing cloud resources both for communication-intensive and data-intensive computations ...

A Novel Approach to the 2D Differential Geometric ...
of-attack is developed to formulate the DG guidance system, whose iterative solution is established ... Therefore, a different approach may be given to study mis-.

A novel approach to Monte Carlo-based uncertainty ...
Software Ltd., Kathmandu, Nepal, (3) Water Resources Section, Delft ... was validated by comparing the uncertainty descriptors in the verification data set with ... The proposed techniques could be useful in real time applications when it is not ...

A Novel Approach to Automated Source Separation in ...
of the proposed method with other popular source separation methods is drawn. ... The alternative method for speech separation that is pre- sented in this paper is not .... around the pitch harmonics versus the overall energy of signal xm.

A Novel Approach to the 2D Differential Geometric ... - jlc.jst.go.jp
1ЮDepartment of Aerospace Engineering, Harbin Institute of Technology, ... 2ЮShanghai Electro-Mechanical Engineering Institute, Shanghai, P.R. China.

TIRAMISU: A novel approach to content ...
key management for seamless super-distribution of ... Convergence of digital media distribution chan- ..... fashion, e.g. distribution from a web portal or P2P.

pdf Evaluation with Power: A New Approach to ...
Evaluation with Power: A New Approach to Organizational Effectiveness, Empowerment, and Excellence (The Jossey-Bass Nonprofit & Public Management Series) PDF, Read Online Evaluation with Power: A New Approach to Organizational Effectiveness, Empowerm

Novel Prospective Approach to Evaluate.pdf
Whoops! There was a problem loading more pages. Retrying... Novel Prospective Approach to Evaluate.pdf. Novel Prospective Approach to Evaluate.pdf. Open.

A Majorization-Minimization Approach to Design of Power ...
Sep 13, 2010 - renewable sources of energy will further stress the grid as these resources are .... the resistive network model; (II-B) discusses how AC power.

Novel Approaches to Solving the Electronic ...
5 Simulated Quantum Computation of Molecular Energies. 90 ...... general interest, since much of chemistry proceeds through pathways involving radi- cals.

A Novel Approach to a HighCapacity Data Hiding in ...
on Signal Processing and Information Technology ... possible the other indicators are of a proper degree. While ... information including image information.

Novel Approach to Ladder-Type Polymers ...
May 25, 2001 - clear solution was poured into a water/pyridine mixture. (5:1) and heated to ... Furthermore the melting point of 22a is iden- tical to the reported ...

Simulating a two dimensional particle in a square quantum ... - GitHub
5.3.12 void runCuda(cudaGraphicsResource **resource) . . . . . 17 ... the probabilities of the position and the energy of the particle at each state. ..... 2PDCurses is an alternative suggested by many http://pdcurses.sourceforge.net/. The.