Gas station without pumps

2019 May 22

Interaction between bias resistor and active high-pass filter

Filed under: Circuits course — gasstationwithoutpumps @ 00:02
Tags: , , , ,

In grading the preamplifier lab, I made a mistake when correcting a number of student papers.  Students who had used a bias resistor rather than a transimpedance amplifier to convert the microphone’s current output to voltage had not taken into consideration the interaction between the bias resistor and the input impedance of the next stage, which was usually an active high-pass filter.  In grading, I overcorrected the student work, changing both the i-to-v gain and the first-stage gain, when the correct action would have been to change either one, leaving the other alone.

Schematic of bias resistor and active high-pass filter. The input is the current I_in.

The passband gain for the circuit is R_b\frac{R_f}{R_b + R_i} = (R_b || R_i) \frac{R_f}{R_i}. The first version corrects the gain of the filter, while the second version corrects the gain of the current-to-voltage conversion. In my grading, I mistakenly applied the correction twice getting (R_b || R_i) \frac{R_f}{R_b + R_i}.

There are two ways to get to the correct answer: using Thévenin equivalence and from first principles.

If we replace the current input and R_b with a Thévenin equivalent, whose AC voltage is the AC component of I R_b and whose resistance is R_b, then we get a simple active high-pass filter with passband gain \frac{R_f}{R_i + R_b} for a total passband gain of R_b\frac{R_f}{R_b + R_i} and a corner frequency of \frac{1}{2 \pi (R_i+R_b) C_1}.

For those who don’t quite trust themselves to do Thévenin equivalence, we can use first principles to reason about the various currents in the schematic. The negative-feedback loop holds the op amp’s negative input to V_{ref}, and the input node has a voltage, so we get
V_{input} = V_{dd} - I_b R_b = V_{ref}-I_f \frac{j\omega R_i C_1 + 1}{j \omega C_1}
which we can rearrange to get
I_b = \frac{V_{dd} - V_{ref}}{R_b} + I_f \frac{j \omega R_i C_1 + 1}{j\omega R_b C_1}.
Because I = I_b + I_f, we get
I= \frac{V_{dd} - V_{ref}}{R_b} + I_f \frac{j \omega R_i C_1 + 1}{j\omega R_b C_1} + I_f
and can solve for I_f to get
I_f = (I- \frac{V_{dd} - V_{ref}}{R_b}) \frac{j\omega R_b C_1}{1+j\omega(R_b+R_i)C_1}.

Finally, because V_{out}-V_{ref} = I_f R_f, we get
V_{out}-V_{ref} = R_f (I- \frac{V_{dd} - V_{ref}}{R_b}) \frac{j\omega R_b C_1}{1+j\omega(R_b+R_i)C_1}.

Our transimpedance gain (including the DC offsets for input current and output voltage) is
\frac{V_{out}-V_{ref}}{I- \frac{V_{dd} - V_{ref}}{R_b}} = R_f \frac{j\omega R_b C_1}{1+j\omega(R_b+R_i)C_1}.
At DC, this has the appropriate gain of 0, and for high frequencies (in the passband), the gain is approximately \frac{R_f R_b}{R_b + R_i}, as claimed earlier. The corner frequency, where the real and imaginary parts of the denominator match is at \omega = \frac{1}{(R_b+R_i)C_1}.

2017 July 1

Multiple-feedback bandpass active filter

Filed under: Robotics,Uncategorized — gasstationwithoutpumps @ 12:14
Tags: ,

I wanted to improve my understanding of active filters, beyond the very simple ones that I included in my textbook, so I decided to try implementing a bandpass filter using the multiple-feedback topology.  To make the design more concrete, I decided to make one that was centered at 2kHz, but firmly rejected 1.5kHz and 2.5kHz.

Here is the design I came up with. The top part is the filter, while the bottom is just a reference voltage buffer. I’ll derive the values below.

I_1= (V_{in} -V_{m})/R_1
I_2= (V_{ref}-V_{m})C_{2} s = (V_{o}-V_{ref})/R_2
I_3= (V_{ref}-V_{m})/R_3
I_4= (V_{o}-V_{m})C_{1}s
I_1 + I_2 + I_3 +I_4 = 0

We can simplify a bit, by replacing V_{m}-V_{ref} with -(V_{o}-V_{ref})/(\tau_2 s), where \tau_2 = R_2 C_2. Note that this corresponds to replacing the amplifier, R2, and C2 with an inverting high-pass filter.

It is conventional to recenter the voltages so that V_{ref} is zero, which simplifies the algebra.  Doing that gives us

(V_{in}+V_{o}/(\tau_2 s))/R_1 + V_{o}/R_2 + V_{o}/(\tau_2 s R_3) + V_{o}(1+1/(\tau_2 s))C_{1}s=0

Multiplying both sides by \tau_2 s and rearranging gives us

-V_{in}\tau_2 s/R_1  = V_{o} \left(1/R_1 + \tau_2 s /R_2 + 1/R_3 + (\tau_2 s +1)(C_1 s)\right)

\frac{V_{o}}{V_{in}} = -\tau_2 s / \left({1+ \tau_2 s R_1/R_2 + R_1/R_3 + (\tau_2 s +1)(R_1 C_1 s)}\right)

More correctly, that should be \frac{V_{o}-V_{ref}}{V_{in}-V_{ref}} = \ldots, but I’ll just talk about the gain G.

Defining \tau_1 = R_1 C_1 we get

G = -\tau_2 s / \left(1+ R_1/R_3+  (\tau_2 R_1/R_2 + \tau_1) s + \tau_1\tau_2 s ^2)\right)

G = -(\tau_2 s/R_1 )/ \left(1/R_1+1/R_3+  (\tau_2 /R_2 + \tau_1/R_1) s + \tau_1\tau_2 s ^2/R_1)\right)

If we have C_1=C_2=C, which is a common design constraint, we can simplify to

G = -(R_2 C s/R_1 )/ \left(1/R_1+1/R_3+  2 C s +C\tau_2 s ^2)\right)

G = -(R_2 /R_1 )/ \left((1/R_1+1/R_3)(Cs)^{-1}+  2  +\tau_2 s)\right)

We can define R_p = R_1 || R_3 = R_1R_3/(R_1+R_3) and \tau_p = R_p C_1.  Then we have

G = -(R_2 /R_1 )/ \left((\tau_p s)^{-1}+  2  +\tau_2 s)\right)

If we let s = j \omega, we get

G = -(R_2 /R_1 )/ \left(2  +j (\tau_2 \omega-(\tau_p \omega)^{-1})\right),

whose magnitude is maximized when \tau_2 \omega-(\tau_p \omega)^{-1}=0 or \omega = 1/\sqrt{\tau_2\tau_p}, and at that maximum the gain is - R_2/ (2 R_1).

The corner frequencies, where the gain drops by the square-root of 2 occur when the real and imaginary parts of the denominator have the same magnitude, or \tau_2 \omega-(\tau_p \omega)^{-1}= \pm 2. If we take only the positive values of \omega, we get \omega = \left(\pm 1 + \sqrt{(\tau_p+\tau_2)/\tau_p}\right) /\tau_2, for a bandwidth of 2/\tau_2, or 1/(\pi R_2 C_2) Hz.

For C=10nF and R2=220kΩ, we get a bandwidth of 144.7Hz.  With R1=6.8kΩ and R3=300Ω, Rp=287.32Ω, with time constant 2.8732 µs, giving a center frequency of 2001.8kHz.  I built this filter and tested it with the Analog Discovery 2:

The overall match of the filter to the theory is pretty good.

But when we look in detail at the peak, we can see that the center frequency is off a little and the gain isn’t nearly as big as it should be. I suspect that the problem is poor matching of the very cheap 10nF capacitors.

I also tried exciting the filter with wideband noise from the Analog Discovery 2, and doing an FFT of the input and output to get a different view of the response:

The filter response looks a little larger taking the difference of FFTs (after averaging many FFTs, since each individual one has a lot of noise). Note the 60 Hz spike.

2014 May 14

Mixed topics in lecture

Filed under: Circuits course — gasstationwithoutpumps @ 21:27
Tags: , , , , , , ,

Today’s lecture was a mish-mash of different topics.

Pre-lab assignments not getting done.
I asked the students for advice on how to get them (or next year’s class) to do the pre-lab assignments before coming to lab, rather than wasting lab hours doing homework that doesn’t need the fancy lab equipment. I told them some ideas I had had, and how everything I’d tried so far had not worked. The only idea they thought might work was requiring that pre-lab assignments be turned in the day before the lab, so that they would prioritize the work. I’ll have to look to see if that is feasible for any of the labs left this year.
Answer getting
I talked again about the “answer-getting” mindset, and how it wasn’t an appropriate one for engineers. The problems they’ll face in industry are open-ended ones, where there isn’t a single unique answer—no one is going to be giving them multiple-choice tests. They’ll have to come up with designs, justify their design choices, and document them well enough that someone else can maintain things after they get hit by a beer truck.
Subdividing problems
I told them that I was deliberately giving them long multi-step design problems so that they could get used to subdividing problems and tackling them a little a time. I had noticed that some of them were stopping as soon as they got to a subproblem they didn’t know how to handle, rather than leaving a symbolic value for the result and solving the other subproblems. It is a lot easier to fill in one hole in a long computation than to have to do the whole thing from scratch each time.
Engineering by design or by tinkering
There are two different styles of engineering: one which uses careful modeling and calculation to try to get a design that works correctly first time, and one that consists of making quick reasonable guesses, trying them out, and adjusting the design to correct problems. I confessed that as a hobbyist, I generally prefer design by tinkering, but most modern electronics does not lend itself to tinkering, because the parts are too small for hand soldering, so one needs to go through a more expensive PC board design and pick-and-place assembly to build a prototype. I did, accidentally, tell them a lie—I said that the MCP6004 quad op-amp chip they are using is available in a 2mm by 3mm package, but that package is for the 8-pin MCP6002 dual op-amp chip, and the smallest for the MCP6004 is 4mm by 6.4mm (substantially larger than 2 MCP6002 chips!). This week’s lab was intended to be a compromise between the two design styles, with Tuesday being engineering by design for the first stage and today and Thursday being tinkering to correct the problems of the first stage, but only one group got to the point on Tuesday of having a partly functional design that could be tweaked.
Results from stage 1
I had a student whose group had gotten stage 1 working in lab yesterday talk about what he and his partner had seen on the scope. He mentioned the voltage going very high when there was no finger blocking the light (and we talked a bit about saturation, pointing out the similarity to the loudspeaker lab, where they observed clipping from either voltage or current saturation—I even managed to tie in the chemical concept of saturated solutions). He talked about how the voltage dropped to Vref+100mV with a finger blocking the light. He mentioned the large 60Hz noise on top of this DC signal, and the tiny voltage that may have been from the pulse. I gave the students some ballpark figures for the sorts of currents that they might see from their phototransistor (based on both what the first group saw and what I had seen at home): about 90–150nA DC and about 2–10nA for the pulse.
Gain of first stage
We talked about ways to increase the gain of the first stage and the desirability of making it as big as possible without saturating at the top rail. One subject that came up (in response to a student question) was increasing the headroom by dropping the reference voltage for the transimpedance amplifier. That brought up the other constraint on that voltage—biasing the phototransistor. The spec sheet gave a VCE saturation voltage of 0.8v, and I suggested that they stay above that voltage (though I suspect that the design might work down to 0.7v since their currents are so small—something I should probably experiment with).
Need for filtering
I asked the students how to get rid of the DC bias, and by this point they all know that a high-pass filter was needed. We then discussed what sort of frequency range a heart rate might be (several were pretty clueless about this), but we eventually got to 30bm–240pbm, or 0.5Hz to 4Hz. I suggested that they might want a wider bandwidth, particularly on high end, to see the shape of the pulse as well. I talked about the need for a low-pass filter to reduce the 60Hz signal.
Synchronous sampling
With a little too much prompting, I managed to get them to come up with the idea of sampling at 60Hz, so that the 60Hz noise would be sampled at the same point on the waveform on each cycle and so be less of a problem. I also showed them that 30Hz or 20Hz would work just as well.
Active filters
Finally we got to what I had intended as today’s topic: modifying the transimpedance amplifier to include a low-pass filter. I showed them the transimpedance amplifier circuit again, and reminded them that the feedback did not need to be a simple resistor but could be a complex impedance. We drew the Bode plot for the desired gain of the amplifier using a 1/f (6dB/octave) rolloff, and I asked them how to design a complex impedance with that magnitude. They fairly quickly came up with the idea of using a resistor and capacitor, but at first they wanted to put them in series. We computed what the plot for that would be, and they decided to try parallel instead. Success! But almost out of time for the day, without talking about multi-stage filters or putting complex impedance in both arms of a voltage divider in the feedback loop for a bandpass filter.
Gnuplot boilerplate
I did give them a quick look at the boilerplate gnuplot script I wrote for them, that allows them to create models and test them out quickly with gnuplot, but I did not have time to work through an extended example of modifying the script for more complicated circuits, and I doubt that any of them will take the trouble to try it on their own.

I did not get a chance to tell them about the pressure on the finger being optimally between the systolic and diastolic blood pressure, but there should be time in lab for that tomorrow. By grasping the edge of a table lightly and gradually increasing the grip force, one can slowly increase the pressure until the finger throbs with the pulse—that is the amount of pressure you want to put on the fingertip.

I expect that I’ll be in the lab quite late with the students tomorrow, getting them to build their stage 1, tweak the feedback resistor (and capacitor) until the circuit has reasonable gain, then design and build their second stage. I’m betting that no one will have thought about what they need for the second stage, and most still won’t have a schematic even for the first stage.

On Friday, I’ll introduce instrumentation amps and strain gauges, for next week’s instrumentation amp lab. Monday will have to be class D amplifier design concepts, because Wed will be the quiz, and there is no Monday the week after next (Memorial Day), so we’ll have to develop class-D block diagram on Friday next week.

%d bloggers like this: