A Variable Step-Size C-MEX S-Function for Reduced ...

2 downloads 0 Views 865KB Size Report
Abstract — This paper develops and compares three different methods of simulating a space vec- tor PWM pulse generator for an adjustable speed drive using ...
A Variable Step-Size C-MEX S-Function for Reduced Simulation Times of Variable Speed Drives Alan Mullane, Gregor Gregorˇ ciˇ c, Gordon Lightbody and Robert Yacamini Department of Electrical Engineering University College Cork IRELAND E-mail:[email protected]

Abstract — This paper develops and compares three different methods of simulating a space vector PWM pulse generator for an adjustable speed drive using variable step-size simulations and Simulink. The simulations are designed to adjust the step-size such that the simulation steps and the precalculated switching times coincide exactly. Three different methods are compared: a standard Simulink implementation, an M–File S–Function implementation and a CMEX S–Function implementation. The CMEX S–Function version proves to offer the most flexible programming environment and results in the shortest simulation times. By using CMEX S–Functions and variable stepsize simulations, systems comprising of fast switching dynamics and slow machine dynamics can be simulated in acceptable timeframes. Keywords— PWM, IGBT, S–Function, Simulink

I

Introduction

In recent years much attention has been paid to the simulation and control of electrical drives [1],[2],[3]. Electrical drives are predominantly constructed from power semiconductor devices acting as switches to transform between dc voltage and ac voltage. For modern drives the switching is performed at a high frequency (1 − 30KHz). Accurate representation of the high frequency switching can make simulations of drives restrictively slow. This is especially true when the drive is connected to a system with much slower dynamics, such as an induction machine. In order to accelerate the simulation the electrical drive is often replaced with an sinusoidal voltage source or it’s direct and quadrature voltage equivalent [4]. This approach is adequate under certain circumstances. However this assumption cannot be made when the device switching may have a direct outcome on the phenomenon under investigation, such as power quality studies. Previous authors have proposed alternative approaches for simulating drives including switching functions and separate high and low frequency models [5]. These methods can result in improved simulation time. Drives can be modelled as a discrete system, however if a fixed time step is used in the simulations, errors can occur. If a switching instant is required between two simulation steps, then the switch will be shifted forward to the next step. In order to minimise this error, the simulation stepsize must be reduced, and lengthy simulation times will result. While variable step-size solutions have been investigated [6], a solution where the simulation actively calculates and defines the step-sizes

according the switching occurrences, has yet to appear. This paper will develop a variable stepsize simulation of a pulse generator for a three phase inverter. This simulation method calculates the exact switching times and adjusts the simulation step-size accordingly to ensure that the switch times and the simulation times match. The modulation technique used will be space vector pulse width modulation and the drive will consist of 6 Insulated Gate Bipolar Transistors (IGBT), these devices act as switches as shown in figure 1. Three methods available in Simulink to model such a system will be compared : i)standard Simulink implementation, ii)M–File S–Function implementation and iii)CMEX S–Function implementation. The three pulse generator models will be connected to an induction machine simulation and simulation speed comparisons will be made. II

Space vector Modulation

For a three-phase voltage source inverter, each pole voltage may assume one of two values depending on whether the upper or lower switch is turned on. Consequently there are only eight possible operating states for the inverter. These consist of six active states and two zero states. Figure 1 shows the inverter in active state 1, represented as [100], where ”1” indicates that pole A is connected to the upper rail, and ”0” indicates that poles B and C are connected to the lower voltage rail. There are five remaining active states for the inverter, these appear figure 3. The two zero states of the inverter occur when the top three switches are closed, or the bottom three switches are closed, corresponding to state 0 : [000] and state 7 : [111]. Suppose that the inverter is feeding a three phase star connected load. The instantaneous line to neutral

Fig. 1: Inverter operating in state 1

voltages are vAN (t), vBN (t), vCN (t). It is possible to represent the inverter output vs (t), as a complex voltage space vector vs (t) = vsα (t) + jvsβ (t)

(1)

where 

vsα (t) vsβ (t)



 =

1 1 − √2 3 0 2

−√12 − 23





 vAN (t)  vBN (t)  (2) vCN (t)

Now calculate the vector v1 , for the inverter operating in state 1 as shown in figure 1.    vDC  vAN (t) 2  vBN (t)  =  −vDC  (3) 2 −vDC vCN (t) 2 so



vsα (t) vsβ (t)



 =

vDC 0

 (4)

Thus v1 is a vector lying along the real axis of the complex space of length vDC . Similar calculations can be performed for the seven remaining states of the inverter, the resulting vectors are given in figure 2

Fig. 3: Realisable space vectors

seen that the six active vectors subdivide the space vector plane into six equal sectors. For balanced three-phase sinusoidal output voltages of amplitude v and frequency ω, the required output of the inverter is     vCos(ωt) vAN (t)  vBN (t)  =  vCos(ωt − 2π )  (5) 3 vCN (t) vCos(ωt + 2π ) 3 and the corresponding space vector is given by      vCos(ωt) 1 1  1 − − vsα (t) √2 √2  vCos(ωt − 2π )  = 3 3 vsβ (t) − 23 0 2 vCos(ωt + 2π 3 ) 

Fig. 2: Realisable space vector co-ordinates

These vectors can be plotted on the complex plane as shown in figure 3. This figure also shows the position of the inverter switches corresponding to each active states of the inverter. It can be

vsα (t) vsβ (t)

 =

3 v 2



Cos(ωt) Sin(ωt)

 (6)

This represents a reference vector of amplitude v rotating anticlockwise at angular frequency ω as seen in figure 4. The inverter cannot directly produce a vector which does not correspond to one of the six active states so the ideal trajectory mapped by the rotating vector, can only be achieved with a sinusoidal three phase source. The rotating vector however can be approximated, by sampling the vector, then switching between different inverter

Having computed necessary times to spend in the active and zero states, the switching signals can now be produced. There are various switching sequences that will result in the correct total time being spent in the required states. Minimum inverter switching frequency is obtained, if the transition from one switching state to another is made by switching a single switch only. It is also convenient to begin and end a switching cycle in a zero state. With this in mind the switching sequence shown in figure 5 was chosen. Two different pulse Fig. 4: Rotating space vector

states during the sampling period. This will produce an approximation of the sampled rotating space vector. By continuously sampling the rotating vector and high frequency switching, the output of the inverter will be a series of pulses that have a dominant fundamental sine-wave component, corresponding to the frequency of rotation of the vector. Instantaneously, the actual vectors produced are not the same as the desired vector, these instantaneous voltage deviations represent voltage harmonics. An arbitrary vector can be approximated by switching between the adjacent states and the zero states in some sequence. If we wish to produce the vector vm in figure 3, then it is necessary to spend more of the switching period in active state 2 than in active state 1. The required time t2 to spend in active state 2 is given by the fraction of v2 mapped by the decomposition of the required space vector vm onto the v2 axis, shown in figure 3 as vy . Therefore |vy | t2 = (7) T |v2 | and similarly t1 |vx | = (8) T |v1 | Now by applying trigonometric relationships to the lower diagram in figure 3 , the amplitude of vector vx and vy are obtained in terms of |vm | and θ. |vm | |vy | |v |  =  x  = Sin (θ) Sin 2π/3 Sin 2π/3 − θ

(9)

Based on the above equations, the required times to spend in each of the active and zero states are given by. T |vm | Sin (π/3 − θ) t1 = (10) |v1 | Sin (π/3) T |vm | Sin (θ) t2 = |v2 | Sin (π/3)

patterns are shown in the figure, for a rotating vector sampled in sector 3. It can be seen that the inverter starts and ends a switching period T , in the zero state. It then switches for the required length of time into state 3, then through state 4 to the other zero state. The reverse of this pattern is then selected to return the inverter to the starting zero state. It can also be seen by the shaded portions in figure 5, that as the reference vector moves towards sector 4, the inverter will spend less of the switching period in active state 3. For any vector, the required switching pattern can be determined by the sector in which the reference vector lies, the vector angle and vector magnitude. From this information the necessary time to spend in each active and zero state can be calculated based on equations 10, 11 and 12. Then based on the sector of operation, the necessary inverter switching pulses can be produced. III

(11)

the remaining time t0 in the switching period T is spent in the zero states according to. T = t1 + t 2 + to

Fig. 5: Pulse pattern

(12)

Simulation using standard Simulink blocks

A simulation of a space vector PWM pulse generator was constructed using Simulink. Some of the key issues which must be observed during the design of such a simulation are as follows.

Phase A Voltage (V)

600 400 200 0

−200 −400 −600 0

0.005

0.01

0.015

0.02

Time (s)

Fig. 6: Phase A output voltage showing PWM pulses

order Butterworth low pass filter, with a passband edge frequency of 1000Hz then voltage waveform shown in figure 7 results. The inverter simulation was then connected to a simulation of a 1.65MW induction machine and the simulation was run for 10s. The total time for the simulation to run was recorded and is shown in in the results section in table 1. As a result of the lengthy simulation time encountered when using this simulation method, a M–File S–Function approach for building the

600

Phase A Voltage (V)

• The required space vector should be sampled at an exact multiple of the switching period, T. • The switching pattern of the IGBT’s should be calculated only once, at the very start of a switching period, then stored for the duration of the switching period • The switch on and switch off times of the IGBT’s should correspond exactly with a simulation step time. With these guidelines in mind, the following simulation design was adopted. The rotating vector was constructed by transforming a three phase signal according to equation 2. This rotating vector was then sampled at a frequency 1/T . Based on the sampled space vector co-ordinates the magnitude, angle and sector were calculated. Using equations 10-12, the appropriate times to spend in each active state were calculated. Based on these times, the switch times for the next switching period were calculated. These switch times remain constant for the entire switching period. At each simulation step, the switch times are compared with the increasing time vector using the Simulink hit crossing block. The hit crossing block forces the simulation to locate a zero crossing by adjusting the simulation step-size. Once a hit occurs the actual switching pulses are produced using the switch and relay blocks. The switching pulses are supplied as inputs to an inverter simulation, a plot of one of the output phases from the inverter is shown in figure 6. If this signal is filtered using an 8th

400 200 0

−200 −400 −600 0

0.02

0.04

0.06

0.08

Time (s)

Fig. 7: Filtered Phase A output voltage

pulse generator was investigated. IV

M–File S–Function

M–File S–Functions are a way of writing customised blocks for Simulink. For two Simulink simulations performing the same calculations, an S–Function representation will display faster execution time than the same system built using Simulink blocks. A method for understanding the operation of an S–Function is to describe the system in terms of a discrete or continuous state space model. Take for example the discrete system. x (k + 1) = Ax (k) + Bu (k) where A and B can be constant or functions of the states or the inputs. One of the important routines in the execution of an M–File S–Function is the update routine. In this section of the S–Function, the user specifies the values of Ax (k) + Bu (k), the output of this calculation will then become the state vector, the next time the S–Function is called. The M–File S–Function also has a derivative routine where the continuous state vector update is calculated. This was unused in this simulation. In the output routine, the user specifies the outputs of the S–Function block. Termination and variable step-size routines are also included. The variable step-size routine was used in this simulation to specify the required simulation step-sizes. The M–File S–Function for a space vector modulated PWM pulse generator, was designed to operate in the same way as the Simulink block diagram implementation. At every integer multiple of the sampling period, the rotating vector input is sampled. The sector, angle and magnitude are determined and the switching times for the next switching period are calculated. These values are then stored in the discrete state vector. The next hit time for the simulation, is read from the discrete vector. As the simulation proceeds the vector containing the switching times shifts upwards, and the next hit time is successively updated with the next switch time. When the time vector in the

simulation is an integer multiple of the sampling time, the discrete vector is reloaded and the simulation continues. Each time the S–Function is called, the output routine is executed, during this routine the present simulation time and the precalculated switching times are compared. Using this timing information and the sector number which is also stored in the discrete state vector, the correct switching pulses are produced. It is very important to note the calling sequence for M–File S–Functions. The sequence as applicable to this simulation is shown in figure 8 The

• Speed improvement over m file S-Functions • Same functionality as m file S-Function • Has a work vector - memory • Has other features eg. - mdlstart The operation of a CMEX S–Function is similar in many ways to the M–File S–Function. The main differences can be seen by observing the calling sequence for a CMEX S–Function [7]. The calling sequence of the CMEX S–Function as applicable to this simulation appears in figure 9

Fig. 8: Calling sequence for M–File S–Function

Fig. 9: Simulation Flow Diagram

importance of the calling sequence can be seen if the first simulation step is examined. When the S–Function is first called the value of t in the time vector is zero, so it is necessary to sample the rotating vector and calculate the switch times. This is performed in the output section and from these calculations the next hit time is known. However, as seen in figure 8, the next hit time must be calculated before the output section. This problem was overcome by careful design of the simulation and initialisation of the state vector. The switching times could of course be calculated in the next hit time section, however the switch times must be stored and therefore calculation is made in the update section where the user can write to the state vector. The discrete state vector is the only form of memory in an M–File S–Function. By using the state vector, data can be passed from one simulation step to another. The M–File S–Function of the pulse generator was connected to the induction machine simulation and the simulation was run for a 10s time period. The results can be seen in table 1. Using the Ode23tb solver, a 100% improvement in simulation time was achieved. With view to further accelerating the simulation speed, a CMEX S–Function implementation was developed. V

CMEX S-Function

CMEX S–Functions offer the most advanced environment available for the programming of user defined Simulink blocks. Some features of a CMEX S–Function applicable to this simulation are

a)

Define Block Characteristics

The first routine of the S–Function mdlInitialiseSizes is used to define the Simulink block. Many parameters of the block are defined here including the number of continuous and discrete states. In this simulation no continuous or discrete states are used. The number of input and output ports, their respective widths and the work vector are also defined here. The work vector is an added tool incorporated in CMEX S–Functions which acts as a nonvolatile vector where data can be stored. The data can be recalled or amended during later simulation steps. This alleviates the need to pass data from one simulation step to the next with the discrete state vector. This simulation uses the work vector and it is defined in this section. b)

Define Sample Times

The variable sample time is defined in the mdlInitialiseSizes c)

Perform Additional Tasks

The next S-Function routine, mdlIStart is called once at the start of the simulation. In this simulation the mdlIStart routine is used to initialise data in the work vector, including the first hit time. d)

Calculate next Hit Time

With the Simulink block description and initialisations complete and a variable sample time chosen, the next simulation hit time must now be defined.

This is done in the mdlGetTimeOfNextVarHit routine where the next hit time is read from the previously initialised work vector. The value returned from the work vector will be the value of t in the time vector of the simulation, the next time the S–Function is called. e)

Output Section

The output routine is called at every simulation step and contains all the calculations for switch on and off times of the devices, this routine also defines the output of the S–Function block. The routine performs a check to see if the value of t is an integer multiple of the switching period. If this is the case then, the input vector is sampled and checked. The routine then calculates the sector in which the vector lies, and the vector angle, and the appropriate time to spend in each adjacent active state. Based on the present value of the time vector, the corresponding switching times for the switching period are calculated and loaded into the work vector, with the first switch time loaded at the top of the vector. If t is not an integer multiple of T , the input vector is not sampled and the work vector remains unchanged. f)

Output the pulses

Both the sector of operation and the switching times are stored in the work vector. Based on this information the position of the switches is known at each switch time over the whole switching period. Each time the output routine is called, a check is made to see if the next switch time (located at the top of the work vector) equals to the present value of t. If this is the case then the inverter switches in the predetermined fashion and the switching pattern is output. Once a switch has occurred, the work vector shifts up one place, the next switch time is loaded into the top of the work vector (to be read by the mdlGetTimeOfNextVarHit routine) and the simulation proceeds. The CMEX S–Function pulse generator was connected to the same inverter and induction machine simulation as was used for testing the Simulink and M–File S–Function implementations. The simulation times can be seen in table 1. When using the Ode23t solver a 200% improvement in simulation time is achieved compared to the standard Simulink simulation. VI

Results

Simulation times using the three developed simulations methods for the drive and motor are shown in table 1, three different stiff solvers where used and the simulation was run for 10s. It can be seen that in each case, the CMEX S–Function implementation, results in accelerated simulation speeds when compared to the Simulink and

M–File S–Functions implementations. For the Ode23t solver, the CMEX S–Function implementation was three times faster than the standard simulink implementation. Simulink M–File S–Function CMEX S–Function

Ode23tb 59min 31min 24min

Ode23t 59min 49min 18min

Ode23s 99min 69min 53min

Table 1: Simulation Results VII

Conclusions

This paper developed and compared three different methods of simulating a space vector PWM pulse generator using variable step-size simulations and Simulink. Three different methods were compared: i) standard Simulink implementation, ii) M–File S–Function implementation and iii) CMEX S–Function implementation. The CMEX S–Function version offered the most flexible programming environment and resulted in a 200% improvement simulation times. By using CMEX S–Functions and variable step-size simulations, systems comprising of fast switching dynamics and slow machine dynamics can be simulated in acceptable timeframes. With this capability studies such as power quality investigations for gird connected wind turbines, can be undertaken with confidence in the simulation accuracy. Acknowledgements The support from the Electricity Supply Board (ESB) is gratefully acknowledged. References [1] Werner Leonhard. Control of Electrical Drives. SpringerVerlag, New York, 1997. [2] Ying-Yu Tsai, Ming-Fa; Tzou. Transputer-based adaptive speed controller for AC induction motor drives with load torque estimation. IEEE Transactions on Industry Applications, 33(2):558–566, Mar-Apr 1997. [3] A Mullane, G Lightbody, R Yacamini, and S Grimes. Comparison of a cascade and feedback linearization scheme for DC link voltage control in a grid connected wind turbine. 36th Universities Power Enginering Conference, 12-24th September 2001. [4] R.Pena. Doubly fed induction generator using back-toback PWM converters and its application to variable speed wind energy generation. IEE Proc. Electr. Power Appl., 143(3):231–241, May 1996. [5] B.Dewan R. Wu. Analysis of an ac-to-dc voltage source converter using PWM with phase and amplitude control. IEEE Transactions on Industry Applications, 27(2):355– 363, 1991. [6] Yu Kazunori and Satoshi Ogasawara. Performance evaluations of a position-sensorless IPM motor drive system based on detection of current switching ripples. PESC, pages 873– 878, June 2000. [7] Mathworks. Writing S-Functions. The MathWorks Inc., 1998.

Alan Mullane is currently pursuing the Ph.D. degree in the Electrical and Electronic Engineering Department at University College Cork, Cork, Ireland. His primary areas of interests include control of WECS and electrical drives.

Suggest Documents