Straightforward Method to Design and Simulate with SPICE the Loop Compensation Controller for All Switching Power Supplies.

Ing. Cristoforo Baldoni

In this article we ‘ll see how to find the output power stage transfer function H(s), called the Control-to-Output function,  of the most switching power supplies: BUCK, BOOST, BUCK-BOOST, HALF-BRIDGE, FULL BRIDGE, both in voltage mode control and current mode control. In spite of the complexity of the different types of power supplies that use one or more output feedback, the output power transfer function H(s), can be reduced to a few schematic categories of general validity. We’ ll see when it’s the case to consider the effects of the RHPZ, the Right Half Plane Zero, and what it means in practical terms.
Once the components for the specific power supply have been sized, we can estimate with good approximation the transfer function which describes mathematically the output power stage. As seen in the article about the determination of POLES and ZEROS by inspection,  we ‘ll identify immediately the POLES and ZEROS which characterize the different switching categories.
We ‘ll draw the Bode plots of these functions with PSpice, and, according to their characteristics, we ‘ll choose the most suitable compensator G(s), implementing the compensation network with the operational amplifiers embedded in the microcontrollers. The SPICE simulation of the open loop transfer function G(s)*H(s), will allows us to evaluate the results for the system stability. Finally, we ‘ll apply this method in two real switching power supply: a low power flyback converter and an off-line, half-bridge switching.
This method allows us to speed up the design of the compensator G(s) in the prototyping phase before the physical measurement with the instrumentation.

It’s strongly recommended the reading of these articles:

Accessing this article you can download the following SPICE simulation files about switching power supply compensation design:

-Forward function example

-Flyback function example

-Flyback function example with a Right Half Plane ZERO

-Origin POLE compensator

-Origin POLE Transfer function implementation

-Forward function compensated example

-One ZERO two POLES compensator

-One ZERO two POLES Transfer Function Implementation

-Flyback with RHPZ compensated

-Three POLES two ZEROS compensator

-Three POLES two ZEROS Transfer Function

-Transfer function of a real Flyback converter

-Compensator for the flyback converter

-Overall compensated  transfer function of the flyback converter

-Transfer function of a real Forward converter

-Compensator for the Forward converter

-Transfer function of compensator for the Forward converter

-Overall compensated  transfer function of the Forward converter

Premium Content

Login to buy access to this content

SPICE simulation of a Combo Wave Generator.

Thanks for this article to ssleandro


In this article we ‘ll se how to implement a template for a Combination Wave Generator that can be a Surge Generator, a Line Impedance Stabilization Networks (LISN), motor control, ripple current, etc. This model can be very useful for hardware engineers which can utilize it in their projects to speed up project development. The platform used for the simulation is PSpice but
it can easily replicated in other SPICE simulation software.


The simplified model of the GPM consists of an High-Voltage source U, a charging resistor Rc, an energy storage capacitor Cc. This part of circuit is connected by a switch to 2 Pulse duration shaping resistors Rs, an impedance matching resistor Rm and a Rise time shaping indutor Lr, as in the picture below





typical values of this components are:  Cc=7.76μF,  Rs1=14.8 Ohm,  Rm=1.05 Ohm,  Lr=9.74μH,  Rs2=23.3 Ohm. The peak voltage on Rs2 can be 1KV, 2KV,..6KV.


In the following schematic we set the high voltage with the initial condition of the CapacitorCc, for example for 6KV, we set 6300 in the PSpice IC field of the Cc component. We can adjust the time in U1 to make surge hit at 90/270 degree or whatever phase we want.







Calibration of Surge Generator.

The IEC/EN 61000-4-5 standars requires the following waveform of open-circuit voltage with no Coupling/Decoupling network (CDN) connected




This is the result of the simulation that shows a voltage waveform that fullfills requirementof IEC/EN 61000-4-5





Below the image of the waveform of short-circuit current with no CDN connected




and here again the simulated results:




Ipeak is about 1.5KA, T1 is 8uS and T2 is 20uS. The effective coupling impedance is 2Ohm. The simulated current waveform fulfills requirement of IEC/EN 61000-4-5 standards.

Designing and Simulation of Industrial PID Controllers using Microcontrollers

Ing. Cristoforo Baldoni

In this article we’ll see how to pass from the design of analog PID controllers for continuous-time systems to digital controllers, replacing operational amplifiers, resistors and capacitors with microcontrollers. Digital controllers are very compact, all the controller fits on a chip, including the A/D and the D/A converters, moreover, digital controllers are not affected by the aging of the components and don’t change their values with the temperature as analog components do. We’ll see how to apply the Z-transform, the equivalent of the Laplace transform, but for discrete-time systems, we’ll see how to identify the transfer function of a process and we’ll explain, with a step by step procedure, how to apply the theoretical knowledge learnt by examining an Proteus microcontroller based project, that uses its PWM output to control an oven ‘s temperature. The microcontroller has a 10 bit A/D converter. This procedure can be easily adapted with minimal adjustments to other processes to control.



1. Digital Control-System Block Diagrams


2. Linear difference equations, Z-Transform, Inverse Z-Transform and Discrete Transfer Function.


3. Sampling and A/D Analogic to Digital Converter


4. D/A Digital to Analogic Converter and ZERO ORDER HOLD  (ZOH) : Relationship between the Continuous Transfer Function and Discrete Transfer Function of a sampled Process.


5.  Block Diagram Manipulation of Sampled Data Systems


6. Methods for designing Digital Controllers, Stability.


7. Designing  PID controllers by microcontrollers


8. Transfer Function Identification and PID Tuning using the Ziegler–Nichols Method.


9. Practical case of a temperature control system implemented with a microcontroller PIC and simulated with ISIS Proteus: Step by step explanation of how to apply the theoretical knowledge for implementing and simulating a PID controller.

Premium Content

Login to buy access to this content

Find Poles and Zeros of Circuit by Inspection

 Ing. Cristoforo Baldoni


In this article we ‘ll see how to recognize the number of poles and zeros of a transfer function simply by inspection, also of a large linear network, avoiding to calculate the analytical expression of the transfer function.  After reading this article, you ‘ll be able to determine the number of poles at first glance . Once set the output, you ‘ll also be able to determine the number of zeros by inspection and calculate the exact symbolic transfer function, the exact values of zeros and poles with simple software tool available for free. Using the SPICE analysis, we ‘ll verify the results found. The purpose of this article is to explore the concept of poles and zeros of a transfer function, their phisical meaning, and provide useful analysis tool for analog circuit designers and control systems engineers.


How many poles has the following network?



and what about this High-Pass filter?


if your answer to the first question is 9 or 8 , or you don’t recognize a fifth order filter (five poles) in the filter’s picture you should read this article.

Premium Content

Login to buy access to this content

Getting Started with PyOPUS

PyOPUS is a Python based platform for very sophisticated circuit optimization and simulation automation. The use of the Python library with the simulator requires a previous SPICE OPUS installation, then refer to the relative tutorial before proceeding. Below we show how to install PyOPUS on windows 7 (64 bit). All the softwares are 32-bit but they work fine on 64-bit. We’ ll have to install the following softwares:

Python 2.6.4Programming language
NumPy 1.3.0Package for scientific computing with Python
SciPy 0.7.1Python software for mathematics, science, and engineering
MatPlotLib 0.99.1Python 2D plotting library
wxPython 2.8Blending of the wxWidgets C++ class library with Python
PyOPUS 0.6 installerthe Windows32 PyOPUS installer

All these softwares can be downloaded here

The article refers to the softare versions of the table, but the procedure is the same for the updated versions.

Let’s start with the Python installation

the default destination directory is C:Python26

the full features installation requires about 50MegaByte

after the installation we have to add an enviroment variable: Start/Control Panel/System and Security/System/Advanced system settings, now click on Enviroment Variables button.

add to “Path” variable the value “C:Python26”

Getting Started with SPICE OPUS

SPICE OPUS is an acronym for SPICE engine for OPtimization UtilitieS. It’ s a recompilation of the original Berkeley’s source code for Windows 95/98/NT and Linux operating systems with Georgia Tech Research Institute’s XSPICE mixed-mode simulator.
You can simulate analog, digital, and analog+digital circuits using SPICE OPUS. It’s available for both Windows and Linux operating systems. It does not have a built-in schematic program for selecting components and drawing circuits. SPICE OPUS is being developed by Faculty of Electrical Engineering, University of Ljubljana, Slovenia and has over 10,000 users worldwide in the areas of research, education, and industry.

In this article we’ ll show the simple procedure to install SPICE OPUS on Windows (tested on Windows 7 64 bit) and how to describe a circuit to simulate, writing a .cir file with a text editor.

After downloading the program run the Setup.exe

you can change the installation directory by clicking on Browse button, by default it is installed in C:SpiceOpus


when the setup is complete, open the Start menu and go to Control Panel, choose “System and Security” and again “System”, once open this window,  click on “Advanced system settings”

the “System Properties”  window pops up:

click on “Enviroment Variables…”

Add a new system variable by clicking on the lower “New” button.

Name the variable OPUSHOME. The specified directory must be the Spice Opus installation directory. Click on OK. Confirm your changes by clicking on OK in the Environment variables dialog and once more in the

System Properties dialog.

Installation on Linux

Become root.

su –

Unpack the .tar.gz archive. A directory will be created with the name that looks like


Enter this directory.

cd spice_opusXXX_linux_DATE_TIME

Start the installation script (spice.install).

./spice_install INSTALL_PREFIX

INSTALL_PREFIX is the tree where Spice Opus will be installed. The recommended location is

/usr/local. The installation script removes any previous Spice Opus installation in that tree and

replaces it with the latest version. The binaries go to INSTALL_PREFIX/bin .

After the installation is finished, you can remove the spice_opusXXX_linux_DATE_TIME

directory that was created by unpacking the .tar.gz archive.

Setting up the environment

We shall assume that you are using BASH. Add the following two lines to /etc/profile (you

must be root in order to be able to do it).



where INSTALL_PREFIX is the tree where you installed Spice Opus.

It is also convenient if you add INSTALL_PREFIX/bin to your path. Add the following two

lines at the end of /etc/profile.


export PATH

Log out and log in again for the changes to take effect.

Getting Started with TINA

We are going to design and test a three stages BJT basic schematic amplifier to become operative with TINA


After running the program we can see this window:


On the components toolbar there are devices of “basic” tab, under the toolbar, selecting “semiconductors” on the toolbar appear several types of semiconductors

Now select “Special”

and again, we have a high number of devices to select. Let’s start selecting a Resistor

Place Resistors, to set value, double click on one and a parameters window pops up

Keep the libraries ordered

Learn to design a circuit with PSpice is a task quite simple and is enough a few pages of any manual available on line to do it. What can be confusing is the number of files with different extensions that belong to this great tool of electronic simulation. This is due to the history of PSpice, which initially developed to be used in PC by Microsim passed after to OrCAD which was at last acquired by Cadence. The original CAD Microsim was Schematics. After, the program was provided with a design tool more advanced, Capture, maintaining the ability to still use Schematics.

Schematics image:



Capture image:


Fortunately, the syntax used to describe a component remained the same, and all libraries with mathematical models, are the . LIB. Creating the design of a circuit with PSpice Schematics, the project will be composed of a schematic file .SCH, a control file .CIR and a circuit description file .NET both automatically generated from Schematics, and files .INC containing subcircuits, to be included in the project. The libraries containing the mathematical models to be added to the project are always .LIB, while libraries that contain graphic symbols associated with the mathematical models are the .SLB.

By using the tool of OrCAD Capture, the main project file becomes the .OPJ, and symbolic libraries are now .OLB. In short, in Schematics a component is completely defined by libraries .LIB and .SLB while in OrCAD Capture by the couple .LIB an .OLB.

Currently most of designers use OrCAD Capture for the circuits design, however, the same Capture has a tool to convert project designed with Schematics and convert .SCH and .SLB in .OPJ and .OLB. We ‘ll see how in a dedicated article.

SPICE Simulation Software

It follows a list of major SPICE simulation software, commercial and free:

CompanySPICE softwareImagesoftware license
AltiumAltium DesigneraltiumdesignerCommercial
cadencelogoCadence OrCAD SolutionsOrCADSoftwareCommercial
designsoftlogoTINA Design SuiteTINAcalculatorCommercial
intusoftlogoICAP/4 icapsoftwareCommercial
labcenterlogoProteus proteussoftwareCommercial
lineartechnologyLTSpice IVltspicesoftwareFree
nationalinstrumentsNI Multisim MultisimCommercial
spectrumlogoMicro-Cap Micro-CapCommercial
logoOpusSpiceSpice OpusspiceopusFree
triadsemilogoViaDesigner SuiteViaDesignerCommercial

SPICE Simulation Algorithm

SPICE (Simulation Program with Integrated Circuit Emphasis) is an algorithm developed at Berkeley University of California, and is the core of the best software of electronic simulation.

An electronic simulator is a program that allows you to draw a schematic circuit and, through mathematical model libraries associated with devices, allows you to simulate the components behavior and the global behavior of the circuit.The software simulation is often part of an Integrated Development Environment (IDE), that provides important tools as routing software, PCB editor, a design rule checker and so on.
Some of these softwares are commercial whereas others are free of charge.

A SPICE simulation program however is not a “magic box”, it’s not enough to copy an electronic sheet to obtain automatically the right result.Vendor’s model libraries are very reliable but often the designer has to model by himself some device, like a transformer, or have to model electronic phenomena that are not related to physical devices.In addition, SPICE is a finite difference numerical method, so there are simulator parameters that is important to learn about to improve the simulation results and avoid convergence problems.This is why professionalism and experience of designers are as important as the reliability of the libraries models.

The are many benefits to learning how to use the SPICE simulation software, primarly ,once you have modeled a circuit, you can easily change components and see immediately how its behavior changes. Furthermore, together with PCB editor tools, SPICE has become the standard in electronics industry, speeding up large-scale production.