Tuesday, February 06, 2007

Steps, Waves, and Loops

Don't worry, part two of the power converter series is coming. I recently had a conversation with a friend about step and frequency response, and I figure I should write it all down before I forget it again. I've taught analog circuits for four semesters, two undergraduate and two graduate levels. The first hurdle seems to be the idea of a small signal model, and linearization in general. The second is poles and zeros, especially zeros. There are lots of published works on how poles and zeros work with respect to complex analysis, but as I learned when I switched from math to engineering, Riemann mapping and Laurent series are as useful to intuition as a tree is to a cabinetmaker.

I'm going to try and explain how I look at poles, zeros, and feedback while invoking as little math as possible. After all, a circuit is a real thing you can hold in your hand and you shouldn't need anything imaginary at all to describe it. Unfortunately, like my old professor used to do to me whenever I thought I had struck upon some circuit epiphany, you can always say "Well what about this case..." and show some pathological circuit designed to break all generalizations. I think the best I can do is look for patterns that work 90% of the time, and be aware of the types of 10% where the pattern does not apply. After all, intuition is just that; no need for precise answers at first glance, that's what a simulator is for. It just helps to know beforehand if your results are supposed to go up or down or in circles.

Poles and Zeros

Suppose we have a real circuit, and we put it in a sealed box. Now physically, the net energy crossing the boundary of the box is zero; this box neither sinks nor generates energy. That's not to say all the electrical power we put in will come out as electricity; some of the power we put in will heat the box, radiate magnetically, and dissipate. But the point is this energy is accounted for when we say "crossing the boundary of the box" and so we are safe. It also doesn't mean that the box doesn't store any energy; during steady-state operation, a constant amount of energy is stored in its inductors and capacitors.

Now let's pick a pair of terminals, label one the input (voltage, current, power) x and the other the output (voltage, current, power) y. So usually when we do two-port theory we have to issue disclaimers right about now such as x is not directly connected to y, or y is not connected directly to a dependent generator and nothing else. But (a) this is a real circuit, so even if x and y were directly connected there would be a tiny bit of parasitic resistance in the wire and (b) we're not going to nitpick. It turns out, again thanks to physics, that the ratio of |y/x| must get smaller as we turn up the frequency of x. If this isn't true, then the world would end. Actually, for fun one day I'd like to come up with a logically continuous set of statements that begins with "If the world didn't have a low-pass roll-off, then..." and end with something absurd like "...I would be able to eat Mars, Venus and Neptune for breakfast and still jump 200 feet in the air." So with this depressing perspective that everything will eventually go wrong, a pole is easy to swallow. It just tells us at what frequency this begins to happen. A zero, however is still puzzling. A zero means the output is fighting the natural roll-off of the universe; energy is coming from somewhere. But our circuit's in a sealed box, and if all the inputs are kept constant, is the box generating energy? Nope. A true (authentic) zero just doesn't exist in real life.

Well what about an inductor you say, it's got an impedance which rises with frequency so if we drive it with a current source then the voltage across it will just keep going up with frequency. Well a real inductor's got a self-resonant frequency above which it looks like a capacitor. Bummer. Of course this example is slightly screwy, because the power of the input source is going up as well so nothing is explicitly being violated. The point is nothing gets infinitely large.

So then where do zeros in circuits come from? Well consider this example.

We've got two simple single pole paths whose outputs add to produce the overall output. This is a completely natural situation that arises all the time; in any circuit the signal has multiple paths to the output. For example an op-amp wired in summing configuration, or if you want to get fancy a gm-C stage with a mis-matched input pair. Let's compute the output value.

Wow! There's a zero! Why did this happen? Well, suppose a1=a2=1, and τ1 >> τ2. At DC, the output gain is 2, with equal contribution from the two paths. Past the first pole frequency the first stage contribution suffers, and so does the output UNTIL the gain in the first path has dropped below one, (at twice the pole frequency) then the output is entirely from the second path. That is the zero location. Obviously I judiciously chose τ1, τ2, a1 and a2 to make the example work but you get the point. Here's whats going on pictorially.
So a zero in a circuit is not some magical amount of gain that suddenly makes the output rise, it's just one path of a circuit taking over for another as frequency increases.

Invoking partial fractions for a moment, it turns out that any transfer function for a real-world circuit--the denominator has a higher order than numerator--can be disassembled into the sum of low-pass and band-pass components. Now these components may have no physical meaning with respect to the circuit, but it just shows that all the zeros in the transfer function arise from re-direction of the signal inside. If you have all these components and want to get a rough overall response, you plot each component on the same Bode plot then follow the maximum of all the plots superimposed. This is what one of my teachers called "the Bode obstacle course".

Feedback, Step and Frequency Response

It seems to me that the first feedback gurus were all mechanical engineers and physicists, before the days of the diode, triode, pentode, compactron, MOSFET, JFET, MESFET, MODFET, HEMFET, IGBT, blah. An early crude form of feedback existed for the regulation of steam engine output speed, called a governor.

Then starting in the 20's feedback became cool for electrical engineers, so you had a lot of brilliant math and physics guys come up with all these neat theorems. They used silly terms like "electrical network" and "driving point" and "cps", but that just adds to the authenticity for me. This lasted until the 80's, after which analog fell out of vogue and digital became cool. From what I've learned in classes, it seems nowadays analog design has become a lot of topology and pattern recognition, and most of the innovation is with mixed signals rather than at the transistor level. The mechanical engineering undergraduates I've met know a lot more about feedback than most electrical graduates, so I'm lucky to have had an adviser who is a huge proponent of all things feedback.

The characteristics of step responses from which we can infer frequency response information depend on the general topology of the circuit. For example an RF power amplifier may have a qualitatively similar looking step response to an audio power amplifier, but because the audio amp has a strong global feedback loop around it means we know about its loop gain, something which is meaningless for the RF PA. In particular, without a global feedback loop the relationship between bandwidth and gain is lost, instead trading bandwidth for delay.

I've always thought about distributed gain circuits in terms of pipelining. This is the only time I use a digital analogy to describe an analog phenomenon. With pipelining, you break a complex task into a series of simple tasks, and so even though from input to output there's a longer latency once you get going the throughput is higher. Anyway in analog if you have a lot of low gain high bandwidth amplifiers in series, then the total bandwidth of the system is higher than a single amplifier of the same total gain--if you built your amplifiers properly--but now you have a disproportionately long delay from input to output. That's about all we'll say about non-feedback systems for now.

What's a Step Response?

So suppose there's a circuit, just chillin. All of a sudden we run up and kick it!! Then we watch what it does. Ideally we'd want to measure its impulse response, but there are these problems with generating impulses like infinite-amplitude, zero-width, and finite-energy. The Fourier components of a step are a bunch of cosines, whose amplitudes are the inverse of their frequency. One way to think of a step response is to treat the system like a filter bank. We take the step, split it into all its cosines, send each one through its own filter, then recombine them at the output.
Each component gets scaled by an amplitude and shifted by a phase. This is nothing new, it's a somewhat digital way to think of things, but it's how I do it.

The Timewidth-Bandwidth Property

If you've never heard of this, don't worry as of three days ago neither had I. I've always been wary of applying a fancy name to a simple concept since it makes me feel like I'm reading the math section of a psychology book, and I have enough fancy names to remember already. Try CMOS065NLVTLP, for "low power 65nm N-type metal oxide field effect transistor with low threshold voltage" WTF! Besides, "timewidth" isn't even a word! The point is simple:
Frequency and wavelength are inverses. If we look at very narrow slices of time, we can only see high frequency behavior. To see low frequency behavior, we need to look at longer slices of time. So the high frequency response controls the initial step response behavior, and the low frequency response controls the steady state behavior. Mathematically these are called the initial and final value theorems. What's interesting about feedback is just that; at any point in the circuit the signal will travel around a loop and a portion will return to the same point.

But how long does it take for the signal to come full circle? Well, if you look at the phase delay of the system, we can get an idea of the time delay in the feedback loop.

Here we see that in-band, the system has a constant delay equal to one period of the pole frequency. If the pole is at 1kHz, then the delay is 1ms, and so on. We know that past the unity gain frequency the feedback is negligible, so the minimum delay of the feedback loop is 1/fu. That means that between t=0, and t=1/fu, there is no feedback going on and the system is behaving open-loop. After this time, the feedback gets stronger as the loop closes. As the loop closes and the loop gain increases, the output gets closer to its final value.

At least that's how I see it.

These concepts are encapsulated nicely in Blackman's theorem. With this theorem, you decompose a circuit into two transfer functions, one which is valid when the feedback is completely operational (low frequency) and one valid when the loop is completely open. (high frequency) Then you determine a third transfer function which "interpolates" between the two transfer functions.

Gain-Bandwidth Product

This is one of those things that seemed reasonable when I learned it, having a pair of parents who throughout my life beat me with the wisdom that "you can't have your cake and eat it too" but I nonetheless didn't quite grasp until later. I mean it's weird right, you can take a huge electric motor that takes full seconds to reach top speed, wrap an opamp and power transistor around it, and all of a sudden it's doing backflips.

Let's forget about gain, bandwidth, and frequency response for a second to ask, what does it mean to say the speed of a circuit? Well, it's how fast the output changes, dv/dt. We want to know what's the maximum derivative of the output of the "plant" we're trying to control. Suppose we have a plant with a gain of A0 and bandwidth of ω0. In this case the maximum derivative is

Now let's consider what happens when we wrap a loop around this plant. Let's suppose we want the loop to have a gain of A, and we want to determine the new bandwidth. Well it's still the same plant, so we should expect the same maximum derivative.
Hence, the gain-bandwidth product. The interesting corollary of this is everything being kept equal, if we turn the amplitude of the input to a feedback system up, it's actually more taxing on the plant. That's obvious when you think of the plant being a motor or something mechanical, but perhaps less obvious when the plant is an op-amp. This is also why back in the day when we had ±15V supplies, the unity gain bandwidth of the amplifier also came with a peak-peak sinewave spec; often it was something much lower than rail-rail.

Second Order Systems and Ringing

Second order systems are ubiquitous for two reasons. One, they're very easy to solve. Two, turns out lots of phenomena are either exactly second order systems or closely modeled by them. I remember being asked why in class, and my wrong mathematical response was "Well sin''x=-sinx..." And everyone else in the class was like, no because F=ma and F=-kx'', dummy.

Anyway in this same class I saw a really neat proof of some second order system properties. Before this I never remembered why magnitude peaking occurs at 45°, or why the resonance peak is not exactly at the natural harmonic frequency. There are crazy formulas for them involving ζ and ωn but I could never remember those either. I don't know who came up with this proof, but it wasn't me. The best I can do is remember it three years later.

Let's begin by normalizing our system by ωn, which means |p|=1. Then we can write our system as:
Which is graphically represented by this:

The value of our transfer function is one over the product of the two solid line vectors.

The questions we want to answer are: (1) for what values of p do we see peaking in the frequency response, (2) at what frequency does the maximum occur, and (3) what is the magnitude of the peak?

To solve (1), we have to see if |(s-p)(s-p*)| has a local minimum less than one. Referring to the dotted line in the unit circle above, we see that |s-p*|=|s-(-p)|=|s+p| which means |(s-p)(s-p*)|=|(s-p)(s+p)|=s2-p2. But we know s=jω, so s2-p2=-p22. How does this help us? Well, -ω2 lies on the negative real axis, and p2 is somewhere in complex space. Note that Arg{p2}=2Arg{p}, which means that if Arg{p}>135°, then p2 lies in the right half plane, and therefore does not have a local minimum distance to any point on the negative real axis. This is illustrated below.

Arg{p}>135° corresponds exactly to the case where p is more complex than real, i.e. the angle it makes with the negative real axis is greater than 45°. Also note that since the radius of the circle is one, any local minima which occur have value less than one. Hence, there is magnitude peaking.

Once we have this, parts (2) and (3) are easy. From the figure above, the local minimum clearly occurs at the projection of p2 onto the negative real axis, and the magnitude at the minimum is the distance from the real axis to p2. These are respectively




If you've been following along, you'll notice that I dropped a minus sign. The thing is we've been defining θ as mathematicians do, but in systems they define θ from the negative x axis, hence the missing sign. It's easy to show that these definitions match with the classic control theory definitions, as follows:


Certainly we can all agree the previous expressions are easier and more intuitive than these, but then again some of us are arguing that π should have been defined as 2π so let's not get pedantic. Just to drive the point home on how neat this proof is, I quote the corresponding proof from an LTI System Review paper: "The peak gain will occur when <second order rational function> is a minimum. After simple differentiation, we find the minimum ωm is given by <formula given>. The corresponding peak value Mp is given by <formula given>." In engineering/math parlance, calling a task "simple" or "trivial" is synonymous with "this sucks" and "I don't want to do it".

Anyway the rest of that system review covers second order systems nicely, so we'll leave that out. What's interesting is when a system rings but doesn't look second order. What about a transient response like this:

It looks like a perfectly well behaved step response except it's got some annoying high frequency junk on it. What can happen is an emitter follower is driving a capacitive load, and since the output of an emitter follower appears inductive (a one transistor gyrator!) it's possible that we get an unwanted resonant tank. Thing is these parasitics are often much to small to appear as dominant effects in hand analysis, so the system looked well behaved on paper. This is the frequency response of the loop which resulted in the above transient response.

As you can see the system's got a 90° phase margin but the resonant tank out of band pushes the gain back up at a high frequency, which is what's riding on our first order response.


Zeros and Over/Undershoot

What sort of circuit would produce step responses like these?


This is actually a direct result from the discussion of multiple paths above. Suppose we have two paths to the output, one fast, one slow. The fast path dominates the initial response, and the slow path dominates the final response. If the two paths have different polarities, then the initial response can have different polarity than the final response. We call that undershoot. Undershoot means there's an odd number of right-half-plane zeros. Again, this comes from the Initial and Final Value Theorems.

With overshoot, it's tempting in the simulator to try and "tune" component values so that the output shoots up and lands squarely at the final value, meaning a super fast rise-time and no ringing. This is a bad idea because in practice values will be different and you'll be stuck with the settling time of the slow path, which probably sucked to begin with. It's better to find the source of the overshoot and eliminate it, which will probably speed up the dominant path in the process.

In practice, unless you know for sure your circuit should behave like this (power supply zeros, for example) the initial behavior is mostly likely caused by some parasitic capacitive path to the output. This looks low impedance at high frequencies hence the initial response but block DC, so the expected behavior takes over after a short amount of time. If you're experiencing undershoot, look for capacitive paths around inverting stages.

Doublets

When I first learned about doublets I tried to find a simple answer for why they cause slow settling transient responses. One way to do it is to brute force calculate the inverse transform of a transfer function with a doublet and partial fraction decompose the answer to isolate the exponential with a slow time constant. This is incredibly unsatisfying. For now I've come to the conclusion that it's all about delay. The key point is that phase starts to fall before gain does. So even if the pole and zero are fairly close together, a factor of two apart, you still get a phase bump of 16°. What does a 16° phase bump mean? Well, it's assumed that the doublet is occurring at pretty low frequencies (we'll deal with compensation later) either inadvertently or for canceling an unavoidable low frequency pole. A phase bump at low frequencies can cause a significant delay to low frequencies, which is the source of the long settling time; for all the frequencies below the doublet frequency, the phase delay of the system behaves as one with a bandwidth of the doublet frequency!

Here is a Bode plot of three systems, the blue curve is a system with a gain of 100 and a bandwidth of 1MHz, hence it crosses over at 100MHz. The green curve is the same system but with a pole at 1KHz and a zero at 2KHz; this also has a pole at 1MHz, but crosses over at 50MHz due to the doublet. To show that crossover is not the culprit, the red curve is a system with a gain of 100 but a pole at 500KHz, so it crosses over at 50MHz same as the system with a doublet.

The resulting phase delay from these three systems tells the story. Note that I had to use a logarithmic y-axis to get the three curves to fit nicely.

The original system has a 1us delay; the slower system has 2us. The doublet, however, has a full 0.5ms! Thinking again about how feedback is a loop, it means all the frequencies below 2KHz are running open loop until 0.5ms later, which is the source of the slow settling time.

That's about as long as I want this to get, it's already pretty incoherent and adding more would just make it harder to read. Please if you spot any errors let me know. (not grammatical errors, I make those on purpose)

0 comments: