SPICE is a program that was originally developed at UC, Berkeley in the 1960s. Since then, there have been many commercial implementations of it, and one of them LTspice is freely available now and I think works very well. Here's an example which we're going to talk about in this lecture. One enters the schematic of a circuit. In this case, a buck converter. Then, SPICE can numerically calculate things of interest in the converter such as the waveforms in a transient analysis, as well as other things like frequency analysis plots. So, here is a turn-on transient of a buck converter where the output starts at zero. The green wave form here is the output voltage that it computes, it goes through some turn-on transient and eventually settles down to a DC voltage that is approximately for the buck converter approximately equal to the input voltage multiplied by the duty cycle. Also in red, here is a plot of the inductor current waveform during the same turn-on transient. To get started, what you should do is follow this link to the LTspice website. From there, you can download free copies of the software either for Windows operating system or for the Macintosh operating system. From this Coursera website, you can also download a zip file containing the buck converter circuit files for this example. So, when you've done that, then you can double-click on this file buck.asc which will open the file in LTspice, and that file contains the circuit schematic. Then, what you do is press the run button to start the simulation. When the simulation will take maybe 10 or 20 seconds to run. When it's done, then to display a waveform, you can click on a node and it will give you the node voltage. Or you can click on an element and it will plot the current through the element. Okay. Here, I have opened LTspice and opened the buck converter schematic. We have here, this is the buck converter power stage with the input voltage Vg of 24 volts, and output voltage that supplies a five ohm load resistor. Here is the LC filter. The switch in the buck converter is realized with this power mosfet and power diode. The circuit has a driver and a pulse width modulator, these are called behavioral models or mathematical models of these functions that we have developed for this Coursera course. So, the pulse width modulator takes a DC input voltage. Here, Vduty that has a value of 0.4 volts DC, and it produces an output logic signal C that switches on and off hat with a duty cycle that is determined by the duty, here the duty cycle of C will be 0.4. It has a switching frequency that is set by the pulse width modulator and you can right-click on the pulse width modulator and enter the switching frequency. In this case, the switching frequency is set to 100 kilohertz. This signal c goes into the driver. The driver produces an output voltage to drive the gate of the mosfet with respect to its source at the proper voltage to turn the mosfet on and off according to the signal c. So, to run the simulation, we put the cursor on the run button, the little running person there and click it. It will take maybe 10 or 20 seconds for the simulation to run. Okay, the simulation is done. LTspice has opened a new window here for plotting waveforms, and we can move the cursor over the schematic to different places to plot different waveforms. So first, let's look at what the pulse width modulator is doing. I will move the cursor over the pulse width modulator input, the cursor changes into a little voltage probe signal. If you click there, it will plot that voltage. Okay? So, the voltage is 400 millivolts or 0.4 volts. We can look at the output voltage that the pulse width modulator makes. So, I'll move the cursor over c. Okay. The blue signal, here is switching up and down with a frequency of 100 kilohertz. Let's get the magnifying glass and zoom in on part of this, maybe over here. So, the blue waveform is c. The control signal, it has a switching frequency of 100 kilohertz corresponding to a switching period of one over 100 kilohertz or 10 microseconds. The signal is high for the duty cycle times 10 microseconds which would be 0.4 times 10 is four microseconds. Okay? I'm going to erase these waveforms and now we'll look at some converter waveforms. So, to erase a waveform, what you do is right-click on the name of the waveform here on the plot. So, right-click on the PC or you tap the trackpad with two fingers on them on the Mac and select delete this trace. Let's plot now the switch node voltage. So, we have to click on the window of the schematic. Then, when we hover over the switch node right here at the point between the transistor and diode, we can click with the pseudoscope foliage probe symbol and get a plot of the switch node voltage in green. So, when the mosfet is on for the DTS period, the switch node is equal to Vg like this, and we have 24 volts for Vg. Then when the transistor's off, the diode comes on and the switch node voltage is equal to ground essentially and so we have zero volts or a low voltage. Let's plot the inductor current also. So, when I hover the mouse over the inductor, the pointer turns into a little current probe to measure current in the inductor with positive current in the direction showed by the red arrow. So, let's just click there. The blue trace then is a plot of the inductor current, it goes up and down like this. It's switching are varying between about 2.6 amps and about 1.1 amp. Okay? Finally, we can plot the output voltage, so we'll take the mouse and hover over the output voltage and click. So, the red line is the output voltage, it looks like it's between nine and 10 volts. Now, we expect the output voltage of the buck converter to be the duty cycle times the input voltage, so V should be equal to the duty cycle times Vg. Vg is 24 volts and the duty cycle is 0.4. So, 24 times 0.4 is 10 volts. What we find as the output voltage is a little bit less than 10 volts, but it's close. The SPICE simulation includes some of the loss mechanisms in the converter. It includes the forward voltage drops of the transistor and diode. Here, I put a little resistor in series with the inductor to model the resistance of the wire used to wind the inductor. These things all cause voltage drops that make the output voltage a little less than we would ideally expect. We'll model those things in module three of this short course and develop some equivalent circuit models that predict more accurately what the output voltage is. Let's plot the input current waveform. I will select the schematic window and hover the mouse over Vg. You can see that again, it turns into a current probe symbol. The arrow is pointing from top to bottom in Vg, which means current is flowing from plus to minus through Vg, which is backwards from the direction we actually expect the current to flow. So, SPICE is going to plot this current with a negative sign or make it negative. Here's a plot of it. When the transistor is on, the current follows the inductor current, again, with a minus sign. When the transistor is off, the transistor current is zero and so the Vg current is zero also. We also have this current spike here and this is caused from the reverse recovery of the diode and from the transistor and diode switching times. This is another source of loss called switching loss, which we're going to study in the next short course of this course. We can measure voltages and currents using SPICE. What we do is we press the control button and click on the name of the waveform, and then a window comes up that tells us the average value and the RMS value of the waveform. So, the current drawn out of Vg, this I of Vg, has an average value or DC component of here, 707 milliamps. So, we're drawing 707 milliamps on average of current out of Vg. This current includes the current spike during the switching times. We can use this function to measure input currents and output currents and voltages as well, and calculate average powers and efficiencies of the converter. Likewise, we can plot the current that the gate driver draws out of its power supply. So, what I do, again, is select this schematic window, hover over the power supply for the gate driver and click there. We'll get the current waveform of the gate driver, which looks like this. The gate driver must draw a current out of its power supply to turn the MOSFET on. So, we see these current spikes happening. So, the gate driver requires some power to operate. We can measure the voltage and current of the gate driver and calculate its power as well. So, I will control click on that waveform. Here, we see that there's an average current of 14.876 milliamps drawn out of the driver. That's the average value of the waveform. It's actually coming in spikes that are considerably higher, but the average current is the DC component of current. The average power drawn out of the gate driver supply then would be this average current, multiplied by the gate driver voltage of 12 volts. Briefly, here are a few more details regarding the models that we have provided for the pulse width modulator block and the gate driver block. The functionality of this block is that it produces an output logic signal C, having a duty cycle given by this formula. So, it's a function of Vc, the input voltage, it can have an offset and it can, also has a gain, so it's divided by some effective number V sub m. You can right-click on this block to set values for those things. The offset voltage in VM. Right now, VM is set to one volt, the offset is set to zero, so the output duty cycle is just equal numerically to the DC value Vc. The block also limits the duty cycle, it has to be between minimum and maximum values, which can be set as well. You can set the switching frequency again by right-clicking on the block and typing the number in the window. The gate driver block, similarly, is a behavioral model that represents key features of gate drivers. So, what you do is you apply the logic signal C to this input terminal of the driver, the driver actually measures its input voltage with respect to this input reference, which, here, is tied to ground. Then, it produces an output voltage here, with respect to the driver VDD or VSS signal here, and what we do is we apply these two terminals to the gate and source of the MOSFET, to turn the MOSFET on and off. The output ground or reference of the driver need not be the same as the input reference. We also have to supply power to the driver to make the circuit work. So, here we've connected a 12-volt power supply between the input power supply VDD and its ground pin VSS. One last point, let's look again at the complete simulation for the output voltage and inductor current. So, I will again plot the output voltage and we'll plot the inductor current. This is a plot from T equals zero all the way to five milliseconds and you can see what happens during this turn-on transient. All the signals are starting at zero with the converter turned off and then when we turn on, the circuit goes through some trangent, where the output voltage rises and there's some error overshoot and ringing in both the current and the voltage, and eventually the circuit settles down into steady state. So, here's a steady-state output voltage, in a steady-state inductor current. We can measure those values as well using SPICE. So, we zoom in at some point after the transient is done, and then we can control click to measure the average voltage, 9.2855 it says. So, again, a little bit less than 10 volts. We can also control click on the current to measure the average inductor current. It says that is 1.8573 amps. Okay. The homework assignment for this week is to download a boost converter file. There's a zip file on the Coursera site for the homework assignment. You should download SPICE and get it to run. Then, run this boost simulation file on your computer. Then, use LTspice to answer the questions in this homework assignment, which are things such as, what is the steady-state DC output voltage, or average output voltage, the inductor current, calculate the system efficiency by measuring the input power and the output power and dividing, and so on.