# Gas station without pumps

## 2021 October 1

### Edition 1.3 released today!

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

I finally released the new version of the textbook Applied Analog Electronics today at https://leanpub.com/applied_analog_electronics. The book is a little longer than the previous editions:

Edition 1.1 Edition 1.2 Edition 1.3 type
659 673 691 pages
337 342 348 figures
14 14 14 tables
515 523 528 index entries
162 162 169 references

The newest edition adds a new section in the active-filters chapter, some additional explanation at the beginning of the FETs chapter, a constant-current circuit for electroplating the Ag/AgCl electrodes, and a few pieces of advice in the design report guidelines.

The chapter on design report guidelines is available free as a separate publication:
https://leanpub.com/design_report_guidelines

The minimum price is still $7.99, but I’m doing a special one-month coupon that lowers the price to$5.99, just for my loyal blog readers! One nice thing about selling through Leanpub is that purchasers get all future editions published through Leanpub as part of the price—the company is trying to encourage authors to publish book drafts through them, rather than waiting until the book is completely polished. That means that people who bought (even with free coupons) earlier versions of the book will get this release for free, and anyone who buys now will get the benefit of future releases. I will still provide coupons for free copies to instructors who are considering using the textbook for a course—contact me if you need a copy!

As before, I am still offering 25¢ rewards for the first report of each error (no matter how small) in the book.

I have recorded video lectures for the book. Playlists are at https://www.youtube.com/playlist?list=PLQCrrTKnAE-97LcrJuUQ_5wKBFil8An9i for the first course and https://www.youtube.com/playlist?list=PLQCrrTKnAE–khjVV52ZWU_Usc3e6KV9J for the second course. The first playlist of 122 videos runs about 27:16 and the second playlist of 50 videos runs about 12 hours, so the average video length is under 14 minutes.

There may be one or two videos added and existing ones may be updated, but the set of lectures is essentially complete. Many still have only automatic closed captioning, but the captions will (slowly) get hand edited.

## 2021 September 27

### Next book edition almost done

Filed under: Circuits course — gasstationwithoutpumps @ 13:50
Tags: , , ,

Eleven days ago, I said

Now all I have to do for the next release of the book is do the standard final checks (page breaks, spell checks, and URL checks).  This will probably take me another week.

I have now gotten the page breaks fixed and checked all the URLs (only 8 of the 215 distinct URLs needed fixing).  I last checked them about a year ago, so that is a link-rot rate of only 4%/year (a half-life of about 18 years).  In the process of fixing the page breaks, I noticed and fixed a few minor typos, as well as tightening the text in a couple of places (to improve the page breaks).  I found one instance of “the the” with my tandem-word checks (probably introduced since the last released edition).

I still have to do the spell checks.

I did release one new video last night: https://youtu.be/vLece-VKfkQ, which talks about providing a constant current for electroplating (see the post Controlling current if you don’t want to waste time watching an 11-minute video).

## 2021 September 16

### Last to-do note in book done

Filed under: Circuits course — gasstationwithoutpumps @ 10:46
Tags: , , , , , ,

I’ve finally removed the last to-do note from the text book. This one was an explanation of the threshold voltage for FETs as the transition between the subthreshold conduction, where the on-resistance has exponential behavior with $V_{gs}$ and the on-region, where it is roughly constant.

I don’t like copying graphs from datasheets for the textbook, so I needed to measure the values myself to make a plot. My first attempt, using the PMV20XNE nFETs that we used for the past few years in class, was a failure.  The typical on-resistance is only 23mΩ, which is too small for the crude measuring setups and low currents that I could get with the Analog Discovery 2.  I ended up mainly measuring the resistance of the test setup, with errors larger than the value I was trying to measure, so I couldn’t even subtract off the short-circuit measurement.

I tried again with a low-power nFET (a 2N7000), using a constant load resistor of 150Ω (so the maximum power dissipation in the ¼-W resistor would be $(5V)^2/150\Omega = 167mW$).

I controlled with the gate voltage with waveform generator, and measured both the drain-source voltage and the drain current. I used the oscilloscope tool and averaged both within a sweep and across many sweeps to reduce noise.

Because the Analog Discovery 2 has only 2 measurement channels, I had to manually copy the measurements into a file for gnuplot, as there was no way to record the waveform generator output with the measurements in a single file (well, there might be with the scripting capabilities of Waveforms 3, but I’ve not explored them much).

I noticed some pretty large offsets when measuring small voltages, so I did open-circuit and short-circuit measurements and used them to subtract off offsets (with the understanding that the current for the open circuit would be about 150µA, because of the 1MΩ impedance of the Channel 1 measuring the open-circuit voltage).

The corrections make a big difference at the low end, where on-resistance is comparable to the resistance of the measurement instrument and test currents are tiny. The correction at the high end is smaller, but still noticeable. The transition from the exponential behavior of subthreshold conduction to the on-region is pretty clear. (Click to enlarge)

Now all I have to do for the next release of the book is do the standard final checks (page breaks, spell checks, and URL checks).  This will probably take me another week.

## 2021 June 21

### Controlling current

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

In the electrode lab this year, students had even more trouble than usual in understanding that the the goal was to provide a constant current to the silver-wire electrodes for a measured time period, in order to produce a known amount of AgCl on the anode.  I will have to rewrite that section of the book for greater clarity.  I also plan to add a circuit that does the constant-current control for them, so that they don’t have to adjust the voltage to get the desired current (a concept that seems to have eluded many of them).

Here is a possible circuit:

This circuit provides a current from Ip to Im of Vri/Rsense, as long as the voltage and current limitations of the op amp are not exceeded.

The negative-feedback loop tries to bring the $I_m$ output to the voltage of the $V_{\rm ri}$ input, which is only possible if the current through the sense resistor is $I=V_{\rm ri}/R_{\rm sense}$.  Let’s say that we want 1mA from Ip to Im—then we would set $V_{\rm ri}= (1\,mA) R_{\rm sense} = (1\,mA)(100\Omega) = 100\,mV$.  If $V_{\rm rail}$ is 5V and the op amp is a rail-to-rail op amp, then we could get the desired 1ma of output as long as the load resistance from Ip to Im is less than 4900Ω (well, 4650Ω really, because of the internal resistance of the op amp).  With a higher load resistance, the voltage at Ip would hit the top rail and still not provide the desired current.  There is no lower limit to the load resistance—even with a short circuit the current would be the desired 1mA.

I chose 100Ω for the sense resistor, so that the control voltages do not get too close to the bottom rail, while leaving enough voltage range for fairly large load resistances.  By using 100Ω, it is possible to specify currents up to 50mA, which is beyond the capability of the op amp to supply.  Since the MCP6004 op amps have a short-circuit current of about 20mA with a 5V supply, about the most we can deliver is 14mA for a short-circuit load, because of the internal resistance of the op amp.

Using a 1kΩ resistor might also be reasonable, since the input voltage in volts would then specify the current in mA, but a 1mA output current would limit the voltage across the output ports to $V_{\rm rail} -1\,V$ (which is probably still fine for the electrode lab). With a 1kΩ resistor and a 5V supply, the maximum specifiable current would be 5mA, and the maximum obtainable is about 4mA.  If you needed 2V across the load, then you could not specify more than 2.4mA (still plenty for the electrode lab).

For the electrode lab, the currents required are low enough that this circuit is adequate, but what if we needed more current?  Here are a couple of circuits that can provide that:

By using a pFET, we can have the voltage output of the op amp control the current. No current is needed from the op amp, and we just need that Vrail is large enough that the pFET can be fully turned on.

If we use a PNP transistor, then we need to turn the voltage output of the op amp into a current for the base.  That current is about 1/50th or 1/100th of the collector current being controlled (depending on the transistor).

Both these designs have the positive and negative inputs of the op amp reversed from the low-current design, because the pFET or PNP transistor provides a negation—the voltage at Im rises as the voltage at the output of the op amp falls.  I reduced to the sense resistor to 10Ω, to allow specifying higher currents (up to 500mA for a 5V supply).  The main limitations on this design are the thermal limitations of the transistor and the resistor—there may be both a large voltage drop and a large current.  The worst case for the transistor is when the load is a short circuit and the voltage at Im is half the power-supply voltage—then the power dissipated in the transistor (and in the sense resistor) is $(V_{\rm rail}/2)^2/10\Omega$.  For a 400mW limitation on the transistor, we would want to limit $V_{\rm rail}$ to 4V.  For a ¼W resistor, we would want to limit $V_{\rm ri}$ to 1.58V (specifying 158mA), or up the resistor to 100Ω for a 5V limit (but then we could only specify up to 50mA).  We really need a 2.5W resistor if we want to have 10Ω and a 5V supply and use the full range.

For the book, I think I’ll just present the low-current version of the current control—we don’t need the high-current version, and students are likely to request too much current for the electroplating if they have it available (errors in computing the area of the electrodes that are off by a factor of 100 are pretty common—mixing up $({\rm mm})^2$ and $({\rm cm})^2$, for example).

## 2021 May 4

### Resonance with nonlinear impedances

Filed under: Circuits course — gasstationwithoutpumps @ 08:24
Tags: , ,

My book uses nonlinear impedance $Z=(j\omega\;1\,s)^\alpha M$ for modelling loudspeakers and electrodes.  The loudspeaker models include an inductor-like component with $\alpha>0$ and the electrode models include a capacitor-like component with $\alpha<0$. Standard linear components are special cases of the nonlinear impedance: inductors have $\alpha=1$, resistors have $\alpha=0$, and capacitors have $\alpha=-1$.

This past week I was thinking about the resonance that I see in some loudspeakers around 4MHz, which can be modeled with a capacitor in parallel with the main nonlinear impedance.  How can I estimate the capacitance to get initial values for model fitting?  In general, when do I get resonance with two nonlinear impedances?

Although I initially looked at the capacitor case, I realized that the general case of two nonlinear impedances in series gives me simple math that I can easily generalize to special cases and to parallel connections, so let’s look at $Z=(j\omega\;1\,s)^\alpha M + (j\omega\;1s)^\beta N$.  The first thing to do is to replace $j$ by the polar form $e^{j\pi/2}$, getting $Z=e^{j \alpha\pi/2}(\omega\;1\,s)^\alpha M + e^{j \beta\pi/2}(\omega\;1s)^\beta N$.  The we can apply Euler’s formula to get the real and imaginary parts:

$\Re(Z) = \cos(\alpha\pi/2)(\omega\;1\,s)^\alpha M + \cos(\beta\pi/2)(\omega\;1s)^\beta N$.

$\Im(Z) = \sin(\alpha\pi/2)(\omega\;1\,s)^\alpha M +\sin(\beta\pi/2)(\omega\;1s)^\beta N$.

We will get resonance whenever the imaginary part goes to zero:

$0= (\omega\;1\,s)^{\alpha-\beta} M\sin(\alpha\pi/2) +N \sin(\beta\pi/2)$, or

$\omega = \left(\frac{ -N \sin(\beta\pi/2)}{M\sin(\alpha\pi/2)} \right)^{1/(\alpha-\beta)} s^{-1}$.

The special case of an inductor and a capacitor sets $\alpha=1$, $M = L / 1\,s$, $\beta = -1$, and $N= 1\,s/C$,  yielding $\omega= \left(\frac{N}{M}\right)^{1/2} s^{-1} = \sqrt{\frac{1}{LC}}$, which is the standard result.

We get a resonance whenever $\alpha$ and $\beta$ have opposite signs.

We can deal with parallel rather than series impedances by looking at the sum of admittances instead of the sum of impedances.  To get the admittances, the exponents $\alpha$ and $\beta$ get negated and the coefficients $M$ and $N$ inverted, giving us

$\omega = \left(\frac{ -M \sin(\beta\pi/2)}{N\sin(\alpha\pi/2)}\right)^{1/(\beta-\alpha)} s^{-1}$.

Note: this post is a much simpler analysis than last year’s in Resonance for non-linear impedance, because here I am just looking for where the phase goes to zero, rather than where the magnitude of impedance is minimized.

Update 2021 May 4: The two definitions of resonance I’ve used (minimum $|Z|$ and $\Im(Z)=0$) are not the same—I tried doing a parametric plot of the magnitude vs. the phase for one asymmetric example ($\alpha=0.6$ and $\beta=-0.2$) and saw that the minimum magnitude did not occur at 0°.  So I’ll need to think some more about what I want “resonance” to mean for nonlinear impedances.

Next Page »