UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Digital control loop for power converter systems Duan, Yingran 1999

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-ubc_1999-0344.pdf [ 3.54MB ]
Metadata
JSON: 831-1.0064811.json
JSON-LD: 831-1.0064811-ld.json
RDF/XML (Pretty): 831-1.0064811-rdf.xml
RDF/JSON: 831-1.0064811-rdf.json
Turtle: 831-1.0064811-turtle.txt
N-Triples: 831-1.0064811-rdf-ntriples.txt
Original Record: 831-1.0064811-source.json
Full Text
831-1.0064811-fulltext.txt
Citation
831-1.0064811.ris

Full Text

Digital Control Loop Design for Power Converter Systems by Yingran Duan B.A.Sc, The Shanghai Jiao Tong University, 1993 A THESIS SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENTS OR THE DEGREE OF MASTER OF APPLIED SCIENCE TN ELECTRICAL ENGINEERING in THE FACULTY OF GRADUATE STUDIES (Department of Electrical and Computer Engineering) We accept this thesis as conforming to the required standar/i|  THE UNIVERSITY OF BRITISH COLUMBIA June 1999 © Yingran Duan, 1999  In presenting  this  degree at the  thesis  in partial fulfilment  University of  freely available for reference copying  of  department publication  this or  of  British Columbia, and study.  of this  his  or  her  requirements  I agree  that the  I further agree  thesis for scholarly purposes by  the  representatives.  may be It  thesis for financial gain shall not  is  that  t*J  The University of British Columbia Vancouver, Canada  Date  DE-6 (2/88)  Library shall make it  permission for extensive  granted by the understood  that  be allowed without  permission.  Department of b-befo-i  for an advanced  fi^^xd^^  head  of my  copying  or  my written  Abstract With the advance of microprocessors/DSP, digital control is increasingly used in various applications of switchmode power converter systems because of its advantages over analog control. The disadvantages, however, include limited signal resolution due to finite word length of processor and A/D converter; sampling time delay and limited computation power and control loop bandwidth. Adequate performance is difficult to realize by the current digital controllers with cost consideration. In order to achieve a good system performance, digital controller design becomes an important issue. Many digital design methods are available right now, and using different design methods results in different digital control performance. Choosing a better digital control design approach or method to improve the performance of the digital controlled power converter system is currently under consideration in this thesis. Digital controllers with different design methods are designed for a power inverter. A thorough and systematic evaluation on these methods is provided by comparing the performance of the digital controlled system. The performance of each approach is compared in terms of both the bandwidth and the phase margin of the control loop as well as the performance at nonlinear load condition. Furthermore, the difference of these design approaches under different sampling rates is studied. The best digital design approach for power converter system applications is identified based on the comparison results. Such a result is useful since, the control sampling rate can be several times lower than the converter switching frequency due to the limited computation power of low-cost processors. ii  A modified direct digital design method is proposed for practicing engineers who are mostly familiar with the continuous domain design approach. Some other issues related to digital control design for switchmode power converter system, including digital controller implementation and delay modelling are discussed as well.  iii  Table of Contents Abstract  ii  Table of Contents  iv  List of Figures  vi  List of Tables  viii  Acknowledgements  ix  1.  Introduction  1  1.1 1.2 1.3  1 3 5  2.  Digital Design Approaches 2.1 2.2 2.3  2.4  2.5  3.  4.  Introduction Modeling of the Digital Control Time Delay Digital Redesign Approach 2.3.1 Backward Euler Method 2.3.2 Bilinear Method 2.3.3 Pole/Zero Match Method 2.3.4 Step Invariant Method Direct Digital Design Approach 2.4.1 Frequency Response Method 2.4.2 Root Locus Method 2.4.3 Deadbeat Control Method 2.4.4 Modified Direct Digital Design Method Summary  7 7 7 9 11 14 17 19 21 22 24 25 27 31  Digital Controller Design for Single-Phase Power Inverter Systems  32  3.1 3.2 3.3 3.4 3.5  32 32 35 37 41  Introduction Switchmode Power Inverter Controllers Based on Digital Redesign Methods Controllers Based on the Modified Direct Digital Design Method Summary  Implementation of the Digital Controllers  43  4.1 4.2  43 44 45 45 48 50 51 51 53 55  4.3  4.4  5.  Background Digital Controller Designs Thesis Objective and Outline  Introduction Hardware Design 4.2.1 Power Stage 4.2.2 Current and Voltage Sensors 4.2.3 DSP Evaluation Board 4.2.4 PWM Generator Software Design 4.3.1 Numeric Representation and Calculation 4.3.2 Program Structure Summary  Simulation and Experiment Results  56  5.1 5.2  56 57  Introduction System Bandwidth Comparison  iv  5.3 5.4 5.5  6.  Nonlinear Load Performance Modeling of the digital controller delay Summary  Conclusions  75 77 79  81  Bibliography  83  Appendix A: Schematic of the DSP Controlled Power Inverter System  87  Appendix B: Controller Software of the DSP  90  V  List of Figures Fig. 1.1 Fig. 1.2 Fig. 2.1  A switchmode power converter system diagram Delay of the digital controller in switchmode power converter systems Bode plot of H (s), H (s) and H (s), assuming T = T  Fig. 2.2 Fig. 2.3 Fig. 2.4  Block diagram of (a) an analog system; (b) an analog system with time delay Mapping of Backward Euler transformation between s-plane and z-plane Comparison of the amplitude and phase angle difference in the continuous and  10 11  discrete domain for G(s)= - using the Backward Euler transformation  12  ZOH  c  delay  c  s  1 3 9  s  Fig. 2.5 Fig. 2.6 Fig. 2.7 Fig. 2.8  A digital controlled single-loop system Mapping of Bilinear transformation between s-plane and z-plane Comparison of the amplitude and phase angle difference in the continuous and discrete domain for G(s)= - using the Bilinear transformation  13 15 16  Comparison of the amplitude and phase angle difference in the continuous and discrete domain for G(s)= - using the Step Invariant transformation  20  s  Fig. 2.9 Fig. 2.10 Fig. 2.11 Fig. 2.12 Fig. 2.13 Fig. 2.14 Fig. Fig. Fig. Fig. Fig. Fig.  3.1 3.2 3.3 3.4 3.5 3.6  Fig. 3.7 Fig. 3.8 Fig. 4.1 Fig. 4.2 Fig. 4.3 Fig. 4.4 Fig. 4.5 Fig. 4.6 Fig. 4.7 Fig. 4.8 Fig. 5.1 Fig. 5.2  Discrete control system diagram 21 Relationship between co and v 23 Loci of constant damping ratio C and constant natural frequency a>„ of a second-order system 25 Discrete step response of the close-loop system using the frequency response method 29 Root locus plot of the digital control system designed by the root locus method 30 Discrete step response of the digital control system designed by the root locus method 31 Circuit diagram of a power inverter system 33 Double-loop analog PI controlled power inverter system 34 Double-loop digital controlled power inverter system 35 Double-loop control system diagram for digital redesign approach 36 Double-loop control system diagram for the direct digital design approach 38 Discrete step response of the output voltage of the double-loop system by the frequency response method 40 Root locus plot of (a) the current loop and (b) the voltage loop with the root locus method 42 Discrete step response of the output voltage of the double-loop system by the root locus method 42 Simplified schematic diagram of the inverter system 44 Inductance current sensing circuit 47 Output voltage sensing circuit 47 Simplified block diagram of the F240 DSP 49 PWM generation in DSP 50 Time diagram of one sampling period 52 Flowchart of the main program 53 Flowchart of the interrupt service routine 54 Double-loop digitally controlled system diagram 58 Test circuit for system loop bandwidth measurement 59  vi  Fig. Fig. Fig. Fig.  5.3 5.4 5.5 5.6  Fig. 5.7 Fig. 5.8 Fig. 5.9 Fig. Fig. Fig. Fig. Fig.  5.10 5.11 5.12 5.13 5.14  Current and voltage loop bandwidth measurement points Simulated Current loop Bode plot at the sampling rate of 10 kHz Simulated voltage loop Bode plot at the sampling rate of 10 kHz Current loop Bode plot provided by the system analyzer at the sampling rate of 10 kHz Voltage loop Bode plot provided by the system analyzer at the sampling rate of 10 kHz Current loop Bode plot provided by the system analyzer at the sampling rate of 20 kHz Voltage loop Bode plot provided by the system analyzer at the sampling rate of 20 kHz Simulated current loop Bode plot at the sampling rate of 40 kHz Simulated voltage loop Bode plot at the sampling rate of 40 kHz Nonlinear load for the inverter system Experimental nonlinear load output waveform Brief schematic of the power inverter model  59 60 61 62 63 67 68 72 73 75 76 78  vii  List of Tables Table 3.1. Table 4.1. Table 5.1. Table 5.2. Table 5.3. Table 5.4. Table 5.5. Table 5.6. Table 5.7. Table 5.8. Table 5.9. Table 5.10. Table 5.11. Table 5.12. Table 5.13. Table 5.14. Table 5.15. Table 5.16.  Digital controllers for current and voltage loops using different redesign methods at 20 kHz sampling rate Features of the TMS320F240 DSP Current and voltage controllers with different methods at 10 kHz sampling rate Simulated current loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Simulated voltage loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Measured current loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Measured voltage loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Current and voltage controllers with different methods at 20 kHz sampling rate Measured current loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Measured voltage loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Simulated current loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Simulated voltage loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Current and voltage controllers with different methods at 40 kHz sampling rate Simulated current loop bandwidth and phase margin with different digital controllers at 40 kHz sampling frequency Simulated loop voltage bandwidth and phase margin with different digital controllers at 40 kHz sampling frequency Total Harmonic Distortion comparison of the five design methods for the inverter system with nonlinear load at different sampling rate Current loop bandwidth and phase margin with different delay models at 20 kHz sampling frequency Voltage loop bandwidth with different delay models at 20 kHz sampling frequency  37 48 59 64 65 65 65 67 70 70 70 71 72 72 75 77 80 80  viii  Acknowledgements  First, I would like to give special thanks to Professor Hua Jin, my graduate supervisor at the University of British Columbia, who supported me throughout the project. This work would have not been completed without his helpful comments and advice. I also want to express my gratitude to all the students, faculty and staff in the Electrical and Computer Engineering Department of UBC, especially the power electronics group. Many thanks are to Anil Tuladhar, Stephane Bibian and Kenneth Wicks for the helpful discussions we had. I wish to acknowledge Statpower Technologies Corporation for providing experiment resources for this project; Mr. Tom Unger and Mr. Rob Cameron for their helps on the system setup. In addition, I would like to thank Dr. Li-Ming Wu who reviewed this manuscript and provided useful comments. Finally, I am grateful to my family and all my friends who have supported me for all these years.  Chapter 1 Introduction  1.1 Background The development o f switchmode power converter systems has been in constant demand for high performance power sources with smaller volume and lower cost. A switchmode power converter system normally consists o f power source, switches, output filters, sensors and control circuitry. F i g . 1.1 shows the diagram o f such a system. In practical design, E M I filters w i l l be included i n the input line and output line as well.  Power Source  Switch Network  to & o.> 1  Output Filter  7^ PWM Generator  Ti Controller  o U  Sensors  Reference  Fig. 1.1 A switchmode power converter system diagram Traditionally, analog control has been used in the power converter applications. Analog control is inexpensive and reliable, and it has infinite resolution with no control delays. The downside o f the analog control, however, is that analog component values can vary with the tolerance, and they can change subject to aging and working environment.  Furthermore, it is difficult to implement advanced control techniques and monitoring functions with analog controllers. The design of controllers using microprocessor/DSP is a changing and fast growing subject. It has been introduced to switchmode power converter system applications as well in recent years. Digital control has more flexibility in implementing advanced control algorithms. It can handle multiple functions and add "intelligence" features to the system. The control of the whole system can be implemented using only a few components, which makes the system very easy to handle. In addition, most digital controllers are reprogrammable, and modifications can be made by changing control programs. The working status is also very stable, and the environment condition has few effects on the performance of the digital controllers. Digital control, however, has a number of disadvantages. Thefirstmain disadvantage of digital control is the delay introduced to the system by the digital controller. The time delay comes from the fact that, in one sampling period, digital controller obtains input samples, finishes all the computation, and updates the control signal. In power converter systems, the control signal remains the same in one sampling period, and is updated at the beginning of the next period. Therefore, the delay of the digital controller is at least one sampling period. Fig. 1.2 shows the introduced delay. The second main disadvantage of digital control is the quantization error. Digital controllers can only deal with numbers in binary form, which must be represented by a binary word composed of a finite number of binary digits or bits. The limited word length in the representations of these numbers, therefore, introduces errors to some degree.  Carrier Signal Co"rripu7ation| Finished —A/D  1  Update Control  Update Control  Input to Output Delay  Fig. 1.2 Delay of the digital controller in switchmode power converter systems  1.2 Digital Controller Designs Because of the limited control loop performance, it becomes even more important to design the digital controller properly and achieve the best possible performance. The objective of this work, therefore, is to evaluate different digital control design approaches and identify the one that is best suited for power converter applications. Many digital design techniques have been proposed in recent years [8-18]. In general, all the design methods can be divided into two main approaches: digital redesign approach and direct digital design approach. In the digital redesign approach, the controller is designed first in the continuous domain, and discretized into the discrete form. In the direct digital design approach, on the other hand, the system plant in the continuous domain is first transformed into the z-domain, and the controller design is carried out directly in the z-domain.  Some efforts have been made in developing new techniques to realize optimal digital redesign from existing analog controllers. In [11], a redesign method is presented based on optimal matching the continuous time close-loop step response of both the analog and the discretized system. In [13], an extrapolation integration technique is applied in developing a discrete representation for integration and differentiation that is less dependent on the sampling interval. They all require extra calculation to obtain the digital controller from the analog one. A good match is accomplished by increasing the order of the digital controller, which also increases the amount of calculation of the digital controller. In direct digital design approach, a modified root locus method is proposed in [16], which uses the sampling period as a parameter in the root locus plot. This method is suitable only in the systems where the sampling period is a dominant factor of the stability. That is, the gain is set and the variable is the sampling rate in the root locus plot. Another robust controller is designed in [17], by minimizing the deviation of the frequency response of a perturbed plant at selected frequencies. The plant perturbations are generated by uncertainty in the coefficients of the plant transfer function. This method increases the robustness at some frequencies, but may result in decrease of the stability at other frequencies. Practical digital controller design, for switchmode power converter system, is required to be simple and effective. Some studies are focused on the traditional digital control design methods. In [1], comparisons on very commonly used digital redesign methods and direct digital methods have been made. In digital redesign methods, the Bilinear method and the Pole/Zero Match method are discussed. It is found that the performance of the digital controller using the Bilinear transformation method is much closer to  the analog controller than that of the Pole/Zero Match method. The root locus method in direct digital designs gives the best step response. The comparison is made only on the transient response of a single-loop system in this work. In [2], the Energy Resemblance Index (ERI) is introduced to compare three discretization methods. This ERI is mainly based on the pulse response difference between the analog system and discrete system. The results show that the Backward Euler method out-performs the Tustin (Bilinear) method, and the performance of the Step Invariant method varies in different systems. Similar comparisons of some other redesign approaches and direct digital approaches are presented in [3-5]. However, there is still a lack of thorough and systematic comparison of these methods. These studies, with the exception of [3], do not provide a quantitative comparison of the performance in terms of control loop bandwidth, load disturbance rejection among different discretization methods, and between the digital redesign approach and the direct digital approach. All these works, including [3], are focused on the single-loop system. It is unclear that how the controller performance will vary in a two-loop structure or under different sampling rates.  1.3 Thesis Objective and Outline The objective of this thesis is to identify the best approach for power converter applications among the selected methods, and implement the design in afixed-pointdigital controller. Specific objectives include: • To compare various transformation techniques in digital redesign approach. • To compare the direct digital design approach with various digital redesign methods.  • To develop a direct digital design method that is effective and easy to use in practical digital control designs. • To evaluate the effect of the sampling rate on the system performance. The thesis is organized as follows. Chapter 2 discusses the digital design approaches in detail. Digital controller design for a double-loop switchmode power inverter is described in Chapter 3. Chapter 4 is focused on the implementation of the digital controlled system. Comparison of different design methods and approaches are presented in Chapter 5, based on the simulation and experimental results. Conclusions and recommendations for future work are given in Chapter 6.  Chapter 2 Digital Design Approaches  2.1 Introduction In this chapter, different digital controller design approaches are described. First, the time delay in the digital control loop is studied and the model for the time delay is discussed. Second, digital redesign methods based on different transformations are presented. Finally, direct digital methods and the design procedure are provided.  2.2 Modeling of the Digital Control Time Delay The time lag introduced by the digital controller has to be taken into account during the controller design stage. In many industrial applications, only the delay due to the zero-order-hold (ZOH) of the A/D converter is considered in a digital control design. Relatively little attention has been paid to the effect of the computational delay in the digital controller. The computational delay includes the time needed to finish numerical calculation and for A/D and D/A conversions. In those applications, the system dynamics is not very fast and the computation time is negligible as compared to the sampling period. The effect of a zero-order-hold can be expressed as:  ~s T  ZOH^=  H  -^j—  X  s  >  (2-D  7  where T is the sampling period. The computational delay, on the other hand, can be $  described as:  H (s)=e' \  (2.2)  c  c  where T is the computation time. Unlike zero-order-hold, the delay H (s) has no effect £  c  on the magnitude of the plant but adds large phase lag to the system. The total delay in the digital system is, therefore,  -T s s  Fig. 2.1 shows the Bode plot of H (s), Z0H  T  _  T  H (s) and Hd i (s), c  e ay  assuming  = T . c  s  In power converter applications, however, computational delay must be included. This is because the computational delay is usually a significant portion of the sampling period. Also, in most of the cases, the new control variable is updated only at the beginning of the next period. There are different ways to model the delay. One way is to consider that the computational delay equals the sampling period. The delay will be -T s  1- e s  s  ~s  •e  T  s  •  •  . Another way is to consider the total delay to be equal to e  ~s T  s  . Three  models of this time delay were presented and compared in Chapter V. Results show that  g  the model of H  del  (s)= e  s  gives the best results, and this model will be used in the  remaining digital control designs in this project.  0.005  0.05  0.5  0.005  0.05  0.5  Frequency (pu), lunit equals £  Frequency (pu), lunit equals fj Fig. 2.1 Bode plot of H (s) ZQH  , H (s) c  and H {s), delay  assuming T  Q  -  T  s  2.3 Digital Redesign Approach The methodology of analog control design has been well developed over the last few decades. By extending it to the digital system, we have the so called digital redesign  approach. Digital redesign approach obtains digital controller by discretizing an analog controller. All the available transformation methods are approximate methods. Accuracy of the discretization depends on the sampling frequency. The fidelity and accuracy of the discretized expression are decreased when the sampling rate is reduced. Let the block diagram of an analog system be shown in Fig. 2.2(a), where H(s) is the plant transfer function and G(s) is the analog controller. The procedure to design a digital controller based on the redesign approach can be outlined as follows: (a) Include the time delay H (s) delay  in the analog system, as shown in Fig. 2.2(b),  and design the analog controller G(s) . (b) Discretize the analog controller G(s) into G(z) using one of the discretization methods. (c) Convert G(z) into a difference equation for implementation.  Fig. 2.2 Block diagram of (a) an analog system; (b) an analog system with time delay  There are several methods to discretize an analog function. In this section, four commonly used methods are discussed: Backward Euler, Bilinear, Pole/Zero Match and Step Invariant. 10  2.3.1 Backward Euler Method The Backward Euler method uses the Backward Euler transformation to discretize the analog control function. In this transformation, all derivatives are replaced by a first dx  ^n  ^ ft 1  order approximation. That is — =  , where x and x  at  , are the current and  1'  last samples, and T is the sampling time. The z-transform expression is:  1-z' s = - J -  1  •  (2-4)  Fig. 2.3 shows three typical points mapping from the s-plane to the z-plane. We can see the left side of the s-plane is mapping into the 0.5 radian circle with the center at 0.5 in the z-plane.  z-plane s-plane  <=>  Fig. 2.3 Mapping of Backward Euler transformation between s-plane and z-plane  This transformation does not preserve the frequency response. The distortion can be seen in the frequency domain by replacing s with /co, and z with e  . If we use the  integrator G(s)= - as an example, the difference of the frequency response between the s  s-domain and z-domain is shown in Fig. 2.4.  0.005  0.05  Frequency (pu), lunit equals f.  0.005  0.05  Frequency (pu), lunit equals f,  Fig. 2.4 Comparison of the amplitude and phase angle difference in the continuous and discrete domain for G(s)  =  - using the Backward Euler transformation  s  The upper plot shows that the Backward Euler method has relatively higher gain and phase lead than the analog one. When the frequency approaches the Nyquist frequency (1/2 sampling frequency), the phase difference can reach up to 90°. Although the Backward Euler method is not a very accurate transformation method because of the magnitude and phase difference with the analog counterpart in the high frequency, the higher  12  amplitude will provide a wider bandwidth, and the phase lead will contribute to the increase of the system phase margin. To illustrate the procedure of the digital controller design, a simple single-loop system as shown in Fig. 2.5 is used as an example.  Digital Controller ref,  Y  H's)  Holder  Sample  Fig. 2.5 A digital controlled single-loop system  The system is based on the inner current loop of the power inverter which will be discussed in Chapter III. The transfer function of the plant is:  1.58e 5+1  = 12  H's)  (2.5)  1.27e V + 8.48e *s+ 16.3 The sample frequency of the digital controller is 20 kHz, and the delay of the digital controller is modeled by one sample T delay. Equation (2.6) is the linear approxima-  2  x  XX  1+*  3  tion of the delay function, where e =1 + x + — + — + 2! 3!  -Se s S  delay^  H  =  ^ -Se s + 2  has been used. 1 -'  5  e  (2.6)  5e~ s + 2 5  13  With the delay function included in the system, we can design the analog controller using the Bode plot method. Assuming a gain-cross-over frequency of 2.88 kHz and a phase margin 50°, the analog controller, in the PI structure, is obtained as:  0.8(9.26e s + I) 1. 9.26e s  G(s)= — i s  (2.7)  Substituting equation (2.4) into equation (2.7), we have the digital controller using the Backward Euler transformation method as:  G(z)= 0-852(z-0.950) z-l In difference equation form, equation (2.8) becomes: u(t) = 0.852e(t)-0.S04e(t-T ) s  + u(t-T ). s  (2.9)  2.3.2 Bilinear Method The Bilinear method uses the Bilinear transformation to discretize an analog controller function. The Bilinear transformation is also called Tustin transformation or trapezoid integration method. In this transformation, all derivatives are replaced by a first order 2 •*"/ ~ i- l approximation: — = — • . The z-transform expression is: dx dt  x  T  s  x + x_ i  i  l  2  1-z"  s  l+z  J  1  14  Fig. 2.6 shows the three typical points mapping from the s-plane to the z-plane. From this, we can see that the left side of the s-plane is mapping into the unit circle in the z-plane.  Fig. 2.6 Mapping of Bilinear transformation between s-plane and z-plane  This transformation does not preserve the frequency response either. If we use the integrator G(s)= - as an example, the difference of the frequency response between the s  s-domain and the z-domain is shown in Fig. 2.7. From the plot, the amplitude of the integration after Bilinear transformation drops to 0 at Nyquist frequency, although the phase plot matches very well to the analog one. The Bilinear transformation is an accurate transformation method at frequency up to 1/5 of the Nyquist frequency. In the high frequency range, since the amplitude drops quickly, the system bandwidth will be limited.  0.005  0.05  0.5  Frequency (pu), lunit equals f  s  0.005  0.05  0.5  Frequency (pu), lunit equals f  s  Fig. 2.7 Comparison of the amplitude and phase angle difference in the continuous and discrete domain for G(s)= - using the Bilinear transformation  S  The design procedure of the digital controller is the same as for the Backward Euler method, except that the transformation method is different. Taking the system in Fig. 2.5 as an example, we have the digital controller as:  G(z)= Q-830(z-0.947) z-1  ?  (2.11)  when the analog controller in equation (2.7) and the Bilinear transformation defined in equation (2.10) are used. The difference equation of the controller is then:  16  u(t) = 0.830e(t)-0J86e(t-T ) + s  u(t-T ). s  (2.12)  2.3.3 Pole/Zero Match Method The Pole/Zero Match method uses the Pole/Zero Match transformation to discretize the analog control function. The Pole/Zero Match transformation maps poles and zeros of the analog function from the s-plane to poles and zeros in the z-plane. Typical transformations are as follows:  (2.13)  <s + a±jb)o(l+2z  e ° cos(bT ) + z e  l  s  2  s  (2.14)  This transform maps the left side of the s-plane into the unit circle as well, as shown in Fig. 2.6. The Pole/Zero Match method requires the number of poles to equal the number of zeros. If the number of poles of the analog function is larger than the number of zeros, artificial zeros of -1 are added in the digital function. The gain of the z-domain function is different from that of the analog function, using the transformations in (2.13) and (2.14). It should be scaled to be equal to the gain of the analog function. The difference of the frequency response for G(s)= - with this transformation is the same as the s  Bilinear method, as shown in Fig. 2.7. The reason for the similarity is that the pole of the integrator is equal to 0, which is a very special case. For a more general case like 1 ~ s + a Pole/Zero Match represents the pole a as e G(s)= s——, , while using Bilinear transaT  17  s  aT  1— s  formation it becomes  2  aT. 2  , which is a linear approximation of function e~  a  r s  s  . The  difference between them is small when the aT is small. But the difference can be signifi$  cant when the sampling period T or parameter a is large. Since G(s)= —— is a lows+a 1 - e~  aTs  pass filter, a scaling factor of  is used to make the gain of the discrete function 2a  equal to that of the analog function at lowband. The Bilinear transformation of T  G(s)=  has a gain of s+a  — , which is very close to the gain of the Pole/Zero 2 + aT  s  Match transformation when sampling period T and parameter a are small. The difference will increase when either T or a becomes large. s  The digital controller discretized from the analog controller, equation (2.7), with Pole/Zero Match method is: G(z)= ° -  8 3 0  ^-, z-1 0  9 4 7  >  .  (2.15)  The Pole/Zero Match method and the Bilinear method are so similar that the parameters of the digital controllers from these two methods are the same to the third digit of decimal point.  18  2.3.4 Step Invariant Method Step Invariant method uses the Step Invariant transformation to discretize an analog controller function. Step Invariant transformation is the Impulse Invariant transformation with addition of an artificial zero-order-hold. The Impulse Invariant approximation is accomplished by making a unit pulse response sequence of the digital function proportional to samples of a continuous time pulse response function. The major problem encountered in this transformation is that high frequencies are folded into the desired bandwidth. It maps only the poles of the analog filter to digital filter, as shown in Fig. 2.6. The zeros may remain outside of the unit circle in the z-plane. To solve this basing problem, a low-pass filter should be used in cascade with the analog function. The Step Invariant transformation uses a zero-order-hold as the low-pass filter. The transformation is then expressed as:  r H(z) = Z  -s T  1  v  6  s  \  s  H(s)  (2.16)  This transformation preserves the step response of the analog function, but the frequency response is distorted. The difference of the frequency response for the integrator function G(s)= - in the s-domain and z-domain is shown in Fig. 2.8. s  From the Bode plot in Fig. 2.8, we can see that the transformation introduces a large phase lag to the controller, which reaches 90° at the Nyquist frequency. The amplitude increases with frequency, similar to the Backward Euler, which compensates the phase lag a bit.  19  The digital controller discretized from the analog controller equation (2.7) with the Step Invariant method is:  G ( z ) =  0.808(z-0.946) z-l  (2.17)  The difference equation of the controller is: u(t) = 0.80Se(t)-0.764e(t-T ) s  0.005  +  u(t-T ). s  (2.18)  0.05  Frequency (pu), lunit equals f.  0.005  0.05  Frequency (pu), lunit equals f,  Fig. 2.8 Comparison of the amplitude and phase angle difference in the continuous and discrete domain for G(s)= - using the Step Invariant transformation  s  20  2.4 Direct Digital Design Approach Besides the digital redesign approach, the other design approach in digital control is called direct digital design approach. The controlled plant in this approach is represented by a discrete model. A continuous plant H(s) should first be transformed into the discrete domain, as illustrated in Fig. 2.9.  H(z) G(z)  W  Lag  H's)  Fig. 2.9 Discrete control system diagram  The methods of direct digital design assume that the compensation network is in the discrete domain. The functions in z-domain only show the relationship of sample intervals, but not the sampling rate. Theoretically, the behavior of the close-loop system is not dependent on the initial choice of the sampling frequencies. This can be contrasted with digital redesign approach, where an increasing of sampling interval changes the dynamics and may lead to destabilization of the close-loop system. Therefore, direct digital design methods are sometimes called exact methods. Obviously, the exactness is valid only in the linear domain and at the sampling points. Saturation of the controller in practical systems and inter-sample behavior, which are not detected by z-transfer analysis, will degrade the performance if a reasonable sampling rate is not chosen. The procedure of the direct digital design approach can be outlined as follows:  21  (a) Discretize the continuous plant into z-domain using Step Invariant transformation. Time delay is included through the transformation. (b) Design a digital controller in the z-domain using one of the direct digital design methods. (c) Convert the digital controller into a difference equation for implementation. There are several direct digital design methods available, and three commonly used methods are discussed in this work. Based on the features of these methods, a modified method is proposed.  2.4.1 Frequency Response Method The frequency response method uses the same technique as the continuous design method in the frequency domain. The same concepts of gain-cross-over frequency and gain/phase margin can still be used. The difference is that the discrete plant transfer function has to be converted to the w-plane by z = *  +  w  , which is in a form of bilinear trans-  1-w formation. It transforms the unit circle in the z-domain to the left-hand-side of the wplane, which has the similar feature as the s-domain. A practical transformation method was proposed by Whiter Back and Hofmann [32] which scaled the transformation with a 9  factor of T /2, that is, w' = —w. The major benefit is that w'-plane has not only a geos  metrical resemblance to the s-plane, but the actual quantities are also similar, which is, W approaches s when the sampling period T approaches 0. This property is useful as it helps to reduce the numerical error through the design process and give better insight to  22  the system. Therefore, the w'-plane, also called as w-plane, is normally used in the digital frequency response method. As mentioned in the section 2.3.2, a bilinear transformation distorts the frequency  7l/2T  s  tt/T  s  co (rad/sec)  Fig. 2.10 Relationship between CO and v  Therefore, v «co is true only at frequency much lower than the sampling frequency. There is a basic difference between the Bode plots of a continuous system and the corresponding system sampled and transformed from the s-plane to the z-plant, and eventually to the w-plane. The w-plane transfer function usually has the same number of poles as zeros. When the number of poles is higher than that of the zeros, additional zeros are  23  added to make them equal in the w-plane. In transforming G(z) = K G'(z) z  G(w) = K G'(w) w  K  w  , the value of the gain K  w  to  can be positive or negative. The sign of  is determined by the coefficient of G(z) which in turn is a function of T. Conse-  quently, the amplitude response of the G(w) can converge to a value totally away from the original G(s) in continuous system. Due to these features, the sampling frequency is required to be much higher than the desired bandwidth to have a satisfactory design. Usually a sampling frequency of 10 times higher than the bandwidth is recommended.  2.4.2 Root Locus Method Root locus is a plot of the roots of the control system characteristic equation as a function of the gain constant. The underlying principle is that the close-loop poles which mainly decide the system characteristics are related to the zeros and poles of the open-loop function and the gain. From the root locus plot, it is easy tofindthe trend of the close-loop poles when the parameters of the controller are changing.  Since the z-plane is the mapping of the s-plane by means of z = e  . The fea-  tures of the poles and zeros in the s-plane can be applied to the z-plane. Fig. 2.11 is the plot of the z-plane loci of a constant damping ratio £\, and natural frequency co for a secw  2  2  ond-order system, with the characteristic expression of s + 2t,Gi s + a> . The concept of n  n  the damping ratio and natural frequency in discrete system is similar to the analog system.  24  t=0  C=0.2 0=0.4  Real Fig. 2.11 Loci of constant damping ratio L\ and constant natural frequency (& of a second-order n  system  The root locus method is a direct way of designing the digital controller. However the transient behavior and the frequency response are strongly influenced by the location of the zeros as well. For this reason, the zeros, poles and the gain of the controller need to be selected properly.  2.4.3 Deadbeat Control Method Deadbeat control is a control technique developed for sampled data control systems. The method is based on the formulation of the desired behavior of the plant and gives an algebraic solution for the controller. The output of the system is forced to move to the expected value after a finite number of intervals. To illustrate the concept, the close-loop transfer function of a single-input-singleoutput system can be expressed as  G(z)H(z)  5  where H(z) is the discrete transfer  1 + G(z)H(z)  25  function plant, and G(z) is the digital controller. If the desired close-loop function is K(z), the controller can be obtained by solving the equation G(z) = —— • H(z)  . It  1 - K(z)  should be noted that, when choosing K(z), unstable zeros or poles in the plant should not be compensated by cancelling the original zeros or poles through placing additional poles or zeros at the same locations. This is because it is unrealizable to locate an unstable compensation pole exactly on the right place and to keep it there practically. Any errors can make the system diverge and cause instability. Deadbeat control requires K(z) to be a polynomial in z . For example, if we 1  wish a second-order system to settle to the desired value after two sample intervals, we can set  l_K(z) = ( l - z - y , ( z )  (2.19)  to obtain a zero steady state error to a step input. We can also set K(z) = Numerator of the plant transfer function • F (z) 2  (2.20)  to avoid cancellation of the zeros of H(z). Function F, (z) and F (z) are user defined 2  polynomials. In order to realize the deadbeat control after two sample intervals, Fj (z), F (z) and K(z) can be in the following forms: 2  -2  Fj(z) =  CqZ  -1 + C j Z  +c , 2  (2.21)  26  F (z) = d z 2  2  Q  K(z) = e z Q  + dz x  +gjZ  1  (2.22)  + d•2>  + ez 2  +e . 3  (2.23)  Using the definition of Fj(z), F (z) and iC(z), one can solve equation (2.19) and 2  (2.20) for K(z) and D(z). In some cases, the number of equations can be less than the number of parameters. To have a solution for these systems, some of the parameters must be set initially. Iterations with different initial values and digital simulation are needed to obtain the optimum design. The procedure of this method is straightforward, although more calculation is needed during the design stage. However, the final performance of the resulting controller may not work well as expected. There are two main reasons. First, the controller design is heavily dependent on the system transfer function. However, the transfer function, which normally only reflects the main dynamics of the system, can not fully represent the system. Furthermore, the system dynamics may be subject to change at different working conditions. Another reason is that deadbeat control usually requires a large control signal which in general can not be implemented in real applications. Therefore, the advantage of this control technique is hard to realize in practical applications.  2.4.4 Modified Direct Digital Design Method As discussed previously, the frequency response method needs additional transformation from the z-domain to the w-domain in order to complete the final design. The approximation in the transformation makes it difficult to achieve optimal design. It is nev-  27  ertheless a intuitive method and very easy to use. The root locus method is a real direct design method. No further transformation that may introduce inaccuracy is needed. The main disadvantage of this method, however, is that the relationship of the poles and zeros in the z-plane is not directly related to the system performance, and the tuning of parameters can be time-consuming. A modified design method is proposed that combines the advantages of the frequency response method and the root locus method. The method proceeds as follows: first, an initial design using the frequency response method is obtained, then the root locus and digital simulation are used to fine tune the controller. In this way, a few iterations will be sufficient to achieve a good digital controller design. The following example with the system shown in Fig. 2.5 illustrates the modified design procedure. The discrete transfer function of the plant can be obtained by discretizing the sdomain plant transfer function with time delay. The corresponding digital transfer function is:  H(z) =  0.71z-0.51 . z - 1.45z + 0.72  (2.24)  2  The sampling frequency is 20 kHz in this case. There is one sampling period delay between the plant input and output from the difference equation of H(z) ;  y(t) = 0.7\e(t-T )-0.5\e(t-2T )+\A5y(t-T )-0.72y(t-2T ). s  s  s  s  (2.25)  The digital controller design starts with the digital frequency response method. The discrete transfer function H(z) in equation (2.24) is converted to the w-plane:  28  „ , , = -0.39w +1.29e w + 9.9e H(w) —. 2  4  w +  s  3  z-1  where w = — • T  n  7.\8e w+\.34e  2  2  ~~ (2.26)  7  has been used. z+1  A digital controller is designed in the w-plane with a control loop bandwidth of 2.8 kHz and a phase margin of 60° :  G(w) =  0.63(1 + 1 . 4 1 ^ ) — . 1.41e w  (2.27)  The z-plane expression of this controller is: G(z) = Q  ~°z-1  7 5 z  5 2  .  (2.28)  The step response of the close-loop system is shown in Fig. 2.12.  1.0  0.2 -  0  U 0  . 10  1 20  .  .  .  30  40  50  60  Time (samples) Fig. 2.12 Discrete step response of the close-loop system using the frequency response method  29  Next, the root locus method will be used to fine tune the controller. If the controller is expressed in the form of K • , there will be two parameters in the digital controller z-1 to be tuned: K, the gain and a, the zero of the controller. As we can see from the step response in Fig. 2.12, it takes several sample intervals to reach the first peak value, and around 60 steps to get settled at the steady state value. Therefore, the gain can be higher and the zero of the controller can be adjusted to make the close-loop poles closer to the origin. After a few iterations, one can finalize the digital controller as:  G(z) =  L 4 z  ~°z-1  9 1  .  (2.29)  The difference equation of the controller is: u(t) = \A0e(t)-0.9\e(t-T )  + u(t-T ).  s  s  (2.30)  The root locus plot is shown in Fig. 2.13, and the step response is shown in Fig. 2.14.  0.8 0.6 0.4  1  1i  1  i  1 z-plane  X Poles O Zeros  0.2  to (~Y~) v «V  TO £  0.2 -0.4 •0.6 -0.8 -1 -1  -0.5  0  0.5  Real  1  1.5  2  Fig. 2.13 Root locus plot of the digital control system designed by the root locus method  30  o LJ 0  ,  5  ,  10  ,  15  ,  20  ,  25  _J  30  Time (samples)  Fig. 2.14 Discrete step response of the digital control system designed by the root locus method  2.5 Summary In this chapter, two different digital controller design approaches and their design procedures are described and analyzed in theory. In digital redesign methods, features of four transformation methods are discussed, especially in their frequency responses. Three commonly used direct digital design methods are analyzed as well. Based on the characteristics of these methods, a modified direct digital design method which is more suitable for practical applications is proposed. A simple design example is provided for each design method to clarify the design procedure. The five digital design methods: four digital redesign methods and one modified direct digital design method, will be used in a power inverter controller design in the next chapter.  31  Chapter 3 Digital Controller Design for Single-Phase Power Inverter Systems  3.1 Introduction In this chapter, the digital design methods discussed in the Chapter 2 will be applied to the controller design of a signal-phase inverter system. Section 3.2 presents the model of the inverter system first, and then describes the control structure of that system. As mentioned in Chapter 2, we have discussed two different digital design approaches and five different methods. Digital controller design using these methods for the inverter system will be described in details in section 3.3 and 3.4. In order to evaluate which method is better for inverter application, and to test the effect of different sampling frequency on the inverter performance, three different sample frequencies are selected: f = 40kHz, f = 20kHz, and f = \0kHz. To avoid duplication, only f = 20kHz is discussed in s  s  this chapter.  3.2 Switchmode Power Inverter In this project, digital controller design and implementation practice will be applied to a PWM single-phase inverter system. Fig. 3.1 shows the circuit diagram of the system.  The inverter uses full bridge topology which consists of four switches. The inductance and capacitor after the switches act as low-pass filter to filter out the high switching frequency. Bipolar PWM scheme is used to turn on and turn off switches. During each conduction cycle, either the upper left (Tl) and the lower right (T2) switches or the upper right (T3) and lower left (T4) switches are turned on. To avoid conduction of switches on one-leg of the full bridge inverter, dead times are added in the gating signals.  J  (Dv,dc  T3  Tl  C t  pT2  JI&T4  Switch driver 1 Switch driver 2 Fig. 3.1 Circuit diagram of a power inverter system  The relationship of the inductance current to the duty ratio d is [33]:  ¥ a  i(*) =  H  5  —  —  =  (3.1)  R CLs +(R R C + L)s + R + R Q  L  0  0  L  where R is the load of the inverter, M is the modulation index of the sinusoidal PWM, and R is the ESR of the inductor L. The relationship of the output voltage to the duty L  ratio d is:  33  M-V .R dc  7"  H  (  s  )  R CLs o  +(R R C L  0  Q  (3.2) + L)s + R + R 0  L  The relationship of the output voltage to the inductance current is: (3.3)  The double-loop structure, as shown in Fig. 3.2, is used for inverter control. The inner loop controls the inductance current, while the outer loop controls the output voltage. PI controllers are used for both the current loop and the voltage loop.  Double-loop PI Controller Fig. 3.2 Double-loop analog PI controlled power inverter system  The objective of this thesis is to replace the analog controller with the digital controller, implemented in a microprocessor or DSP. The DSP which used in this project, has the function of PWM embedded with deadtime feature. Detailed implementation issues of  34  the DSP will be discussed in Chapter 4. Fig. 3.3 is the block diagram of the DSP controlled inverter system. Digital PI controllers are used in the design.  ±)V  VSI  dc  TC  P W M Generator i A/D DSP *~  o U  Ro  V  A/D  'act  5  Reference Fig. 3.3 Double-loop digital controlled power inverter system  3.3 Controllers Based on Digital Redesign Methods The power inverter we used in this research has the following system parameters: V  dc  = 200V, R = 0.3Q, L = 800p#, C = 9.9pF. L  The nominal output voltage of the inverter is 120 VAC, the modulation index is assigned as 0.6, and the load R is set to 16Q. Substituting these values into equation (3.1) and equation (3.3), we obtain H;(s) and H~ (s) as follows: v  H (s) = 120 t  }f  e  -4S+  ]  , 1.27e V + 8.48e 5+16.3  (3.4)  35  The continuous double-loop control system diagram with the time delay is shown in Fig. 3.4.  Vo.ref,  Current Controller  Voltage Controller  V, o  •(  Kv Fig. 3.4 Double-loop control system diagram for digital redesign approach  K and K are the gains of the current sensor and voltage sensor. In this study, t  v  K = 0.1, and K = 0.013 have been used respectively. The current loop design using t  y  digital redesign methods have been done in the last chapter, as seen in equations (2.8), (2.11), (2.15) and (2.17). The outer voltage loop transfer function is the product of the current close-loop transfer function and H (s). The voltage loop controller is designed by y  using Bode plot as well. The analog PI controller with a bandwidth of 0.9 kHz and a phase margin of 50° is given by:  0.12(1.56^+1) G  c v ^  is  =  l.56e  •  (3-6>  s  36  Using the transformation methods discussed in section 2.3, the corresponding digital controllers for the voltage loop can be obtained. Table 3.1 lists the current and voltage controllers with different redesign methods. Simulation and experiment results on the inverter system with different digital controllers will be presented in Chapter 5.  Table 3.1. Digital controllers for current and voltage loops using different redesign methods at 20 kHz sampling rate Methods  Current Loop controller n  Backward Euler  (  0.852z- 0.809 z-1  Cl  f v  n  Bilinear  Cl  n  Pole/Zero Match  (  v  Cl  , ,  n  Step Invariant  v  G  «  ( 2 )  Voltage loop controller r G  0.830z-0.786 z-1  n G  0.830z-0.786 z-1  x  (  -  (  Z  )  _  , x 0.294z + 0.068 " z-1 (  Z  )  G V  = °-  CV  0.808z-0.764 " z-1  0.475z-0.113 z-1  G c v ( z )  =  3 7 7 z  - 0  0 1 5  0.113z 0.249 +  3.4 Controllers Based on Direct Digital Design Method Fig. 3.5 shows the block diagram of the direct digital design method. In this method, the continuous plant transfer functions H~ (s) and H (s) are discretized first. The t  transfer function H^s) is discretized as:  m  .  7.07,-5.11  t  ( 3 ? )  z -1.45z + 0.72  37  with the sampling frequency of 20 kHz. Unlike the H (s), {  directly from H (s), y  H (z) v  is not discretized  because one sample delay from inductance current to the output volt-  age will produce total delay of two-sample period. Since we know the relationship of output voltage and the duty ratio as:  <  a{  \21e V + 8.48e $+16.3  s)  by discretizing this function, we have:  = ^1= V  H  (  Z  )  d  ^  16.55Z+ 14.79  (  3  9  )  z -1.45z + 0.72 2  The discrete function H (z) is then obtained by f ^ f ^ , or v  = 2.34Z + 2.09  o,re^_  V  Voltage Controller  (  Current Controller  3  1  0  )  "o  H,(z)  Kv  Fig. 3.5 Double-loop control system diagram for the direct digital design approach  38  The w-plane transfer function of H (z) is: (  „  (  H (w)  ,  t  -3.85w + 1.29ew + 9.9e 2  =  5  8  —  m  .  n  (5.11)  w + 7.18e w+ l.34e  The function H (w) is not obtained from transformation of H (z), v  v  but rather  from the multiplication of the inner close-loop function T (z) and H (z), {  H'(z)  =  or  v  T (z)-H (z). t  v  The digital controller is then designed in the w-plane with a bandwidth of 2.8 kHz and a phase margin of 60° for the current loop; and a bandwidth of 0.9 kHz and a phase margin of 60° for the voltage loop. The current and voltage controllers are:  0.63(1 +  G (w)  \A\e~\)  ci  ,  (3.12)  1.41e w  „  , ,  0.52(1 +9.66e w)  ...  5  9.66e w After transformation, the z-plane expressions of equation (3.12) and (3.13) are:  0^^052 ^ z-1  01  G  (  w  W  _ 06^039  (  3  1  4  )  ( 31 5 )  The step response of this double-loop system is shown in Fig. 3.6. 39  20 10 0 LJ 0  ,  5  ,  ,  ,  ,  10  15  20  _ J  25  ,  ,  .  30  35  40  Time (samples) Fig. 3.6 Discrete step response of the output voltage of the double-loop system by the frequency response method  To proceed with the direct digital design method, the root locus method is used to fine tune the controller parameters. Since the controller has a double-loop structure, the current loop poles and zeros placement will also affect the voltage loop design. As we can see from Fig. 3.6, the output takes several sample intervals to reach the peak value and even longer to get to the steady state. This means that the gains of the current and voltage controllers can be further increased, and the zeros of the current and voltage controllers need to be adjusted to make the close-loop poles closer to the origin of the z-plane. Since the gain and the zero position of the current controller will affect the positions of the voltage loop poles, attention should be paid to the voltage loop pole/zero movement, when making parameter changes on the current loop controller. There are usually several poles in the voltage loop on the z-plane, as seen in Fig. 3.7. Dominant poles which are closer to the unit circle on the right side of the plane deserve more attention. In the current loop root locus, the zero of the controller has been moved closer to the pole at point 1, the influence  40  of this pole/zero pair on the system is very small. The response speed of the current loop will increase, when the gain of the current controller is adjusted to make the two dominant poles "a" and "b" closer to the origin. One of the voltage loop root loci shows the tendency of going directly to the outside of the unit circle. Moving the zero of the voltage controller to the origin will slow the tendency. The gain of the voltage controller is also modified to finalize the positions of the dominate poles "c" and "d". After a few iterations, we obtain current and voltage controllers as:  G (z) ci C l  G (z) cv  = 1 ^ 1 3 2 ,  z-l  =  0-^-0-13  (3.16)  (3.17)  The root locus plot of the system is shown in Fig. 3.7, while the step response is depicted in Fig. 3.8. As compared to Fig. 3.6, the step response in Fig. 3.8 shows that the controller performance has been improved in terms of response time and overshoot magnitude.  3.5 Summary In this chapter, a real PWM single-phase inverter system was introduced. Different digital design methods discussed in chapter 2 are used to control a single-phase inverter system. The current and voltage loop controllers we derived in this chapter will be implemented in a DSP controller which will be discussed in the next chapter. The simulation and experiment on the digital controlled inverter system will be performed in Chapter 5.  41  1 0.8  X Poles  0.6  O Zeros  z-plane  0.4  )2  ,- . I. Pc a  60 03  0  K:  —(  m  ?\  o  \J7  -  3.2  -0.4  -0  6  -0  -1  Real fa) 1.5  X Poles  z-plane  O Zeros • .5  4> DO  s  -0.5  Fig. 3.7 Root locus plot of (a) the current loop and (b) the voltage loop with the root locus method  90 80 70 60 50 40 30 20 10 0  0  5  10  15  20  25  30  35  40  Time (samples) Fig. 3.8 Discrete step response of the output voltage of the double-loop system by the root locus method 42  Chapter 4 Implementation of the Digital Controllers  4.1 Introduction A good control algorithm is only thefirststep towards a satisfactory digital controlled system. A lot of effort must be made in order to achieve appropriate implementation of the numerical algorithm. Using a fixed-point finite word length DSP, for example, various arithmetic errors can be encountered which may cause system degradation. Basically, arithmetic errors can be classified into three types. One is errors from analog-to-digital or digital-to-analog conversion where an analog signal is represented by a finite length binary word. These errors, also called as quantization errors, can be handled as random "noise". The second are multiplication errors, where the product of two finitelength binary words must be represented by another word of the same length. These errors can be treated as random "white" noise as well. The last category of errors is the parameter errors in which control algorithm coefficients must be truncated and stored as finite-length words. Since pole location and frequency response of controller are very sensitive to the variation of coefficient values in the transfer function, the parameter errors therefore can cause significant alterations in the system dynamic behavior. No matter what kind of digital control algorithm is used, these three errors always exist in the system and must be carefully handled in order to obtain a satisfactory controller performance.  43  In this chapter, a DSP-based power inverter is implemented. The hardware components of the inverter such as power stage, current and voltage sensors, signal condition components, PWM signal and power supplies are discussed in section 4.2, while the software implementation is described in section 4.3.  4.2 Hardware Design In this section, a power system consisting of an inverter and a TMS320F240 DSP control board is constructed. Fig. 4.1 shows the simplified schematic diagram of the power system. A complete circuit schematic is shown in Appendix A.  LI wnr r  YA/vVrr  IGBT  + ACin  Ei  'C6  C4  Cc  ACout  C5 Cl  ri Optocoupler —  H  r ^AA/vn lurm Lm Y V  L2  linrw  1  Optocoupler  Current Signal Conditioning  Voltage Signal Conditioning  Optocoupler Optocoupler PWM1 PWM2  ADCIN6  ADCIN14  DSP TMS320F240  Fig. 4.1 Simplified schematic diagram of the inverter system  The power system consists offivedifferent parts: DC power supply, single-phase power inverter, switch driver circuit, current and voltage sensor, and the DSP board. They are described as follows. 44  4.2.1 Power Stage The input DC power source of the inverter is a simple AC to DC diode bridge. In order to provide a low ripple DC source to the inverter, a capacitor of \QmF is used. Due to its large size, this bulky capacitor can not be placed very close to the hardware circuit. In order to suppress the switching spikes produced by the parasitic inductance of the long connection wires, another three small capacitors of 650pF are placed just before the switching network. The power stage of the inverter is based on the commercial product of a 1.8 kW inverter from Statpower Technologies Corporation. To minimize the ESR, three output capacitors of the inverter are placed in parallel with an equivalent of 9.9 pi . IGBTs (Insu7  lated Gate Bipolar Transistor) IRG4PC40UD from International Rectifier are used as switching devices. The optimized operating frequency of this device is from 8 kHz to 40 kHz. With ultrafast, ultra-soft-recovery anti-parallel diodes included in the module, the switching characteristic of the IGBT are as follows: 57ns rise time, 54ns turn-on delay, 130ns fall time, 200ns turn-off delay, and 120ns diode reverse recovery time. Based on these characteristics and the load condition, the dead time is set to be 1.5ps to avoid shoot-through. Optocouplers HCPL-3150 from Hewlett Packard are used to isolate the control circuit from the power stage. With 0.5A output current operating at a DC voltage of 15V to 30V, the optocouplers also work as gate drivers for IGBTs.  4.2.2 Current and Voltage Sensors The output voltage of power inverter is 120VAC and the output inductance current can go up to 15 A. While considering the transient overshoot, the possible voltage peak-to-  45  peak value is set to be 380V, and the possible current peak-to-peak value is 50A. Since the DSP A/D converter accepts signals only from 0 ~ 5 V, signals sensed from the output stage of the power inverter must be processed before they are transmitted to the A/D converter. Fig. 4.2 shows the current sensing circuit. The inductance current is sensed by a small resistor, R = 5mQ, which is connected in serial with the inductor. The voltage t  across the resistor is 200 times smaller than the current value flowing through it. Circuit of Stage 1 in Fig. 4.2 amplifies the signal 20 times larger to make the output at "vl" to be lOOmv/A, where R = R = 50kQ and R = R = 100&Q. The resistor R , with the x  3  4  5  2  value of 10Q, is to provide a small input signal to the current controller to stabilize the current loop temporarily in case there is a problem on the current sensing resistor R . i  Circuit of Stage 2 is to shift the current signal to be within the 0 ~ 5 V range, so that 2.5V corresponds to OA in the circuit. In order to prevent the A/D channel from being damaged due to the excessive voltage, a 5-V zener is used at the output. Fig. 4.3 is the voltage sensing circuit. In circuit of stage 1, the output voltage is R-y + R-i  measured by a voltage divider:  , where R^ = lMQ,i? = 10&Q,i? is an 2  3  adjustable resistor of 0 ~ 5kQ.. The purpose of 7? is to adjust the voltage at "v2" 76 times 3  smaller than the inverter output voltage. Circuit of Stage 2 is the same as the current sensing circuit in Fig. 4.2.  46  i  L  L  „  o i A A  /  Ri T  V A / v V  •  i•  :RO  Inverter  /WVT >R2  =  vi  To A / D 5V  -15V pvvW-  Stage 1  Stage 2  Fig. 4.2 Inductance current sensing circuit  \AAr  L  AA/V  Stage 1  To A / D 5V  Stage 2  Fig. 4.3 Output voltage sensing circuit 47  Resolution of the A/D converter is 10 bits, each level corresponds to 0.37V for the output voltage, and 0.37mA for the inductance current. This resolution loss will result in some steady state error and the controller-induced oscillations (or limit cycles).  4.2.3 DSP Evaluation Board The DSP used in this project is TI TMS320F240. This type of DSP is designed mainly for motor control applications. Besides the high performance of the DSP core, it also has many on-chip peripherals that are normally only available in microcontrollers. The main features of this DSP are listed in Table 4.1.  Table 4.1. Features of the TMS320F240 DSP Parameter Name  TMS320F240  MIPS  20  Cycle Time (ns)  50  Frequency (MHz)  20  RAM (words)  544  Flash (words)  16K  Boot Loader Available  Flash  Timers  3  PWM channels  12  A/D channels  16  A/D resolution  10-bit  Conversion Time (us)  6.6us  Total Serial Ports  2  External Memory Interface  Yes  48  The architecture of the F240 DSP is based on the modified Harward architecture, which supports separate bus structures for program space and data space. A third space, the input/output space, is also available and is accessible through an External Bus Interface. To support a large selection of peripherals, a peripheral bus is used. The peripheral bus is mapped to the data space and interfaced to the data bus through system module. Fig. 4.4 is the simplified block diagram of the DSP. A high-speed powerful CPU allows faster processing of algorithms.  Program Bus Data Bus  Event Manager Wait  System Module  CPU Multiplication 16-bit x 16-bit  32-bit Input scaling  v Data Memory  Peripheral Bus  System Control WD/RTT/ PLL  32-bit CALU ADC 32-bit Accumulator  External Bus Interface  Digital I/O Program Memory  32-bit Output scaling External Interrupt  Fig. 4.4 Simplified block diagram of the F240 DSP  The evaluation board of the F240 DSP provides features that are very useful in the development stage. It provides hardware interfaces between the DSP and the peripherals. There are four 34-pin connectors that give access to all the relevant signals on the evaluation board. This board also provides the power supply and the oscillator for the DSP. The  49  A/D converter uses the same ground as the DSP which is grounded through the sensing circuit.  4.2.4 PWM Generator One of the key function of TMS320F240 is the generation of PWM pattern according to calculated duty cycle. The frequency, duty cycle, and deadtime of the PWM signals are programmable. The PWM signal is generated by comparing an internal counter with a specified value. The counter can be either symmetrical or asymmetrical, as shown in Fig. 4.5.  i off Symmetric PWM  On  Asymmetric PWM  Fig. 4.5 PWM generation in DSP  If the PWM period T is fixed, the maximum value of the counter TV in a period of T„ is also fixed; that is N = T/t , m  where t  m  is the cycle time of the DSP. Simulta-  neously the highest resolution of the PWM can be determined as: Resolution = 1 /N for the asymmetric PWM, and Resolution - 2/N for the symmetric PWM. Since the asymmetric PWM can give 2 times higher resolution than the symmetric PWM, it is used in this digital controller application. 50  4.3 Software Design The digital control schemes are implemented in a C program. The following section describes the fixed-point implementation issues and the program structure.  4.3.1 Numeric Representation and Calculation In general, numeric data can be represented in floating-point or fixed-point formats. Since TMS320F240 is a 16-bit fixed-point DSP, it provides much faster operation speed on an integer than on a floating-point number. For example, it takes 24 cycles to finish the calculation of '2.0 + 3.0', but only 10 cycles to finish '2 + 3 '. Similar speed difference can be found in multiplications. In order to increase the computation speed, all the parameters are converted into integers before calculation is performed. The scaling values which are used to transform floating-point numbers to integer numbers are carefully selected to avoid overflow and to minimize the quantization effect. A digital PI controller  G(z)=  a,z-a —  7  can be  implemented  in the  form  of difference  equation,  as  z-l u(t) = a^e(t)- a e(t- T ) + u(t- T ). For voltage loop and current loop, there are two 2  s  multiplications and two additions in each PI controller. Compared to addition, multiplication has a larger possibility of overflow. To avoid overflow, multiplication results have been stored in long integer variables and limited to 16-bit for later computation. The scaling values are in the power of 2, so that the multiplication or division operations can be implemented as left or right shift. The value of e(t) feeding into the current controller is in the range of ± 6 4 after A/D conversion. The parameters than 512 to avoid overflow. For example, if the parameters  and a  should not be larger  2  and a  2  are 1.4 and 1.39 in  51  the current controller, the scale factor of 256 can be used, and the parameters in the DSP will be 1.4 x 256 - 358.4^358 and 1.39x 256 = 355.8 « 356 respectively. The value of gains and zero positions can be changed slightly as compared to designed values because truncation has been made when the parameters are scaled from floating-point numbers to integers. To optimize the implementation of PI controller, the computation sequence has been modified. Basically, the calculation of a digital PI controller consists of two parts. One is the calculation on the previous data e(t - T ) and u(t - T), and the other is on the recent A/D input data e(t) = r(t)-y(t),  where r(t) is the reference value and the y(t) is  the input value. The first part can be precalculated before the new input is available. Then the calculation burden is reduced for the second part. The A/D converter of the F240 DSP needs 6 us minimum to finish a conversion. If some calculation can be performed in this period of time, instead of doing all the calculation after that, at least 6 us can be saved. The time diagram of the one sample period is shown in Fig. 4.6.  Update P W M  Obtain P W M pattern  A / D values ready A / D conversion Computation 1  • Computation 2  DSP in Idle  End of one period  Start of one period  Fig. 4.6 Time diagram of one sampling period  The meaning of Fig. 4.6 is explained as follows. In the stage of Computation 1, the DSP is doing A/D conversion and some computations at the same time. Necessary calcu52  lation variables from last sample interval are stored, those are, e(i) —> e(t— T ) and u(t) —» u(t — T ). The new reference value for a current sample period is obtained by checking the reference table which is prepared and stored in the DSP memory before execution. The second terms of the digital controller  • e(t- T ) can be calculated in the  same period as well. All the other necessary calculations to generate new PWM pattern are finished in the stage of Computation 2.  4.3.2 Program Structure Fig. 4.7 is a flowchart of the overall control program. The first task of the program is to initiate the DSP status, cycle time, and wait cycles, etc. The main computation part is in Timer Tl interrupt procedure. After starting the timer, the program will be waiting for the interrupt to be requested.  Initiate DSP Status  t Initiate Timer, A / D , P W M , and Interrupt  __t Start Timer and Enable Interrupt  Wait for timer interrupt  Fig. 4.7 Flowchart of the main program 53  When Timer Tl counter reaches the end of a switching period, the interrupt is triggered and program flow is redirected to the interrupt service routine. Fig. 4.8 is the flow diagram of the interrupt service routine with sampling frequency of 20 kHz.  Timer interrupt triggered  1  Save registers  1 Start A/D conversion  1 A/D conversion is progress; Store previous value: e(t-T )=e(t); u(t-T )=u(t); s  s  Computation: a/*e(t-T ) Get Reference value: r(t) s  1  Get A/D result  Calculation: e(t)=r(t)-y(t); u(t)=(a *e(t)+ a! *e(t-T ))/K+u(t-Ts) 2  Set to the max value  s  Yes  H Generate PWM  _t Return  Fig. 4.8 Flowchart of the interrupt service routine 54  4.4 Summary In this chapter, the implementation of a digital controller through DSP is discussed. Both respects of hardware and software designs are considered. In hardware design, a system with a inverter and a DSP evaluation board was constructed. Some efforts are made to improve the system performance. In software implementation, the numeric representation and calculation sequence in the fixed-point F240 DSP are issued. Some techniques used to reduce the computation time are developed. The experiment of the inverter system will be reported in the next chapter.  55  Chapter 5 Simulation and Experiment Results  5.1 Introduction In this chapter, performance comparison of five digital controller methods mentioned in Chapter 3 is made based on experiment and simulation results of the switchmode power inverter. Bandwidth and nonlinear load condition are used to evaluate the system performance. In the frequency domain, bandwidth of the control loop gives information of the response speed of the system. Therefore, comparison of the bandwidth of the inverter with different controllers is made first. In the time domain, the performance of a control system can be observed from response to a nonlinear load. Therefore, the performance of the five methods with the nonlinear load condition is compared too. Their relationship with the control structure and the sampling frequency is studied as well. In general, the magnitude of the switching frequency has significant effect on the performance of an inverter. It influences not only the output voltage ripple, but also the steady state sinusoidal waveform as well. Theoretically, the higher the frequency is, the better the performance. Unfortunately, the frequency is limited by the availability of components and cost consideration. Due to the speed of the DSP, we can only realize the digital control at 20 kHz switching and sampling frequency. In the following discussion, the waveforms and data measured from experiments are the results from using 20 kHz as switching frequency, 20 kHz & 10 kHz as sampling frequencies. The waveforms and data 56  obtained from simulation programs PSIM and MATLAB are results from using 40 kHz as the switching and sampling frequencies. The experimental output waveforms are measured with a Tektronix TDS 240A digital real-time oscilloscope. The experimental bandwidth data and frequency responses are provided by a Venable Industries Model 260 system analyzer. Section 5.2 compares the system bandwidth of the current loop and the voltage loop with different digital controllers and different sampling frequencies. Nonlinear load performance is presented in 5.3. Additional comparison of the digital controller delay models was made in section 5.4.  5.2 System Bandwidth Comparison In this section, five design methods are compared based on system bandwidth measurements. The system bandwidth is measured from a frequency response plot (Bode plot). This frequency response plot can be obtained from the Matlab simulation and from experiment. Bandwidth obtained from simulation is a little different with different calculation approaches. No matter which approach is used in the digital controller design, all systems share the same block diagram as in Fig. 5.1. Since calculation in Matlab has to be made in the same domain, either in the sdomain, or in the z-domain, transformation is needed because the plant transfer function is in the s-domain while the digital controller is in the z-domain. We either can convert the plant to the z-domain, and replace z in loop transfer function with e  to see the fre-  57  quency response, or convert the controller to the s-domain, and replace s in loop transfer function with /'co to obtain the frequency response. In this thesis, the first transformation is used, and the transformation of the plant is the same as that of direct digital design approach. The current loop bandwidth is measured in the Bode plot of K • D (z) • H^z), t  f  and the voltage loop bandwidth is obtained from that of K • £> (z) • T (z) • H (z), v  v  t  v  where  is the current close-loop transfer function.  Voltage Controller  Current Controller  H (s) v  Fig. 5.1 Double-loop digitally controlled system diagram  Fig. 5.2 shows the experimental test circuit for the current loop and voltage loop bandwidth with Venable system analyzer. Channel 1 and channel 2 are the two terminals of the system analyzer used for signal injection and measurement. Two operational amplifiers connected as voltage followers are used to provide a high impedance for channel 1 and a low impedance for channel 2, as required by the system analyzer. A small resister of 22Q is added as well for the analyzer to inject and obtain signals. Fig 5.3 indicates the connection of the test circuit and the inverter system. The test circuit is believed not to have a large influence on the system dynamics. First, the comparison on the system bandwidth is made at 10 kHz sampling frequency and 20 kHz switching frequency. Following the same design procedure described 58  in Chapter 3, five different current loop and voltage loop controllers were constructed, and Table 5.1 lists all the controllers.  22Q.  Signal in  L  J  Signal out  W V  Channel 1  Channel 2  T Y Y Y  1  System A n a l y z e r  Fig. 5.2 Test circuit for system loop bandwidth measurement  Current Controller  Voltage Controller  V,  o  His) HJs) Current loop inject point  Voltage loop inject point  Ki  Kv Fig. 5.3 Current and voltage loop bandwidth measurement points  Table 5.1. Current and voltage controllers with different methods at 10 kHz sampling rate Design Method  Current Loop Controller , x  n  Voltage Loop Controller  0.8z-0.796  °*  Direct Digital Backward Euler  Gj(z) ~  ' r, ' f  Bilinear  G  s ( Z ) =  0.514z-0.489 z-1 0.502z-0.477 z-1 0.502z-0.477  Pole/Zero Match Step Invariant  , x  n  , x  n G  *  „ G  ( Z ) =  x  t  '  (  Z  )  r. , . °' ( Z )  G  <-  (Z)=  0.489z-0.464 z-1  . .  n G  ( z )  *  ( Z )  =  z-0.18 z-1  0.866z-0.156 z-1 0.509z + 0.204 z-1 0.720z-0.072 z-1 0.153Z +0.562 z-1 59  Fig. 5.4 and 5.5 are the simulated Bode plot of the system current and voltage loops from Matlab.  m w  1  Frequency (Hz)  Fig. 5.4 Simulated Current loop Bode plot at the sampling rate of 10 kHz  OQ w  •a |  Frequency (Hz)  -300 10  10*  2-10  Frequency (Hz)  Fig. 5.5 Simulated voltage loop Bode plot at the sampling rate of 10 kHz  The experimental frequency responses of the current and voltage loops obtained from analyzer are presented in Fig. 5.6 and Fig. 5.7.  Frequency (Hz)  Frequency (Hz)  Fig. 5.6 Current loop Bode plot provided by the system analyzer at the sampling rate of 10 kHz  62  PQ -13  a  "5.  Frequency (Hz)  -300 10'  Frequency (Hz)  10  2-10  Fig. 5.7 Voltage loop Bode plot provided by the system analyzer at the sampling rate of 1 0 kHz  63  Table 5.2 to 5.5 list the bandwidth and the phase margin of the current and voltage loops from the simulated and experimental results.  Table 5.2. Simulated current loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Design Method  Current Loop Phase Margin  Direct Digital  Current Loop Bandwidth 2.93 kHz  Backward Euler  2.23 kHz  70°  Bilinear  2.20 kHz  70°  Pole/Zero Match  2.20 kHz  70°  Step Invariant  2.16 kHz  70°  50°  Table 5.3. Simulated voltage loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Voltage Loop Phase Margin  Direct Digital  Voltage Loop Bandwidth 1.08kHz  Backward Euler  0.68kHz  75°  Bilinear  0.64kHz  63°  Pole/Zero Match  0.65kHz  71°  Step Invariant  0.63kHz  53°  Design Method  70°  Table 5.4. Measured current loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Current Loop Phase Margin  Design Method  Current Loop Bandwidth  Direct Digital  2.5kHz  48°  Backward Euler  2.3kHz  48°  Bilinear  2.3kHz  48°  Pole/Zero Match  2.3kHz  48°  Step Invariant  2.2kHz  40°  Table 5.5. Measured voltage loop bandwidth and phase margin with different digital controllers at 10 kHz sampling rate Design Method  Voltage Loop Phase Margin  Direct Digital  Voltage Loop Bandwidth 0.90kHz  Backward Euler  0.70kHz  70°  Bilinear  0.65kHz  65°  Pole/Zero Match  0.68kHz  70°  Step Invariant  0.60kHz  55°  70°  As we can see from Fig. 5.5 to 5.7, the experimental and the simulated frequency response curves are very similar in shape. The bandwidth and phase margin obtained from these curves are close to each other as well. Between the two results, the experimental result is considered to be a better reflection of the real physical inverter system. However, the noise in the physical system makes it difficult to get a very accurate reading. The small variation of the simulation results, as seen in Fig. 5.5 to 5.7 and Table 5.2 to 5.5, is because of the following two reasons. First, the simulation is based on the system transfer function, which only represents the main dynamic of the system. Second, there is a system transformation in the simulation, and the transformation may introduce some errors. Although there are limitations on the method, the simulation results still display the system performance. From both the experimental and the simulation results, it is shown that the direct digital design approach gives a higher bandwidth than the redesign approach. In the experimental system, the bandwidth of the current loop is 8.7% higher than the Backward Euler method and 13.6% higher than the Step Invariant method. The improvement is even bigger in voltage loop: it is 28.6% higher than the Backward Euler and 50% higher than the Step Invariant. In digital redesign methods, Backward Euler gives the highest bandwidth 65  in the voltage loop, Pole/Zero Match and Bilinear are second, Step Invariant gives the lowest. The bandwidth difference in the current loop among the Backward Euler, Pole/ Zero Match and Bilinear is not very clear in the experimental result, but their bandwidth are slightly better than that of Step Invariant method. The same conclusion on these redesign methods can be drawn from the simulated results, and from the data, we can see that the Backward Euler has higher bandwidth than the Pole/Zero Match even in the current loop. A similar comparison of the system bandwidth was made at a 20 kHz sampling frequency. Table 5.6 lists all the controllers with different design methods.  Table 5.6. Current and voltage controllers with different methods at 20 kHz sampling rate Design Method  Current Loop Controller  Direct Digital  ^ , , '  1.4z-1.39 z-l  ,v  0.852z-0.809 z-l  n  Backward Euler  °'  , ,  n  '  Bilinear  , ,  n  Pole/Zero Match  ( Z )  ' ^ .v  Step Invariant  G,(z)=  0.830z- 0.786 z-l 0.830z-0.786 z-l 0.808z-0.764 z  l  Voltage Loop Controller , v  n  V  G  (  Z  )  r. , , G  *  n G  (  =  ( Z )  -  v ,  n  z-l  0.294z + 0.068 z-l 0.377z- 0.015 z-l  x  v  r, < ^ °^ Z  Z - l  0.475Z-0.113 )  (  *  Z  0.55z-0.13 "  )  =  0.113z +0.249 z-l  Fig. 5.8 and 5.9 are the experimental results of the current and voltage loops provided by the system analyzer. Table 5.7 and 5.8 list the measured bandwidth and the phase margin of the current and voltage loops. Similar results are obtained from simulation as  66  well. Table 5.9 and 5.10 list the simulated bandwidth and the phase margin of the current and voltage loops.  Frequency (Hz)  Fig. 5.8 Current loop Bode plot provided by the system analyzer at the sampling rate of 20 kHz 67  Table 5.7. Measured current loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Design Method  Current Loop Phase Margin  Direct Digital  Current Loop Bandwidth 3.1 kHz  Backward Euler  2.9 kHz  50°  Bilinear  2.9 kHz  50°  Pole/Zero Match  2.9 kHz  50°  Step Invariant  2.9 kHz  50°  50°  Table 5.8. Measured voltage loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Voltage Loop Phase Margin  Direct Digital  Voltage Loop Bandwidth 1.2 kHz  Backward Euler  0.95 kHz  65°  Bilinear  0.83 kHz  55°  Pole/Zero Match  0.90 kHz  60°  Step Invariant  0.82 kHz  50°  Design Method  65°  Table 5.9. Simulated current loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Design Method  Current Loop Bandwidth  Current Loop Phase Margin  Direct Digital  3.74 kHz  62°  Backward Euler  2.94 kHz  65°  Bilinear  2.90 kHz  65°  Pole/Zero Match  2.90 kHz  65°  Step Invariant  2.85 kHz  65°  69  Table 5.10. Simulated voltage loop bandwidth and phase margin with different digital controllers at 20 kHz sampling frequency Design Method  Voltage Loop Phase Margin  Direct Digital  Voltage Loop Bandwidth 1.29 kHz  Backward Euler  0.93 kHz  63°  Bilinear  0.89 kHz  55°  Pole/Zero Match  0.90 kHz  58°  Step Invariant  0.88 kHz  46°  56°  Qualitatively speaking, from observing the experimental and simulation results with 20 kHz sampling rate in Fig. 5.8 and 5.9 and Table 5.7 to 5.10, one can almost draw the same conclusion as that for 10 kHz sampling rate. However, the difference on the bandwidth among different methods becomes smaller compared to the case of 10 kHz sampling rate. In the experimental system, the current loop bandwidth of the direct digital controlled system is 6.9% higher than the redesign methods. The voltage loop bandwidth is 26.3% higher than the Backward Euler and 46.3% higher than the Step Invariant. Although there are some differences among the four redesign methods from the simulation results on current loop, the difference is so small that, in the real inverter system, it can not be differentiated from noise. On the other hand, the difference on the voltage loop is visible, especially on the phase plot. The Backward Euler gives the highest bandwidth and good phase margin, followed by Pole/Zero Match and Bilinear. The Step Invariant method is the worst, both in amplitude and phase response. From previous results, we can see that the difference among the different methods is larger in the double-loop than that of single-loop. The difference also increases when  70  the sampling frequency is lower. To verify the trends of variation of the bandwidth difference among the five methods, a sampling frequency of 40 kHz was tried. Since it is difficult to perform a experiment with such high switching and sampling frequency with the existing setup, the trend verification is done only by simulation. Table 5.11 lists the digital controllers designed with 40 kHz sampling rate. Fig. 5.10 and Fig. 5.11 are the simulated frequency responses of current and voltage loops. Table 5.12 and 5.13 list the bandwidth and the phase margin of the current and voltage loops.  Table 5.11. Current and voltage controllers with different methods at 40 kHz sampling rate Design Method  Current Loop Controller r, , \ 2z- 1.98 G,(z)2  Direct Digital G  )  =  Backward Euler Bilinear  r,, , ' G  ( Z ) =  G  '  Pole/Zero Match Step Invariant  Voltage Loop Controller  G  <-  (Z)=  n  l  1.73Z-1.67  ^  z- 1  n  t  G  ^  1.70r-1.64 z-l  n  1.70Z-1.64 z-l  n  1.67z-1.61 z-l  \  t  G  Z  )  ^ Z  )  -  ,  f  , , *  ( Z )  r, ,  N  0.75z-0.49 z-l 0.543z-0.323 z-l 0.433z- 0.213 z-l  v  G  =  -  0.446z-0.226 z-l 0.323z-0.103  Table 5.12. Simulated current loop bandwidth and phase margin with different digit controllers at 40 kHz sampling frequency Design Method  Current Loop Bandwidth  Current Loop Phase Margin  Direct Digital  5.44 kHz  67°  Backward Euler  4.78 kHz  68°  Bilinear  4.71 kHz  68°  Pole/Zero Match  4.71 kHz  68°  Step Invariant  4.64 kHz  69° 71  i  20  i  i i i i i •  15 ^k. \.  1  Direct Digital  1  CQ  X  10  1  1  w  Backward Pole/Zero Match Bilinear Step Invariant  3  "a.  E  / / /  1 1 1  1 1 1 1 1 1 1 1 1 1 1  -10 10'  10  Frequency (Hz)  0 \  -20  \  ^  i  Direct Digital  -40 Vy  -60 u DO  ii w  l \ v  -80  iK,  -100  <D to  03 - C  L  L  - V V  Backward Pole/Zero Match Bilinear Step Invariant  -120 -140 -160  L,  1  1  1  -180 -200 10"  10  Frequency (Hz)  Fig. 5.10 Simulated current loop Bode plot at the sampling rate of 40 kHz  20 15  Direct Digital  10 5  m  3  0  T3  3 S <  -5 -10  Pole/Zero Match Bilinear  -15 -20 5-10  Step Invariant 5-10  10'  Frequency (Hz)  w • OH  .  5-10  Frequency (Hz)  Fig. 5.11 Simulated voltage loop Bode plot at the sampling rate of 40 kHz  73  Table 5.13. Simulated loop voltage bandwidth and phase margin with different digital controllers at 40 kHz sampling frequency Design Method  Voltage Loop Phase Margin  Direct Digital  Voltage Loop Bandwidth 1.76 kHz  Backward Euler  1.43 kHz  57°  Bilinear  1.39kHz  54°  Pole/Zero Match  1.39 kHz  52°  Step Invariant  1.36 kHz  47°  58°  With the switching and sampling frequencies increasing to 40 kHz, the system bandwidth with different methods, in sequence from larger to smaller, are still in the same order as in the low frequency cases. However, the difference of the bandwidth with different controllers is reduced in the voltage loop. The bandwidth of the direct digital controller is 23.1% higher than the Backward Euler and 29.4% higher than the Step Invariant method. In the current loop, the bandwidth is 13.8% higher than that of Backward Euler method and 17.2% higher than that of Step Invariant. Although the difference seems larger than the results of low frequency experiment, it is reduced when compared with low frequency simulation results. In the comparison on the system bandwidth above, the direct digital design approach always gives the highest bandwidth on both the current loop and the voltage loop at all frequencies. The difference on double-loop system is bigger than single-loop. The four digital redesign approaches are comparable in terms of the bandwidth as well; that is, Backward Euler gives the largest bandwidth, followed by Pole/Zero Match and  74  Bilinear, and Step Invariant has the narrowest bandwidth. The difference on the bandwidth keeps increasing while the sampling rate is reduced.  5.3 Nonlinear Load Performance Performance at nonlinear load is another indication of the system. The performance can be measured by voltage distortion. The lower the distortion, the better the performance. In the system experiment and simulation, the nonlinear load shown in Fig. 5.12, withC  0  = 560pF, R  Q  = 26.67Q, is applied.  •0  Fig. 5.12 Nonlinear load for the inverter system  Fig. 5.13 are typical output voltage and current waveforms from a nonlinear load. These waveforms represent big distortions in the output voltage and current. The performance difference of the five design methods will be listed in Table 5.14 by calculating the total harmonic voltage distortion from the experimental waveforms at sampling frequency of 10 kHz and 20 kHz. The total harmonic voltage distortion can be expressed as  THD=  V,H L-H  , in which V,L-H  is the fundamental A C line to neutral voltage; V  H  is the  75  2  total line to neutral harmonic voltage V  £  H  , the upper summation limitation  A, =2  of h = 10 is chosen for calculation purposes. 2  o  >  Output Voltage -150 i  0.2  0.3  i  XT i  Time (s) Fig. 5.13 Experimental nonlinear load output waveform  Table 5.14. Total Harmonic Distortion comparison of the five design methods for the inverter system with nonlinear load at different sampling rate  Direct Digital  THD at 10 kHz sampling frequency 15.1%  THD at 20 kHz sampling frequency 13.5%  Backward Euler  15.7%  13.9%  Bilinear  15.9%  14.1%  Pole/Zero Match  15.9%  14.1%  Step Invariant  16.9%  14.7%  Design Method  76  The same comparison is made on the double-loop system with a switching and sampling frequency of 40 kHz. THDs are calculated from PSIM simulated waveforms, they are: 9.2% for direct digital, 9.6% for backward, 9.7% for Bilinear and Pole/zero Match, and 9.9% for Step Invariant. Direct digital approach has the lowest output voltage THD at all sample frequencies that have been tried. When the sampling rate is relatively low, the THD difference among methods increases a little. Backward Euler method has lower THD than other redesign methods, but the difference is small. Pole/zero Match method and Bilinear method give the same THD, which is between the Backward Euler and the Step Invariant. These results also verify the system bandwidth differences of the five digital design methods.  5.4 Modeling of the digital controller delay As discussed in Chapter 2, the model which represents the digital controller delay as in Fig. 2.2(b), has some effects on the digital controller design. Using different delay models on the same design method will generate different controllers. In this section, an experiment is performed on a hardware inverter model board to display the influence of the delay model on digital controller design. Fig. 5.14 is the brief schematic of the model board. The model board neglects the switching effect of the inverter while retaining the main dynamic characteristics. An LM3875 amplifier is used to realize the gain from control signal to working voltage. The gain is obtained from taking the ratio of R and i?j. 2  Because of the limitation on operating voltage of the amplifier, the model board can only work in a low voltage range. The values of output inductance, capacitor and the load have 77  been modified in order to obtain similar dynamic behavior as the inverter, and the current and voltage controllers are modified slightly tofitfor this model board.  Fig. 5.14 Brief schematic of the power inverter model  The current and voltage loop bandwidth of this model system was measured at a sample frequency of 20 kHz with the same equipment. Table 5.15 and Table 5.16 list the designed current and voltage loop bandwidth and phase margin. The measured current and voltage loop bandwidth and phase margin are provided in these two tables for comparison purpose. Model 1 to 3 in Table 5.15 and 5.16 are explained as follows:  Model 1: T delay only, Hdelay I (s) = e  Model 2: Zero-order-hold and T /2 delay, Hdelay! (*) = l-e  Model 3: Zero-order-hold and 7' delay, Hdelay3  7>/2  s  e  l-e s  78  Table 5.15. Current loop bandwidth and phase margin with different delay models at 20 kHz sampling frequency Model  Design Bandwidth  Designed Phase Margin  Model 1  2.3 kHz  Model 2 Model 3  Design Phase Margin  60°  Measure Bandwidth 2.2 kHz  2.3 kHz  60°  2.2 kHz  40°  1.85 kHz  60°  1.8 kHz  40°  50°  Table 5.16. Voltage loop bandwidth with different delay models at 20 kHz sampling frequency Designed Phase Margin  Model 1  Design Bandwidth 0.8 kHz  Model 2 Model 3  Model  Design Phase Margin  65°  Measure Bandwidth 0.8 kHz  0.8 kHz  65°  0.8 kHz  70°  0.6 kHz  65°  0.6 kHz  73°  76°  As seen clearly from Table 5.15 and 5.16, the first two models give us much faster response than the last one. Using Model 1 or model 2 in the digital design not only generates higher bandwidth but also shows reasonable phase margin. The amplitude responses of these two models are almost the same, while Model 1 gives more phase margin than that of Model 2. Model 3 adds dramatic delay to the system, and the system bandwidth is poorly limited. Based on the result we have obtained, model 1 has been used in this project.  5.5 Summary The simulation and experiment results of a DSP-controlled-inverter are presented in this chapter. The performance of five digital control design methods are tested and compared as well. From the presented results, some interesting points are as follows: 79  1) . The direct digital design method always gives higher bandwidth and smaller output voltage THD than the redesign methods. 2) . The system performance also varies with different digital redesigned controllers, and the Backward Euler method is the best among the four discussed redesign methods. 3) . The difference in performance is bigger in a double-loop system than that of a single-loop. 4) . The difference also increases while the sampling rate is lower. In addition, the study on the influence of the delay model to the system performance shows that digital controller obtained with T delay as the delay model gives better performance than the other models. Further conclusions on the development of digital controlled inverter system will be stated in Chapter 6.  80  Chapter 6 Conclusions  The work presented in this thesis describes five digital controller design methods for switchmode power converter system application. Design, implementation, and comparison are made on these methods. The contribution and conclusions of the thesis can be summarized as follows: a) A systematic comparison of different digital controller design methods is carried out. Results show that: i) . the direct digital design method out-performs any of the digital redesign methods. The direct digital design method gives a higher bandwidth, and smaller Total Harmonic Distortion in nonlinear loads at all switching and sampling frequencies that have been applied. ii) . Among the digital redesign methods, the Backward Euler transformation methods always gives a slightly better controller, followed by the Pole/ Zero Match and the Bilinear methods. The Step Invariant method is the worst. The Backward Euler also provides the smallest THD in nonlinear load condition among the digital redesign methods. The same results can be drawn at all applied switching and sampling frequencies.  81  iii). The difference of the performance among the design methods becomes greater for the outer loop in a double-loop system and when the sampling rate is lower. This result can be very useful in digital control design for switchmode power converter systems. In these applications, double-loop control structure is mostly used, and the sampling rate can be several times lower than the converter switching frequency, due to the availability of components. b) A modified direct digital design method is proposed. This method makes full use of the advantages of the frequency response method and the root locus method. It can still use the same concept of the gain-cross-over frequency and the gain/ phase margin as in the continuous s-domain, and at the same time achieve an near optimum design with fewer iterations using the root locus method. This method is particularly convenient for practicing engineers who are familiar with the traditional s-domain design methods. Some future work related to this topic will be indicated. The control program in DSP is written in C right now. It is recommended to write the control program in assembly for a commercial product, so that more functions or features can be added, or a low-rate controller can be used. The model used to represent the delay introduced by the digital controller is helpful to get reasonable digital controller. Theoretical study on this issue will benefit the further digital control designs. The digital controller delay in switchmode power converter system is the main factor that degrades the system performance. A question "Is it possible to reduce that delay?" is waiting for an answer. The application to other switchmode power converter system and control schemes can be examined as well. 82  Bibliography  [1]  T.W. Martin and S.S Ang, "Digital Control for Switching Converters", proceed-  ings of the IEEE International Symposium on Industrial Electronics,  [2]  1995, pp.480-484  CH. Wang and C.C. Hsu, "Performance Evaluation of Redesigned Digital System  Using Energy Resemblance Index", IEEE Decision and Control Conference, 1996, pp. 4311-4316 [3]  C.K Lau and M.H. Pong, "Comparison of Three Approaches on DSP Based Digi-  tal Controlled 2-Wheeler Forward Converter", Proceedings of IEEE Industrial ogy Conference,  [4]  1994, pp.164-168  L.S. Su, "Digital Controller - Its Design Techniques", IEEE Instrumentation and  Measurement  [5]  Technol-  Technology Conference, 1994, pp. 841-844  A. Kawamura and T.Yokoyama, "Comparison of Five Different Approaches for  Real Time Digital Feedback Control of PWM Inverters", Conference Record of the IEEE Industry Application Society Annual Meeting,  [6]  1990, pp. 1005-1011  K.S. Rattan, "Compensating for Computational Delay in Digital Equivalent of  Continuous Control Systems", IEEE Transactions on Automatic Control, Vol.34, No.8, 1989, pp. 895-903 [7]  K.Ohkubo, Y.Yagishita, and T. Katayama, "An Analysis of Quantization Errors in  Digital Control Systems and Its Application to a Hard Disk Drive", Proceedings of the IEEE International Conference on Industrial Technology,  [8]  1996, pp.61-69  T.Ieko, Y. Ochi, K.Kanai, and N. Hori, "PIM Digital Redesign Method and Its  Application to the Design of a Digital Flight Controller", Proceedings of the 34th SCIE Annual Conference, International Session Papers,  1995, pp. 1469-1474  83  [9]  Y. Y Tzou, "DSP-based Fully Digital Control of a PWM DC-AC Converter for AC  Voltage Regulation", IEEE Power Electronics Specialists Conference, 1995, pp.138-144 [10]  M.Y. Chang, J.Y. Lin and Y.Y. Tzou, "DSP-based Fully Digital Control of a AC/  DC Converter with a Nonlinear Digital Current Mode Control", IEEE Power Electronics Specialists Conference,  [11]  1996, pp. 1702-1708  N. Rafee, T. Chen and O.P. Malik, "A Technique for Optimal Digital Redesign of  Analog Controllers", IEEE Transactions on Control Systems Technology, Vol. 5, No.l, 1997, pp. 89-99 [12]  A.H. Mitwalli, S.B. Leeb, G.C. Verghese and V.J Thottuvelil, "An Adaptive Digi-  tal Controller for a Unity Power Factor Converter", IEEE Transactions on Power Electronics, Vol. 11, No.2,1996, pp. 374-381  [13]  S. Manchanda and P. Rastgougard, "Utilization of Extrapolated Integrators and  Differentiators in Digital Controller Design and Analysis", IEEE Southeastcon '90 Proceedings, 1990, pp. 906-910  [14]  E.W. Bai and S.Dasgupta, "On Digital Control of Continuous Time Systems Using  Generalized Hold Functions", IEEE Proceedings of the 28th Conference on Decision and Control,  [15]  1989, pp. 1241-1246  H. Elci and R.W. Longman, "Discrete Frequency Based Learning Control for Pre-  cision Motion Control", IEEE International Conference on Human, Information and Technology, 1994, pp. 2767-2773  [16]  S. Dormido, I. Lopez-Rodriguez, J. L. Fdez-Marron, F.Morilla and J. Aranda,  "Design of Digital Control System Using the Sampling Period as a Compensator", IEEE Electrotechnical  [17]  Conference, 1991, pp. 812-815  C.S. Berger, "Robust Control of Discrete Systems", IEE Proceedings of Control  Theory and Applications,  Vol. 136, No.4, 1989, pp. 165-170  84  [18]  B.P. Lampe and Y.N. Rosenwasser, "Design of Hybrid Analog-Digital Systems by  Parametric Transfer Functions", IEEE proceedings of the 32nd Conference on Decision and Control, 1993,  [19]  pp. 3897-3898  M.Steinbuch, G. Schootstra and H.T Goh," Closed-Loop Scaling in Fixed-Point  Digital Control", IEEE Transactions on Control Systems Technology, Vol. 2, No. 4, 1994, pp. 312-317 [20]  Y.Y Tzou, "DSP-Based Robust Control of an AC Induction Servo Drive for  Motion Control", IEEE Transactions on Control Systems Technology, Vol. 4, No. 6, 1996. pp. 614-626 [21]  T.C. Yang, "On Computational Delay in Digital and Adaptive Controllers", IEE  Control'94  [22]  Conference Publication,  H. Jin, "Behavior-Mode Simulation of Power Electronic Circuits", IEEE Transac-  tions on Power Electronics,  [23]  1994, pp. 906-910  Vol. 12, No.3, 1997, pp. 443-452  L.Salazar, "PSPICE Simulation of Three-Phase Inverters by Means of Switching  Functions", IEEE Transactions on Power Electronics. Vol. 9, No. 1, 1994, pp.35-41. [24]  N. Nakamura and Tomotaro Katsura, "Test of Fast-Digital Beamline Feedback  Control at the Photon Factory", IEEE Particle Accelerator Conference, 1993, pp. 22572259 [25]  A.Khodabakhshian, V.J. Gosbell and F.Coowar, "Discretization of Power System  Transfer Functions", IEEE Transactions on Power Systems, Vol. 9, No. 1, 1994, pp. 255261 [26]  "TMS320C24x DSP Controllers Evaluation Module", Technical Reference, Texas  Instruments,  [27]  1997  "TMS320C24x DSP Controllers: CPU, System, and Instruction Set", Reference  Set, Texas Instruments,  1997  85  [28]  "TMS320C24x DSP Controllers: Peripheral Library and Specific Devices", Refer-  ence Set, Texas Instruments,  [29]  1997  "TMS320C2x/C2xx/C5x Optimizing C Compiler", User's Guide, Texas Instru-  ments, 1995  [30]  Y. Duan and H. Jin, "Digital Controller Design for Switchmode Power Convert-  ers", IEEE Applied Power Electronics Conference, 1999, pp. 967-973 [31]  S. Bibian and H. Jin, "A simple Prediction Technique for the Compensation of  Digital Control Time Delay In DC Switchmode Power Supplies", IEEE Applied Power Electronics Conference,  [32]  1999, pp. 994-1000  R. Whitback and L. Hofmann, "Digital Control Law Synthesis in the w' domain",  J. Guidance and Control, Vol. I, No. 5, 1978  [33]  M. Brown, "Practical Switching Power Supply", Academic Press, Inc. 1990.  86  Appendix A: Schematic of the DSP Controlled Power Inverter System  88  n  Z  75  >  Z  *0  3 a n  c IK  o h a r  D O o 3  CL  o  ft  3  IK o  r o  o re C/3  C T3 T3  O O o o n  s D  GO  O o 3  QO  (5  00  3  ao  era  D  n  +  Appendix B: Controller Software of the DSP  The C program is made of five files. The main program is in "invl.c". There are two header files, "regis.h" and "invl.h". Another small assembly program "init.asm" is only for system initialization, "invl.cmd" defines the program and data memory address in F240 DSP.  A) "invl.h" file /* invl.c */ /* the main c program for the DSP controlled switchmode power inverter system */ /* header file which defines the registers of the DSP */ #include "regis.h" /* header file which define the inverter system parameters */ #include "invl.h" /* set cpu interrupt vector */ asm(" asm(" asm(" asm(" asm(" asm(" asm("  /* two interrupts: timer T l interrupt and NMI interrupt */ .global _c_intO"); .sect V'.iniV "); b cintO "); retc "); retc "); b _c_int2 "); .sect V'.textV ");  /* main program start from here */ mainfj { /* the initialization of the system and program */ init(); /* clear the A D C digital result registers */ bufferl=*ADCFIF01; bufferl=*ADCFIF02; bufferl=*ADCFIF01; buffer 1=*ADCFIF02; /* idle, waiting for timer interrupt */ while(l) {  }; }; /* main program ends here */  90  /* dsp initialization program */ void init() {  /* define the system clock as 10MHz and the cpu clock as 20MHz */ /* the 'waitstate' is a system initialization function in init.asm program */ waitstate(); /* initial the status registers stO and stl */ /* enable all unmasked interrupts */ asm(" CLRC INTM"); /* reconfigurable dual-access R A M block are mapped to data space */ asm(" CLRC CNF "); /* enable timer INT2 interrupt and clear the interrupt pending flags */ *IMR=0x0002; *IFR=Oxffff; /* intial the PWM registers */ /*ACTR:0000011001100110=0x0666 */ /* set 3 pwm pares output polarity to be active high/low respectively */ *ACTR = 0x0666; /* DBTCON: 0001100100100000 =0x1920 */ /* enable deadband timer to be 1.25us */ * DBTCON = 0x1920; /* inital a pwm duty ratio to be 0.5 */ *CMPR1 = 500; /* enable full compare output, and set in pwm mode */ /* COMCON: 0000001000000111=0x0207 */ *COMCON = 0x0207; /* start the compar operation */ *COMCON = 0x8207; /* initial the timer T l registers */ /* enable timer T l underflow interrupt */ /*EVIMRA: 0000001000000000= 0x0200 */ *EVIMRA = 0x0200; /* no interrupt poriotity problem */ *EV1VRA= 0x0; /* reset all the pending interrupt flag */ *EVIFRA=0xffff; /* enable timer compare output and set output polarity to be active low */ /*GPTCON: 0000000001000001=0x0041 */ *GPTCON = 0x41; /* set the timer period to be 50us, the corresponding switchingfrquencyis 20kHz */ *T1CMPR = 0; *T1PR = 999; /* enable timer and compare operation */ /* set the timer count mode to be continuous up/dowm count mode, */ /*and reset the counter */ /*TlCON: 0010100001000010 =0x2842*/ *TlCON = 0x1042; *TlCNT = 0x0;  /* intial the AD converter registers */ /* enable two AD units, select channal 6 and 14, set the input clock prescler to 20 /* ADCTRL:1001100001011010=0xl85a*/ •ADCTRL1 =0x185a; *ADCTRL2 = 0x0006; /* reset the reference table vector and sample and flag for 10kHz sample rate*/ i=0; f=0; } /* the timer interrupt process */ /* the control algorithm is calculated here */ interrupt void c_int2() { /* just return at this switching period, for 10kHz sample rate */ /*if(f>0) { *PCDATDIR = 0x8080; f=0; *PCDATDIR = 0x8000; }  else { f=i; */ /* set I/O port C7 to high, for testing purpose*/ •PCDATDIR = 0x8080; /* start A/D conversion */ *ADCTRL1 =0x385b; /* store the old controller data */ xil=xi0; xvl=xv0; yil=yi0; yvl=yv0; /* some control algorithm calculations, which do not need new AD values */ xil=xil*c4; xvl=xvl*c2; /* get the reference value for this time step */ if(i<167) vr=SIN[i]; else vr=-SIN[i-167]; if(i>333) i=0; /* check whether AD conversion is finished, if not wait for it. */ while(*ADCTRLl &0x80)  { };  /* get the input AD result */ /* A/D input voltage range is 0->5v */ /* represents -25A->25A in inverter for current, */ /*-190V->190V for voltage in inverter */ /* the ad converter result -512->+512 after shifting */ buffer 1 = ((* ADCFIFO1 »6)&0x03 ff)-512; vv=bufferl; buffer2= ((*ADCFIFO2»6)&0x03ff)-512; ii=buffer2; /* controller calculations */ /* voltage PI controller, 512 is the parameter scaling effect */ xv0=(vr/4-vv); y vO=y v 1 +(xvO* c 1 -xv 1 )/512; /* set limitation */ if(yv0>16384) yv0=16384; if (yv0<-16384) yv0=-16384; /* current PI controller, 256 is the parameter scaling effect */ xiO=(yvO+ii); yi0=yil+(xi0*c3-xil)/256; /* generate pwm duty ratio, set limitation, and update the compare register vr=yi0/2*3; *CMPRl=vr+500; if(*CMPRl>970) {*CMPR1=970;} if(*CMPRl<30) {*CMPR1=30;} /* send out some important signal to D/A port, for testing */ DAC0_VAL=ii*4+2048; DACl_VAL=vv*4+2048; DAC2_VAL=vr+2048; DAC3_VAL=DAC0_VAL; asm(" OUT _DAC0_VAL,0000h"); asm(" OUT_DAC3_VAL,0001h"); asm(" OUT_DACl_VAL,0002h"); asm(" OUT_DAC2_VAL,0003h"); asm(" OUT_DACl_VAL,0004h"); /* clear the interrupt pending flag */ *EVIFRA=Oxffff; /* set I/O port C7 to low, for testing purpose*/ *PCDATDIR = 0x8000; /*}*/ }  /* end of program */  B) "ini.asm" file .global  meminit  .global waitstate .include f240regs.h Variables Declartion for B2 .bssGPRO,l;General Purpose Register  .text meminit  ;Dummy function call for demo  NOP NOP NOP RET _waitstate SETCINTM  ;Disable interrupts  LACCIFR;Read Interrupt flags SACLIFR;Clear all interrupt flags CLRCSXM;Clear Sign Extension Mode CLRCOVM;Reset Overflow Mode CLRCCNF;Config Block BO to Data mem LDP  #00E0h;DP for addresses 7000h-707Fh  SPLK#00BBh,CKCR 1 ;CLKIN(OSC)= 10MHz,CPUCLK=20MHz SPLK#00C3h,CKCR0 ; C L K M D = P L L Enable,SYSCLK=CPUCLK/2 SPLK#40C0h,SYSCR ; C L K O U T = C P U C L K SPLK#006Fh, WDCR;Disable W D if VCCP=5V (JP5 in pos. 2-3) KICK_DOG;Reset Watchdog RET .end  C) "invl.h" file  /* invl.h */ /* this the header file that defines the globle constant parameter and varables.*/ /* the parameters of the digital controller */ /* voltage PI controller parameters */ const int c 1=282; /*0.55*512=282*/ const int c2=67; /*0.13*512=67*/ /* current PI controller parameters */ const int c3=358; /* 1.4*256=358*/ const int c4=356; /* 1.39*256=356*/ /* the variables that needed for the system */ int D A C O V A L ; /* data to D/A channal 0 */ int DAC 1_VAL; /* data to D/A channal 1 */ int D A C 2 V A L ; /* data to D/A channal 2 */ int DAC3_VAL; /* data to D/A channal 3 */ int i=0; /* for count purpose.*/ int f=0; /* flag for 10kHz sample rate, 20kHz switchingfrquency*/ int buffer 1=0; /* temperary storage for AD value */ int buffer2=0; /* temperary storage for AD value */ int ii=0; /* the current input */ int vv=0; /* the voltage input */ int vr=0; /* the reference voltage for the system */ long int xv0=0,xvl=0; /* the input data for the voltage controller, xvl is the last data */ long int yv0=0,yvl=0; /* the output data for the voltage controller, yvl is the last value */ long int xi0=0,xil=0; /* the input data for the current controller, xii is the last data*/ long int yi0=0,yil=0; /* the output data for the current controller, yil is the last data*/ /* sinasoidal reference waveform table, half period */ int SIN[168]={0,34,68,102,136,170,204,237,271,305,338,372,405,438,471,503,536,568, 601,633,664,696,727,758,789,819,850,879,909,938,967,996,1024,1052,1079,1106, 1133,1159,1185,1211,1236,1260,1284,1308,1331,1354,1377,1398, 1420,1440,1461,1481,1500,1519,1537,1554,1571,1588,1604,1619, 1634,1648,1662,1675,1687,1700,1711,1722,1732,1741,1750,1758, 1766,1773,1779,1785,1780,1795,1798,1802,1804,1806,1807,1808, 1808,1807,1806,1804,1802,1800,1795,1790,1785,1780,1773,1766, 1758,1750,1741,1732,1722,1711,1700,1688,1675,1662,1648,1634, 1619,1604,1588,1571,1554,1537,1519,1500,1481,1461,1440,1420, 1398,1377,1354,1331,1308,1284,1260,1236,1211,1185,1159,1133, 1106,1079,1052,1024,996,967,938,909,879,850,819,789,758, 727,696,664,633,601,568,536,503,471,438,405,372,338,305, 271,237,204,170,136,102,68,34,0};  D) "regis.h" file /* regis.h */ /* this is the header file that defines dsp registers */ /*Core Registers*/ int*lMR = (int *) 0x0004; int *GREG = (int *) 0x0005; int*IFR = (int *) 0x0006; /•System Module Registers*/ int *SYSCR = (int *) 0x7018; /* Watch-Dog / Real Time Interrupts / Phase Lock Loop (PLL) Registers int *RTICNTR = (int *) 0x7021; int *WDCNTR = (int *) 0x7023; int *WDKEY = (int *) 0x7025; int *RTICR = (int *) 0x7027; int *WDCR = (int *) 0x7029; int *CKCR0 = (int *) 0x702B; int *CKCR1 = (int *) 0x702D; /* Analog-to-Digital Converter Registers*/ int *ADCTRL1 = (int *) 0x7032; int *ADCTRL2 = (int *) 0x7034; int *ADCFIFOT= (int *) 0x7036; int *ADCFIF02= (int *) 0x7038; /•Digital I/O*/ int *PCDATDIR = (int *) 0x709C; /•General Purpose Timer Registers - Event Manager*/ int *GPTCON = (int *) 0x7400; int*TlCNT = (int *) 0x7401; int *T1CMPR = (int *) 0x7402; int*TlPR = (int *) 0x7403; int*TlCON = (int *) 0x7404; /•Full & Simple Compare Unit Registers - Event Manager*/ int *COMCON = (int *) 0x7411; int*ACTR = (int *) 0x7413; int *SACTR = (int *) 0x7414; int *DBTCON = (int *) 0x7415; int*CMPRl = (int*) 0x7417; int*CMPR2 = (int *) 0x7418; /•Interrupt Registers - Event Manager*/ int •EVIMRA = (int *) 0x742C; int *EVIFRA = (int *) 0x742F; int *EVIVRA = (int *) 0x7432; /*wait state registers */ int*WSGR =(int *) Oxffff;  E)  " i n v l . c m d "  file  /* compile options */ -cr -1 rts2xx.lib -stack 256 -heap 256 -o invl.out -m invl.map MEMORY { PAGE0: PAGE 0: PAGE 0: PAGE 0:  P F L A S H : origin = 0x0000, length = 0x0040 P P R O G R : origin = 0x0040 length = 0x3 fbO P E X T R A M : origin = 0x4000, length = OxbeOO P_B0_RAM: origin = OxfeOO, length = 0x0100 /* If CNF=1 */  PAGE PAGE PAGE PAGE  D B 2 R A M : origin = 0x0060, length = 0x0020 D B 0 R A M : origin = 0x0200, length = 0x0100 /* If CNF=0 */ D B 1 R A M : origin = 0x0300, length = 0x0100 D E X T R A M : origin = 0x8000, length = 0x8000  1: 1: 1: 1:  }  SECTIONS { .ini: > P F L A S H , PAGE = 0 /* DEFINE THE INTERRUPT VECTORS */ .text : > P P R O G R , PAGE = 0 /* initialized - executable code */ .cinit: > P E X T R A M , PAGE = 0 /* initialized - initialization tables */ .switch: > P E X T R A M , PAGE = 0 /* initialized - switch tables */ .const: > D B 2 R A M , PAGE = 1 /* initialized - constants */ .bss : > D B 0 R A M , PAGE = 1 /* uninitialized - global variables */ .stack : > D B 1 R A M , PAGE = 1 /* uninitialized - system stack */ .sysmem: > D_B1_RAM , PAGE = 1 /* uninitialized - sytem heap */ .data : > D E X T R A M , PAGE = 1 /* not needed for C programs */ }  

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.831.1-0064811/manifest

Comment

Related Items