Modelling and Characterization of Power Electronics Converters Using Matlab Tools

© 2012 Fagerstrom and Bengiamin, licensee InTech. This is an open access chapter distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Modelling and Characterization of Power Electronics Converters Using Matlab Tools


Introduction
Advances in semiconductor technologies to produce high power devices have facilitated numerous applications where high power density is a key for practical and sophisticated solutions. Instead of being limited to the traditional low power electronics applications, high power devices opened a broad frontier for engineering design. These devices are now embedded in systems that span the full range from small electric motor drives to very high voltage transmission lines where hundreds of amperes are regulated while the devices are exposed to thousands of volts. Compared to the traditional rotating electric machine based (dynamic) energy conversion, these devices made static conversion from one form of electricity to another so seamless that employing a certain form of electric power (AC, DC, or a combination) has become an engineering design option rather than a forced solution. Application areas like in motor drives, fuel cells, solar panels, wind turbines, electric cars, and high speed transportation systems are only a few of the major beneficiaries of advances in power electronics. Emphases on energy conservation motivated the design for improved system efficiency where power electronics devices are utilized in their most desirable mode. These efforts resulted in increased portability of high power density systems and affected the design of the full range of power systems including those for small electronic equipment which are becoming more demanding on power for their ever increasing features and capabilities. Like all advanced engineering design applications, mathematical developments and supporting software tools for modeling, simulation and analysis are critical (Shaffer, 2007;Assi, 2011). In addition to introducing some of the fundamental concepts in power electronics and related applications, this chapter exploits the capabilities of Matlab and its associated SimPower and Simulink toolboxes as an effective relevant engineering tool.
When dealing with an alternating current, changing voltage levels, at the same frequency, is achieved simply by utilizing AC transformers where the principle of mutual induction exists between two magnetic coils with the proper turns-ratio. Mutual induction is possible due to the rate at which the magnetic lines cut the wires of the transformer coils and the produced electromotive force that is capable of producing current in closed electric loops. This fundamental concept is not applicable to DC voltage and current due to the absence of the alternating nature of the produced magnetic fields. Therefore, changing DC voltage from one level to another must be achieved using different methodologies. One possible methodology is to modulate DC voltages by switching them on and off at proper rates and durations such that the average produced voltage is controlled. The key concept here is to store energy then release it at the proper time with the proper rate needed for the desired load. Energy storage elements like inductors and capacitors facilitate this methodology. Therefore, a combination of energy storage elements and switching schemes provide the basic ingredients for the design of DC-DC conversion devices. Such devices are referred to as power electronic DC-DC converters. The modes of operation of these devices are dependent on the shape of the produced voltage waveform which is manipulated by the switching scheme and the size of the energy storage elements. Compared to AC transformers which usually exhibit linear characteristics for its most modes of operation, DC transformers (DC-DC converters) possess highly non-linear characteristics which require more intensive analysis and design schemes.
Optimization of power electronics systems' design and operation is important to accommodate the growing need for energy efficiency in portable electronic devices to extend their battery life and respond to their increasing functionality and features. These features demand more electric power while the devices must reduce in size and weight; i.e. increased energy density. DC-DC converters are embedded in numerous electronic equipment and they have become an integral part of many commercial and industrial products. These converters are employed to lower (buck) or raise (boost) DC voltage levels as needed by the application. Buck and boost converters are emphasized in this chapter for their different topologies and modes of operation. The presented methodologies facilitate analysis, characterization, and design of efficient DC-DC converters. Sufficient background and theoretical development are provided for completeness.

Static power converters
Static power converters can take numerous topologies which enable AC-AC, AC-DC, DC-AC, and DC-DC conversion. AC-AC converters vary in complexity from the crude chopping of the AC waveform in order to regulate the delivered average power like in light dimmers and electric stove burners to varying the produced frequency like in Variable Speed Drives (VSD) for AC motors. AC-DC converters usually utilize the simple rectifier bridge configuration. They are popular in windmill applications as a front stage before converting to AC for interface with the utility grid. This last stage employs the DC-AC converter which is also popular in applications like solar panels interface with the utility grid. In addition to the AC-DC converter, most household and commercial electronic equipment use DC-DC converters. These converters produce the multiple DC voltage levels necessary for the operation of the equipment. DC-DC converters are also critical for battery powered portable electronic devices where power density is high and efficiency of converters is critical to the charging cycle of the device.

AC-AC converter
Converting AC at the same frequency is most effectively achieved using induction transformers. This is particularly true for high frequency/low-power applications where the magnetic core is relatively small. Applications that require converting to different frequencies, however, can be achieved in several configurations. One configuration may utilize an intermediate stage of AC-DC back-to-back with DC-AC as is the case for wind energy conversion for example; assuming that the wind turbine is coupled to an AC electric generator. Cycloconverters (Rashid, 2004) on the other hand, don't require an intermediate stage as they utilize chopping techniques to shape the waveform directly. Conversion from three-phase to either single-phase or three-phase is usually possible with the proper control scheme. One crude application to regulate power at the same frequency using waveform chopping is that of the light-dimmer (Paul, 2001); used here to illustrate some of the basic concepts. Although light dimmers usually regulate power consumption without altering the fundamental frequency of the source, they provide a more economical solution compared to tap-changing induction type transformers. Fig. 1 depicts the circuit configuration for a simple light dimmer where the primary power control device is the Triac whose gate firing device is the Diac (Skvarenina, 2002). The Diac is a fixed break-over voltage device compared to the Triac that permits a variable firing angle through its gate terminal. Compared to the Silicon Controlled rectifier (SCR) which is also gate controlled, the Triac permits device firing on the positive and negative half-cycles of the AC waveform. The SCR has a similar characteristic to that of a rectifier (unidirectional) but with an adjustable conduction angle (Rashid, 2004). Both devices are self-commutated, i.e. they turn off naturally at the zero crossings of the waveform. The triggering circuit for the Triac is comprised of R1, R2, and C where the potentiometer R2 represents the adjustable resistor which is usually operated by the dial (or slide switch) on the operating plate of the light dimmer. The value of R2 controls the conduction phase of the Triac. As the capacitor charges to a voltage higher than the break-over voltage of the Diac, a pulse is produced at the gate of the Triac to turn it on. In the conduction mode, the internal resistance of the Triac becomes small causing the flow of current through the light bulb. A higher value of R2 elongates the charging time of C (longer time constant τ=C(R1+R2)), causing a delayed triggering pulse and a shorter conduction period for the Triac. The average power transmitted to the light bulb becomes less, resulting in a dimmer light. The same logic works for both halves of the source's waveform cycle. This application will be analyzed using Matlab in Section 4 to demonstrate some of the capabilities of the SimPower and Simulink tool boxes. Several practical notes relative to the circuit in Fig. 1 are due, 1. While it may seem that the Diac is an unnecessary device in this application since the voltage of the capacitor may trigger the gate of the Triac directly, it must be noticed that Triacs are notorious for not firing symmetrically. Lack of symmetry in triggering at the same voltage level for both polarities of a full cycle produces unnecessary additional harmonics that negatively affect the efficiency of the circuit. The symmetrical characteristic if the Diac provides accurate timing that enhances the firing symmetry of the Triac. 2. One may use two SCRs back-to-back to implement the power control device in place of the Triac. 3. The firing time through the RC circuit is perfectly synchronized with the conduction cycle of the Triac because they are both powered by the same AC source.

DC-DC converter
Converting DC voltage to the proper levels from a single energy source that might be depleting, like in battery applications, requires employing energy storage elements (inductors) with associated power electronics devices. When switched ON-OFF at a certain rate, stored energy gets released to the load at the proper time to maintain the desired voltage level. Pulse-Width-Modulation (PWM) techniques are most popular in this application. Converters of this type are suited for boosting or bucking the source voltage; commonly known as switching power supplies. Since the current is DC and zero crossing is not one of the steady cyclic features like in AC circuits, self-commutation is not possible. Therefore, Gate-Turn-Off (GTO) devices are required (Skvarenina, 2002). These devices are turned off with a negative pulse on the gate terminal. MOSFETs and BJTs also provide a viable option in low power applications. Feedback loop methodologies are an integral part of DC-DC converters to regulate the load voltage, compensating for load variations and irregularities in the source voltage.
Current and voltage ripples, and high frequency harmonic distortion are common byproducts of switching techniques. Capacitors are usually employed to insure acceptable ripple content. Harmonics negatively affect the efficiency of the converter and produce losses in the form of heat. While the produced load current is regulated for a desired average value, the cyclic behavior produces current fluctuations in the energy storage elements. Operating at zero current for energy storage elements during part of the cycle results in a highly nonlinear characteristic, where the converter is known to be in its Discontinuous Conduction Mode (DCM). The Continuous Conduction Mode (CCM), however, insures nonzero current during the full cycle of switching (Rashid, 2004;Shaffer, 2007). Each mode of operation has certain implications on the ripples and harmonics content which affects the efficiency of the converter.

Buck converter
In low power applications, voltage bucking is usually achieved using voltage divider resistors. This simple solution is acceptable because the current is usually too small to cause significant losses in the resistors. Employing this approach in high power applications is unrealistic because the losses of the resistors may exceed the useful power consumed by the load; that is in addition to the associated heat dissipation issues that must be resolved to insure sufficient ventilation. The DC-DC converter provides a more practical solution in spite of its associated design complexities at times.
Bucking DC source voltages can be achieved using a topology like the one shown in Fig. 2. The energy storage element (L) is to be sized for the desired mode of operation (CCM or DCM). The power device (GTO in this case) switches On-OFF using PWM where the dutyratio (D=Ton/T) determines the average load voltage; T is the time of one period of the switching frequency (f). The diode facilitates inductor current wheeling during the OFF time of the GTO. The capacitor is usually sized to reduce the load current ripples. The inherent inductor current ripples (usually in the range of about 30%) are then facilitated by the capacitor while blocking it from flowing through the load. Snubber circuits are installed across the power devices for protection and to minimize the stress on the device that may result from opening the circuit while the current cannot be stopped instantaneously due to the nature of the energy storage element. Current and voltage waveforms will be shown in Section 4 for illustration. Design of the DC-DC converter centers around determining the size of the energy storage element (L) which achieves predetermined Vsource, Vload, ∆Vload (load voltage ripple), and Iripple. Knowing that Iripple=∆IL, D=Vload/Vsource assuming CCM, T=1/f, and VL=Vsource-Vload during Ton (Rashid, 2004), Eq.
(2) can be obtained. Since, Notice that L is charging during Ton only, which means that ∆T=D/f. The calculated "L" is usually well above the minimum inductance needed to insure CCM in many applications.
Only very light load conditions may force DCM.
The capacitor "C" is sized to reduce load current ripple while providing a pass for the inductor current ripples (Iripple). It is worth noting that the inherent Effective Series Resistance (ESR) of the capacitor plays a major role in determining the size of the capacitor. Since, Eq. (5) shows that the capacitor's ESR rating can have a significant effect on the size of the capacitor knowing that the tolerated ∆Vload is usually small in sophisticated applications. Therefore, the ESR rating shouldn't be overlooked when selecting the capacitor. The Effective Series Inductance (ESL) rating of the capacitor is also relevant but it is usually considered for very high switching frequencies only (>1 MHz). By then, inductive effect of board tracings can start to be critical as well.

Boost converter
While bucking the source voltage for low power applications can be achieved with resistor voltage dividers (passive components), boosting the voltage requires active devices like Operations-Amplifiers (OpAmps). Power OpAmps are also available for low-voltage medium power (500 Watt) applications but they usually exhibit high power loss and they need active cooling (fans) in addition to passive cooling via heat sinks. OpAmps are also analog devices which are usually controlled with analog control voltages, while PWM controlled power devices can be easily interfaced with digital controllers. Real-time load voltage regulation is achieved most effectively with embedded digital controllers.
By rearranging the components of the buck converter as shown in Fig. 3, it becomes possible to boost the source voltage. The underlying principle of operation is in the fact that the polarity of the inductor (L) voltage reverses instantaneously when the rate of change in the inductor current (iL) reverses pattern; i.e. diL/dt changes sign. During the ON time (Ton) of the GTO, the inductor charges with its voltage taking the opposite polarity of the source. When the GTO turns OFF during Toff, the inductor current starts to drop and accordingly its polarity reverses direction to become in the same direction like the source. The load, then, becomes supported by Vsource plus VL which signifies the higher load voltage compared to the source voltage. The role of the capacitor is similar to that of the buck converter, that is to reduce the ripples of the load voltage as it supports the load voltage during Ton in this case. It must be noted that VL is equal to L(diL/dt) which means that the inductor voltage can rise significantly if the current is allowed to change at a high rate, resulting in load voltages much higher than that of the source. The inductor, however, must be sized properly and allowed to charge enough by increasing the duty-ratio (D) of the PWM scheme such that it stores enough energy to feed the load during Toff. The ratio Vload/Vsource is determined by 1/(1-D) which implies that Vload can rise well above Vsource as the duty ratios gets closer to 100% (Rashid, 2004). The physical limit of the employed components is usually the determining factor for how high Vload may be attained.

Buck-boost converter
Rearranging the components as shown in Fig. 4 provides the flexibility to buck or boost the source voltage by adjusting the duty-ratio (D) of the PWM. A 50% duty-ratio provides the load with the same source voltage while a lower duty-ratio bucks the voltage and a higher duty ratio boosts the voltage (Rashid, 2004). It was proven that Vload/Vsource is determined by D/(1-D). The orientation of the diode is such that the load current is blocked while the inductor is charging during Ton. During Toff the inductor releases its energy to the load through the diode loop resulting in an opposite voltage polarity compared to that of the buck or boost configurations. The size of the storage element (L) is critical to facilitating the boost mode. To insure CCM, the inductor must be of a certain minimum size (Rashid, 2004). Current and voltage waveforms will be shown in Section 4 for illustration.

Voltage control
Control of switching power converters requires modulating the width of the pulse provided to the power devices' gate, based on feedback from the load voltage and the inductor's current. Fig. 5 illustrates the basic components of an analog control scheme; where the output voltage provides the desired feedback. This scheme is identified as the "voltagemode" control. The low-pass filter (R3, C3) of the error amplifier along with R1 provide feedback gain and reduce harmonics. The PWM hardware can be a typical controllable IC and the Schmitt-trigger is to produce sharp edges for the power device's gate. Needed high gate current usually requires current amplification as well.
The compensator can be implemented with Op-Amps to realize desired dynamic characteristics for voltage recovery and regulation. Traditional compensators like PID, leadlag, and Sliding Mode Control (SMC) are all applicable. Digital control, however, provides flexibility in implementing sophisticated control schemes and mixed mode operations to achieve power saving and to possibly automatic controller tuning. Digital schemes also reduce magnetic interference effects which would most probably exist in applications that require DC-DC power conversion. Digital Signal Processors (DSPs), microcontrollers, and Field Programmable Gate Arrays (FPGAs) together with the Analog-to-Digital Converter (ADC) are widely used to implement digital controllers. However, high-speed highresolution ADCs are expensive and they are not easy to consolidate into an integrated circuit.
Design of the compensator requires transient analysis and solving the differential equations that describe each waveform. Retaining the instantaneous detailed characteristic of the circuit requires analysis of each mode of the switching cycle. This level of detail is usually not necessary for the design of the compensator. Averaging over a number of switching cycles provides viable approximate models (Forsyth & Mollov, 1998) which simplify the compensator design significantly. In this technique, the state equations for the RC circuit are written for both modes of the converter (ON and OFF). A combined state equations model is then formed using the weighted average of the state matrices of the ON and OFF models according to the duty ratio (D). The produced model is a set of two linear time-variant state equations which ignore ripple components. The time-variant effect is due to the presence of the control variable "D(t)" (varying duty-ratio) in the state matrices rather than being part of the input control variables vector. Since solving time-variant equations is difficult, further simplifications are required. Linearization techniques are then employed for specific operating conditions, resulting in small-signal state-space models (Johansson, 2004). These models facilitate frequency and time domain design methodologies. In addition to the above explained voltage-mode control scheme, current-mode control can also be achieved by sensing the current of the switching power device or the energy storage element and integrating it into the main voltage control loop (Johansson, 2004). In this scheme, the output of the voltage compensator acts are the reference voltage for the current feedback loop which controls the PWM and adjusts the gate pulse for the power device. This scheme usually improves the stability of the converter in high performance applications.
Controlling the peak inductor current is one of the popular schemes employed. Current sensing can also be used to determine when to switch between CCM and DCM which facilitates implementing high efficiency schemes for operation.

Power saving and improved efficiency
Minimization of DC-DC converter power losses is important to accommodate the growing need for a longer battery life and reduced size and weight of portable electronic devices. Power losses are usually dependent on the type of power devices and their conduction losses, the effective series resistance of inductors and capacitors, mode of operation of the converter, switching scheme, and the switching frequency. While diodes are simple in their use, they may reduce the efficiency of the converter due to their high losses in certain modes of operation. The same function of a diode can be achieved by using a switching power device similar to the main energy transfer device of the converter (e.g. GTO or MOSFET).
This will require applying switching logic to multiple devices in the same converter. Synchronizing the switching of the devices introduces an additional control challenge and the converter topology is therefore referred to as the "synchronous" topology. The diode topology is then called "asynchronous". A detailed characterization of power losses in DC-DC converters is offered by Gildersleeve, et.al., (2002).
The basic asynchronous and synchronous converter topologies are given in Figs. 6.a and 6.b, respectively. Table 1 lists the sources of losses considered assuming a MOS switching device.   Extensive lists of DC-DC converter losses may be found in Zhou, S. (2003) and Djeki, O. & Brkovic, M. (1974). Buck-boost converter losses considered in this work are given in Table 1, as itemized and developed analytically in the following subsections. The PMOS is used for the Source Switch (SS) and NMOS is used for the Load Switch (LS), respectively.

a. PMOS Source Switch Conduction Loss
When the PMOS transistor is in forward conduction there is a resistive loss in accordance with Eq.(6). PMOS conduction loss is associated with both asynchronous and synchronous converters (Gildersleeve et al, 2002;Klien, J., 2006).  Combining Eqs. (7) through (12) gives the combined switching loss Eq. (13).
Where, ileakage=reverse bias leakage current, VLS=load switch drain to source voltage.

h. Synchronous Switching Dead-Time Loss
Dead-time loss occurs through the load switch when neither transistor is on as the load switch is in forward conduction (Klien, 2006). A period of dead-time must exist to prevent current "shoot-through" whereby current flows through both switches simultaneously to the load. The value of tdead is assumed to be 60 ns as is typical for DC-DC converter controllers (Djekic & Brkovic, 1997 Where, VD=voltage across diode.

k. Diode Junction Capacitance Loss
Diodes have a certain capacitance associated with changing voltages across them (Klein, J., 2006). The charging and discharging of this capacitance creates a power loss as modeled by Eq. (20). Diode junction capacitance loss is associated with only the asynchronous converter.

Matlab capabilities
The Matlab simulation platform (by MathWorks, Inc.) offers a versatile and robust option in design and simulation of power electronic converter systems. Matlab is matrix based, offering diverse options in data manipulation, preparation, and presentation. Simulink, a sub-program of Matlab included in the standard software package, offers a relatively high-level programming language utilizing drag-and-drop function blocks that mask embedded functions. These icons can be incorporated into yet larger models and again masked into new system blocks. This modular block-symbol based modeling system allows ease of construction and programming of large complex systems while maintaining the ability to edit and control internal systems all the way down to the most base-level functions.
The power electronic system designer upon starting Simulink, then, is entering the design process at the phase of assembly of power electronic, measurement, and signal routing components into larger more complex systems to accomplish a desired task. The designer may from time to time wish to delve into base Simulink models to change component characteristics and behavior, add base-level monitoring of characteristics, change signal routing, confirm calculation methods, or even develop system models from scratch.
This section is intended for the Matlab user who possesses basic workspace programming knowledge. Many resources are available to learn or refresh on Matlab workspace programming, including the help files included with the Matlab software. Matlab help files are an invaluable resource in workspace and Simulink programming and are recommended for perusal.

SimPowerSystems toolbox
Simulink provides a rich suite of toolboxes applicable to wide areas in engineering applications. The power electronics devices discussed in this chapter are simulated using "SimPowerSystems", a versatile toolbox for modeling electro-mechanical systems. In addition to popular power electronics devices, this toolbox provides a wide range of simulation apparatuses such as transformers, rotating machines, hydraulic turbine & governor, and wind turbines, as well as basic electric circuit components. Detailed characteristic parameters can be configured for these components to represent typical performance scenarios. To monitor the performance of constructed models, a host of measurement blocks are available for discreet, continuous, and phasor based measurements. Relevant variables like active & reactive power, total harmonic distortion, and power factor can be monitored with ease. Custom functions can also be set up with simple manipulations. Since this chapter deals with power electronics applications, attention is focused on the Power Electronics block-set which includes several power electronics semiconductor simulation blocks relevant to industry, Table 2. Devices shown in Table 2 are modeled into systems with other standard Simulink and SimPower devices, some of which are presented in Table 3.

Simulation parameters and data presentation
For proper numerical computations Matlab provides various simulation options including the specific numerical method (solver), the allowed tolerance, and mode of computation. Since some numerical methods are more computationally intensive than others, the user may choose a less intensive method for simulations that don't require solving highly nonlinear differential equations, for example. This improves the efficiency of the simulation and accelerates obtaining results. Some trial and error may be necessary to achieve a successful simulation. However, the default simulation options can typically be used for most simulations. If the simulation takes too long to execute or the computed data is incomplete, is at an unacceptable resolution, or has errors, it will be necessary to change simulation parameters. Highly complex simulations may require some time invested in finding the correct solver for the application in order to achieve a good balance between accuracy and computation times. The Configuration Parameters dialog box is found under the Simulation tab in Simulink, Fig. 7. Usually the best choice is to leave these set to "auto" to allow Simulink to determine simulation parameters automatically, based on the model.

A B C
The solvers are categorized into two general types: Fixed step, and Variable step. Fixed step simulations evaluate in user-set time steps that are constant throughout simulation. Variable step solvers dynamically change the simulation step size to optimize simulation time vs. accuracy. Therefore, the goal in choosing the solver is to find the least computationally intensive method that yields the level of accuracy required. Solver types are summarized in Table 4.

Configuration of SimPowerSystems blocks
Simulation of any SimPower circuit involves parameter configuration within model blocks after circuit is constructed. This is achieved by double-clicking on the circuit block to reveal block parameters. Table 5 shows the possible block configuration parameters for common SimPower power electronic devices. A user may also elect to use typical values provided by default. The parameters of Table 5 can be classified according to the following: Ron, Lon, Vf are applicable during forward conduction of current, current 10% fall time and current tail time are applicable during shut-off, and snubber resistance and snubber capacitance affect the circuit during the OFF condition.
The definitions of Ron, Lon, and Vf are evident by inspection of the typical power electronic device circuit diagram shown in Fig. 8.

Figure 8. Example SimPower Power Electronic Device Equivalent Circuit
Initial current is the amount of current in amperes flowing through device at the start of simulation. Snubber resistance and capacitance (Rs and Cs) are self-evident for snubber circuits. Latching current (Il) is defined as the amount of current required for thyristor to become self-commutated. Turn-off time (Tq) is defined as the minimum amount of time required for the voltage across anode and cathode to be zero or less to avoid the device automatically turning on again when a forward voltage is seen. Current fall-time and tail time are explained in waveform shown in Fig. 9 (from Matlab help file). Internal diode resistance of the MOSFET (Rd) is explained in Fig. 10.

Simulation, analysis, and design
A Matlab script file can accompany simulations performed in the Simulink environment. Script files provide ease in defining and computing variables from a single location which allows the model to be general and applicable to many different cases as well as maintain uniformity in plotting and results presentation. If modification of parameters is desired, the changes are easily accomplished by changing the numbers in the workspace and repeating the simulation. This general-modeling functionality is a distinct advantage of Matlab over Multisim.
Simulink offers a simple and versatile platform for equation modeling. Practically any equation can be implemented in Simulink following an easy and direct method. Consider Eq.
(1), the inductor voltage as a function of inductor current -these are the input and output variables of what can be implemented as a small subsystem in Simulink. The first modeling step can be to introduce variable routing tags for each input and output variable as shown in Fig. 11 (a). Next, consider the intermediate mathematics of the function. It is observed that the equation involves multiplication by a constant and a derivative -therefore drag these function blocks into the Simulink workspace and connect appropriately, Fig. 11 (b). For example Eq. (1) is simulated as in Fig. 11 (b). Following the signal step-by-step as shown in Fig. 11 (c) reveals that the subsystem output is the voltage of the inductor based on the input current to the inductor. The equation is therefore successfully modeled. It is well to mention that the model shown in Fig. 11 is an analytical exercise only; physically implementing the model shown is not recommended as the differentiator will amplify noise in a real system.
As an exercise to bring together the concepts discussed of blocks performing functions based on embedded subsystems and equation modeling, consider the non-linear signal created with the Matlab program shown in Fig. 12. The signal shown in Fig. 12 can be imported into the Simulink model with the "From Workspace" block and evaluated for total harmonic distortion (21) as shown in Fig. 13. Compare the top three forward paths of the block diagram in Fig. 13 to Eq. (21). It can be seen that the signal has been successfully evaluated for Total Harmonic Distortion (THD) of the given signal (neglecting harmonic content beyond the 3 rd ). Now consider the fourth forward path of the block diagram and compare the THD measurement blocks at the rightthe results are identical illustrating the embedded mathematical functionality contained in Simulink blocks. To explore further, right-click on the Simulink THD block, choose "Look Under Mask", and compare mathematical functionality.
Applying the same modeling techniques shown in the THD example in an effort to aid in optimization of power electronic converters and to exemplify the block modeling concepts discussed, the loss equations introduced in section 2.4 have been modeled in Simulink (Fig.  14) for the buck-boost converter and combined into a Simulink model block (Fig. 15). The Buck-Boost Converter Power & Efficiency block is used in section 4.3 for converter optimization.

Light dimmer
Consider the light dimmer circuit introduced in section 2.1. A good first step in simulation of this circuit is to understand the range of available output voltage and power as controlled by varying the potentiometer R2. As R2 is adjusted between its minimum and maximum resistance values, Matlab can be used to plot the waveforms to illustrate the output characteristics of the circuit. The light dimmer TRIAC is self-commutating as introduced in To find the output power of the light dimmer circuit, the light dimmer voltage waveform shown in Fig. 16 can be evaluated for RMS current over one-half period (as negative portion of waveform is symmetrical) giving, It follows that, where α = firing angle of TRIAC The relationships shown in 23 and 24 can be plotted in the Matlab workspace as shown in Fig. 17, assuming a supply of 120VRMS, 60 Hz, and light bulb impedance of 576Ω (purely resistive -inductive effects negligible).  To examine light dimmer circuit behavior in more detail and observe waveforms, the circuit can be implemented in Simulink. The model can be constructed as shown in Fig. 18. Simulink blocks are added to the model simply by dragging-and-dropping from the Simulink Library Browser, while connections between blocks are accomplished by singleclicking and dragging to appropriate nodes. The blocks shown are color coded by type of block as organized within Simulink as follows: orange -SimPower sources, red -SimPower power electronic devices, magenta -SimPower elements, light blue -SimPower measurements devices, dark blue -standard Simulink blocks. Some devices shown in Fig. 18 are identical to those introduced in Fig. 1, such as resistors and capacitors. The DIAC is represented by two diodes placed to conduct current in opposite directions (for AC) as diodes exhibit the same self-commutating behavior. The TRIAC is implemented using two thyristors to pass AC current in much the same way as the DIAC, the difference being the active control input at the gate. Thyristors are chosen in SimPower for their self-commutating behavior and representation of TRIAC characteristics. Double-click model blocks to set parameters according to those shown. %% Light Dimmer Power and Voltage as a Function of Firing Angle clear; close; %clear previous data Vm=120*sqrt(2); %voltage signal R=576; %ohm -bulb impedance (j0) alpha=0:pi/180:pi; %scale output to degrees in workspace for m=1:length(alpha) P(m)=(Vm^2/(2*R))*(1-(alpha(m)/pi)+(1/(2*pi))*(sin(2*alpha (m)))); % SCR formula*2 for TRIAC & resistive load end subplot(2,1,1); plot(alpha*(180/pi),P); grid; xlabel('degrees'); ylabel('Watts'); title('P vs. alpha'); %plot results Vl=sqrt(P*R); subplot(2,1,2); plot(alpha*(180/pi),Vl); grid; xlabel('degrees'); ylabel('Volts RMS'); title('V vs. alpha'); Note the block in Fig. 18 labeled "powergui" near the AC voltage source. This block automatically appears upon running a SimPower simulation, and is required. The powergui contains configuration functions such as initial states, machine initialization parameters, FFT analysis, and other useful tools, albeit none are utilized in this chapter.
The results of evaluating the light dimmer circuit in Simulink are shown in real time as the simulation progresses on the numerical readouts. After the simulation is completed, double-clicking on the "Vload" scope icon reveals a waveform similar to Fig. 19. The waveform of Fig. 19 shows the self-commutation behavior discussed earlier in that, once fired, the TRIAC passes current until the voltage across it drops to zero. Note the time that the gate voltage spikes to 1 is the exact time that the TRIAC fires and allows the source voltage waveform to pass until the current drops below the holding current IH which occurs in this ideal case at I=0. Also notice the waveform that fires at approximately 10ms is slightly distorted -this asymmetrical firing of the TRIAC's occurs for a brief period until the converter stabilizes. The light dimmer circuit was also constructed using physical components and tested for validity. A 60 Watt light bulb was light controlled using the Littlefuse Q2015L5 TRIAC and the STMicroelectronics DB3 DIAC. The Fluke-41 Power Harmonics Analyzer was the primary waveform capturing device (Fig. 20).
Graphical comparison of simulated and experimental results shows very good agreement. Observe the symmetrical firing angle on both halves of the waveform as presented and discussed earlier -this provides confirmation of a successful design concerning firing angle symmetry. Simulated and experimental data were taken for firing angles ranging from 28° to 155° and recorded as presented in Table 6. There is good agreement between the simulated and experimental data given in Table 6. The values diverge particularly toward the upper firing angles. Divergence and inconsistencies are expected due to variations in the load resistance due to thermal effects. THD is expected to be lower for low firing angles as less harmonic components are present in undisturbed waveforms closely resembling the smooth curve of the input sine wave. The more the voltage waveform is modified by the TRIAC firing at higher angles the more high frequency components are produced, and therefore the more total harmonic distortion.

DC-DC converter
A designer concerned with the behavior of DC-DC converters introduced in earlier sections may wish to consider the voltage gain of the buck, boost, and buck-boost converters as a starting point. The Matlab workspace can be used to plot Vload/Vsource as introduced in section 2.2 for each converter to graphically represent the curves for consideration.
Recognizing that duty ratio ranges between 0 and 1 for all PWM converters, a Matlab workspace script program is used to create the plot shown in Fig. 21 to show output voltage of each type of DC-DC converter introduced in section 2 as a function of duty ratio. Note the asymptotic behavior of the boost and buck-boost at higher duty ratios.

Buck DC-DC converter
The buck converter was introduced in section 2.2.1 including equations 1 through 5 which describe buck converter behavior. To further develop tools in power electronics design in Matlab, consider the following design example.
It is desired to design a buck converter for a particular automotive application. The supply voltage in a typical automobile while running is 13.8 volts. The device to be powered is purely resistive at 100 ohms and requires a constant 5 volt supply. A maximum of 5% current and voltage ripple is desired. The design has physical size constraints, so a switching frequency of 100 kHz or above is decided upon to keep inductor size at a minimum. Analytically, minimum inductor size is given by Eq. (25) (Shaffer, 2007)  The analytic development of parameters may be used for simulation, but Matlab/Simulink offers another option. A Matlab program can be created to calculate and store system parameters, and used to support a Simulink simulation. First, the following script program is written to calculate system parameters (Fig. 22).  Merely by executing this program the values of C and L will be written to the Matlab workspace, and are also saved into temporary memory for use in a Simulink simulation. Such a simulation is constructed as shown in Fig. 23 for the buck converter. Note the large red arrow in the script program which shows a command that is commented out. If we wished to evaluate this circuit with proper design considerations for current ripple, this line can be commented back in to the program. However, for the purpose of examining the behavior of the converter at the CCM/DCM borderline, the value of LCCM is used for the following evaluation. The capacitor size automatically changes accordingly ; %ohm -load resistance, purely resistive assumed (j0) P=1/fs; %Second -switching period d=Vout/Vin; %unitless ratio -duty ratio calculation Lccm=(((Vin-Vout)*R)/(2*fs*Vin)); %Henry -minimum L value for CCM Lambda=(2/iripple)*(Vout/R); %inductor scaling factor -intermediate calculation L=Lccm %Henry -inductor size at absolute minimum for CCM %L=Lccm*Lambda %Henry -inductor size accounting for current ripple C=(1-(Vout/Vin))/(8*L*vripple*fs^2) %Farad -capacitor calculation when the program is reevaluated, highlighting the great advantage that computer-based systems have over analytic calculations: the ability to modify parameters at will without having to perform additional calculations. The circuit is set to run over the duration of 0 to 100*P, with all simulation settings default except Max step size set to P/20 to increase resolution. Examine and consider the actual simulation values shown in the Simulink simulation diagram of Fig. 23, and waveforms shown in Fig. 24. Note the values of L and C and other values shown in the upper left of the Simulink diagram as calculated from the workspace program. Observe the buck converter's inductor current characteristics operating on the borderline of CCM and DCM behavior by nearly falling to zero. A related behavior is observed in the inductor voltage waveform as the energy contained in the inductor field exponentially decays nearly to zero before the source-switch closes and raises the voltage level. Also note the instantaneous voltage polarity change on the inductor -this capability is what makes power electronic converters possible (keep in mind that when the polarity across the inductor is negative, current is still flowing in the same direction through the load). The slight variation in load current is observed exhibiting ripple behavior. The circuit's efficiency is also evaluated at 92% with the loss model block developed in section 4.0.

Buck-boost DC-DC converter
Continuing with practical designs, consider an application for a portable electronic device that requires power such as a laptop or cellular phone. These devices require precisely controlled voltage levels for supply to sensitive electronics. Batteries, however, do not exhibit stable output voltage characteristics as illustrated in Fig. 25 for two typical battery types. As the battery undergoes its normal discharge cycle, its supplied voltage varies significantly as Fig. 25 shows. A solution is required in order to provide a relatively constant input voltage to electronic devices fed from a source whose voltage varies. The buck-boost converter is very effective for this application as it can provide a well regulated load voltage, as discussed in Section 2.3.
Assume a designer wishes incorporate a converter for its voltage stability characteristics into a portable electronic device. Portable electronics require continuous current in order to retain information in volatile memory registers, therefore CCM mode is required. The designer will be concerned with minimizing the power losses of the converter in order to provide the maximum battery life possible. Simulink provides an effective option to determine optimal configuration of parameters to maximize efficiency. The synchronous converter as introduced earlier can be modeled in Simulink as shown in Fig. 26. The asynchronous converter is modeled by changing the active load switch to a diode, and changing the power & efficiency calculation block accordingly (see Fig. 15).
Parameters for simulation are defined in a workspace program according to data sheets for the IRFP450 MOSFET and SB245E Diode, as these are common devices. A median battery supply voltage of 5 volts is chosen as well as a 5 volt output from the converter as this is a common required voltage for electronic devices. Simulated buck-boost inductor behavior as described earlier is plotted in Fig. 27.
The synchronous and asynchronous buck-boost converters can be evaluated at various load currents in order to yield the overall efficiency of each in order to optimize power transfer. After some trial runs are executed to explore the range of load current that should be simulated, a minimum and maximum load current test range of 1mA to 1A are chosen. The converters are evaluated accordingly; efficiency data is recorded, and subsequently plotted in the Matlab workspace as shown in Fig. 28.
The curves shown in Fig. 28 can be used to select the appropriate buck-boost converter topology and design load current for various applications. If inductor size is not a consideration, the designer will elect to use a synchronous converter at a switching frequency of 10kHz as this configuration yields maximum efficiency for all loads examined (keep in mind that larger inductors allow lower switching frequencies). If perhaps size is a consideration and a minimum switching frequency of 50kHz must be used, the designer will choose a 50kHz asynchronous converter for loads ranging from 10mA to ~50mA, and a synchronous converter for loads above 50mA. Other considerations may regulate various switching frequencies, topologies, and load current such as harmonic considerations, available control circuitry for the load switch, etc. - Fig. 28 can be used for these various applications to choose the most efficient converter configuration.

Conclusion
This chapter gave a general overview of AC and DC converters with special emphases on DC-DC converters and their applications. The different topologies were discussed and the importance of designing for efficiency and energy saving was emphasized. Design and analysis steps were illustrated using Matlab and Simulink as an engineering tool.