# 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}$.

## 2019 May 10

### Inductive spikes

Filed under: Circuits course — gasstationwithoutpumps @ 22:04
Tags: , , , ,

One of the labs in my textbook Applied Analog Electronics asks students to look at the inductive spikes created by switching a nFET on and off with a loudspeaker as a load:

A 5V pulse signal to Gn will turn the nFET on.

My students were very confused when they tried the experiment, because they got a different result:

What the students got at the nFET drain went a little above 5V, but did not have the enormous inductive spike they expected.

Of course, I lied to you a little about what their circuit was—they were working with half-H-bridge boards that they had soldered:

The half H-bridge boards have a pFET and capacitor on them, as well as an nFET.

The pFET was left unconnected, so the circuit was really the following:

The gate and pFET source were left floating in the student setups.

So what difference does the pFET make? Well, with the gate floating and staying near 0V, the pFET turns on when the pFET source voltage gets high enough, allowing the capacitor to charge.

The pFET source gets up to about 7.2–7.3V, and the time constants for the capacitor and loudspeaker are long enough that the capacitor looks like a power supply (not changing voltage much on this time scale), so that the body diode of the pFET snubs the inductive spike at about a diode drop above the pFET source voltage.

So how did I miss this problem when I did my testing before including the lab in the book? One possibility is that I left out the bypass capacitor—without it you get the expected spike. But I know I had included the capacitor on my half-H-bridge boards—I had to solder up a board without the bypass capacitor specially last night, in order to get the “expected” plot in the first plot of this post.  I think what happened is that when I had done my tests, I had always connected the pFET gate to the pFET source, to ensure that the pFET stayed off, but when I wrote the book, I forgot that in the instructions. Here are the plots of the board with the pFET gate and source tied together (both floating), both floating separately, and with the them both tied to 5V:

With the pFET gate and source tied together, the circuit behaves as expected, with large inductive spikes if the pFET source is floating, but snubbed to a diode drop above 5V if the source is tied to 5V.

The pFET source voltage gets quite high when the pFET gate and source are tied together to keep the FET off, but they are not tied to the power rail:

Because the pFET never turns on, the body diode and capacitor acts as a peak detector, and the capacitor charges until the leakage compensates for the charge deposited on each cycle, around 33.7V, snubbing the inductive spike at about 37V (more than a diode drop above, but the duration is short).

This summer and fall, when I’ll be working on the next edition of the book, I’ll be sure to improve the instructions for the FET lab!

## 2019 February 15

### Why do I write?

Filed under: Circuits course — gasstationwithoutpumps @ 19:56
Tags: ,

O Why Do You Write? Charles French asks

I have a question for all you out  there who write, and that includes writers of books, poetry, plays, nonfiction, and blogs. If I left out any kind of writing, you are included also.

Why do you write?

I wrote my textbook Applied Analog Electronics because I was creating a course for which I could find no suitable textbook. I wanted a college-level introduction to electronics that was focused on designing things, not on applied math. I don’t have an objection to math (there is plenty in my textbook), but I wanted it to be there to solve a particular design problem, not just with sterile exercises. The central theme of the book had to be iterative engineering with design, construction, and debugging of interesting circuits, with almost everything else as support for that activity.

All I could find on the market either delayed design until the third or fourth course (which seems to be the standard approach in EE departments) or was very hand-holding—telling students exactly what to wire and leaving no electronics design to the students.

When I started the book writing, I already had a fairly thorough set of lab handouts and felt that the book would be a simple rewrite with a bit of additional material. Boy, was I wrong!

The book has taken over much of my life (when I’m not teaching the course from it or grading student work) for the past few years. I had a “finished” draft at the beginning of January, but students in my class have pointed out about 170 problems with it, and they are only halfway through the book. A lot of the problems were tiny copy-editing things (commas, spaces, spelling errors), but some were substantive. I have about 50 to-do notes accumulated for me to work on this summer.

I think that this year’s students have been motivated to find errors by the token amount I pay for each error found (25¢) and by the “leaderboard” on Piazza, where I keep track of what I owe each student. To encourage more feedback, I try to be generous in allocating the quarters—something doesn’t have to be a real mistake, if I agree that the wording can be improved or something needs to be rewritten for clarity or completeness.  Students can ask questions about something they don’t understand, and if that triggers a specific idea for a change to the book, I give credit for that also.  (Having question-triggered corrections means that even students at the bottom of the class can get credit for book corrections.)

The question of why I write on this blog is a harder one.  Sometimes I am trying to share something I learned, sometimes I’m asking for help finding a solution to a problem, sometimes I’m motivating myself by making something public (like my weight and exercise records), sometimes I’m just thinking out loud (like many of my posts about the design of my course).  I’d like to say that I blog for the social connections, but so few people respond to my posts that I can’t really pretend even to myself that I am having a conversation.

I think that a few of my posts have been valued (at least Google thinks enough of them for people to come to them with searches), so I have some incentive to keep on writing.

## 2019 January 21

### More typos than expected

Filed under: Circuits course — gasstationwithoutpumps @ 16:53
Tags: , ,

When I released my textbook in December, I offered 25¢ for each typo or other mistake found in the book.  I expected, based on how much material was new, to have about 50 typos in the book.

My students have already found 42 errors, and they are only up to about page 200, so I’m having to revise my error estimate upward to about 100 errors.

This year’s class seems to be pretty sharp—they have done much better on the first two quizzes than last year’s class did, and in two weeks they have already found about as many typos as last year’s class did over two quarters.

## 2019 January 8

### Struggles with Canvas

Filed under: Circuits course — gasstationwithoutpumps @ 11:30
Tags: ,

Yesterday (2019 Jan 7) was a crazy day for me.

I got up early to walk my son down to the bus station for his trip back to college, then bought groceries, walked home, had breakfast, and cycled to work. It was the first day of class, so I had meetings with my teaching team (5 undergrads, but one was snowed in at Tahoe and unable to make the meetings—there were two meetings, because no time worked for all five students).

I spent most of the day struggling with “Canvas” the learning management system that the campus makes us use. Setting up courses on it is a major pain, even if all you use it for is turning in assignments and grading them. My course has 12 homeworks, 6 prelab reports, and 5 design reports, plus about 10 quizzes.  One of the problems is that each assignment takes many mouse clicks to create— setting the name, the due date, the number of points, the grace period for submission, whether it is a group assignment, what group set it is associated with … .  Setting up lab groups the way I wanted turned out to be impossible in Canvas.  I wanted random pairs, respecting section boundaries, with no pair of students working together twice.  Even the simplest version of this (doing random pairings without the no-repetition constraint) didn’t work in Canvas, which tried creating one group of 3 and one singleton, for a section with an even number of students.

I figured that it would be easiest for me to create the pairings on my own computer and upload them to Canvas. But Canvas doesn’t have any way to upload group assignments! The only way it supports instructor-assigned groups would have required about 1000 mouse clicks. I ended up doing the assignments on my computer and posting them on the class bulletin board, telling the students to enter themselves into the assigned lab groups. I hope that this did not violate any FERPA rules (I checked the summary provided to faculty and it looked ok, but it would have been better for Canvas to have permitted uploads, so that I didn’t need to worry).

Lecture went ok, but afterwards I found that one of the figures in my book had gotten messed up between the Dec 15 and Dec 30 releases, and I had to come up with a new way to create the figure and re-release the book. LeanPub is nice in that anyone who has bought the book can pick up the new releases for free.  I think some of my students haven’t figured this out yet, as there have been more uses of the free coupon I issued than there are students in the course.

So I was continually busy from 6am when I got up to midnight when I got to bed. This morning I went for a 1.5km run in light rain before breakfast, created the quiz for tomorrow’s class, and cycled up to campus for office hours, faculty meeting, and 4 hours of instructional lab. Today is (probably) not going to be as hectic as yesterday was.

The new complex-number exercises in the book have prompted a couple of students to come in for help, as they did not really understand Euler’s formula.  I ended up redrawing and re-explaining the figure from the book, and that seemed to help them.  I’m hoping that this complex-number review will make it easier for them when we get to complex impedances.

Next Page »