Gas station without pumps

2017 July 13

Analog Discovery 2 oscilloscope input impedance fixed

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 23:25
Tags: , ,

This morning in Analog Discovery 2 oscilloscope input impedance, I wrote

I cannot fit a model based on the input divider circuit to the data—I keep getting a negative capacitance for C9 or C8, so that they can cancel each other.  These models also make C1 around 50pF.

So I can reconcile the DC behavior (1.044MΩ is well within the ±2% measurement error of the nominal 1.04MΩ), but not the AC behavior of the scope inputs.

I must be missing something, but what?  Any useful suggestions (which don’t involve modifying the Analog Discovery 2) are welcome.

This evening I figured out what I was missing. The model I was trying to fit was the following one for the oscilloscope, with a 2MΩ resistor in series as the reference impedance:

There is a natural, internal split into an 820kΩ and 220kΩ resistance in the input voltage divider (component numbers here are for channel 1, but channel 2 is identically designed).

What I was missing was parasitic capacitance from the breadboard and scope wiring. If I model a capacitor (Cref) in parallel with the 2MΩ resistor and another capacitor (Cextra) in parallel with the scope, I can get a good fit.  I can leave all the internal resistors and capacitors at their nominal values, and fit for several different values for the trim capacitor C8:

I can get an excellent fit with Rref being only a little over 1% off and reasonable parasitic capacitance values.

Analog Discovery 2 oscilloscope input impedance

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 11:43
Tags: ,

I have been blindly trusting the documentation for the Analog Discovery 2 that claims that the input impedance of the differential oscilloscope channels is 1MΩ || 24pF.  Yesterday, when my son was measuring the input impedance of the reference inputs of a sigma-delta ADC, we had reason for a while to doubt that claim, so I measured the input impedance in a simple way:  I put a 2MΩ 1% resistor in series with one input channel and used the other input channel to measure the voltage across the series pair. I swept the network analyzer from 10Hz to 1MHz, and recorded the voltage gain (and the phase).  The voltage gain is not well-fit by a simple (1MΩ || 24 pF) model, as the impedance does not keep decreasing.  It seems to be well modeled by a model with Rs+(Cp||Rp), though.

The reported voltage gain for Channel 2/Channel 1 is well fit by a voltage divider.

Because the Analog Discovery 2 reports gain for Channel 2/Channel 1, I had to invert the data to get it in the form I wanted for my model (I could, alternatively, have swapped the legs of the voltage divider in the model).

The phases were also well fit by the models, though I did not use the phase information in the fitting. (I tried refitting using just the phase information, but that did not change the parameters by much, nor did it visibly improve the fit of the measured phases, so I left the parameters with just the amplitude fit.)

The DC impedances are both 1.044MΩ, very close to the specified value, but the capacitor is over twice the specified value, and not directly in parallel with the resistance.  The reference resistor I used is supposed to be a 2MΩ±1% resistor, but it was part of a cheap assortment, and we’ve found these cheap assortments to often be slightly out of spec, so I’d not trust it to be better than ±2%.

The 200kΩ/800kΩ split is not very surprising, when we look at the circuit for the input divider of the oscilloscope (from the hardware reference manual):

There is a natural, internal split into an 820kΩ and 220kΩ resistance in the input voltage divider (component numbers here are for channel 1, but channel 2 is identically designed).

The appearance of the 200kΩ/800kΩ split in the model for the input impedance suggests that the trimmer capacitor C8 is not properly adjusted.  If all capacitance and resistance values were nominal, then C8 should be set to 39.59pF, to provide a flat response from the voltage divider (at the high-gain setting), producing an input impedance of (1.04MΩ || 26pF).  But C8 only has a 5–20pF range, so perhaps there are some other, parasitic capacitances that change the desired trimming.

I cannot fit a model based on the input divider circuit to the data—I keep getting a negative capacitance for C9 or C8, so that they can cancel each other.  These models also make C1 around 50pF.

So I can reconcile the DC behavior (1.044MΩ is well within the ±2% measurement error of the nominal 1.04MΩ), but not the AC behavior of the scope inputs.

I must be missing something, but what?  Any useful suggestions (which don’t involve modifying the Analog Discovery 2) are welcome.

2017 June 28

Changing the loudspeaker lab

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 21:38
Tags: ,

I’ve started looking at how the loudspeaker lab in the applied-electronics course will change, given that we will have the Analog Discovery 2 USB oscilloscope in the labs.  There are two main changes in capabilities:

  • hundreds of measurements can be made in a couple of minutes from 10Hz to 1MHz
  • phase information is available, not just amplitude information.

The availability of phase information means that we can try fitting complex impedance, and not just the magnitude of impedance.  Unfortunately, the gnuplot curve fitting that we’ve been using is only set up for fitting real-valued functions, not complex-valued ones, and I don’t really want to switch to a more full-featured model fitting program, as they get hard to use.

Today I gathered data from two loudspeakers: the tiny 1cm one that I have posted about before (Ultrasonic rangefinder tests with tiny loudspeaker and Redoing impedance test for tiny loudspeaker) and an 8Ω oval loudspeaker that we used to use in the class until Parts Express sold out of them (Loudspeaker analysisBetter model for loudspeaker). I only collected data out to 1MHz, since my previous experience indicated that the network analyzer was not very useful past that frequency (Loudspeaker impedance with Analog Discovery 2). I put a 22Ω resistor in series with the loudspeaker and measured the voltage across it on channel 1, with the voltage across the loudspeaker on channel 2.  I recorded the “gain”, which is channel2/channel1, and the phase for channel 2 relative to channel 1.  The gain times 22Ω is the magnitude of the impedance of the loudspeaker.

The formula that I’ve been using for impedance modeling, R + ja\omega^\beta + (R_m || Z_{L_m} || Z_{C_m}), turned out not to be a good fit for the phase.  I played around for a couple of hours with different, more complicated models, before finally settling on a model that is as simple as the one I’ve been using, but that fits pretty well:

R + a (j\omega)^\beta + (R_m || Z_{L_m} || Z_{C_m})

The difference is just that I’m including the j inside the exponentiation, so that the “inductor-like” component is now in direction j^\beta instead of j—that is, the asymptotic phase angle is \sin^{-1}(\beta) instead of 90°.

To do the fitting, I alternated between fitting some of the parameters to the magnitude of the impedance and some to the phase. After I had layed around a bit and gotten ball-park estimates of the parameters, I did a more careful fitting. I started by fitting the series R to just the low-frequency end of the data, then fitting the resonance peak without the “inductor-like” component in the model with data collected in just a decade of frequency around the resonance peak (I used a separate data file that had 600 data points for just that decade).  I fit the three parallel parameters using the phase data, then refit the parallel resistance using the amplitude data.  To start in the right region, I set initial values R_m = R_{peak}-R, C_m = 0.3/\omega, and L_m = 3.3/\omega, with R_{peak} being the magnitude of the impedance at the top of the peak, located at frequency  f, with \omega = 2 \pi f.

With those parameters set, I fit \beta with phase information for the high frequencies, and a with amplitude information.

I then tweaked the fit by refitting the resonance peak, refitting \beta and a, and repeating the refits.

The 6-parameter fit for the magnitude is pretty good.

The 6-parameter fit for the oval loudspeaker is not great for phase, but is not too bad.

The 6-parameter fit for the tiny loudspeaker is pretty good, though I did not attempt to model the two higher frequency resonances that are visible, despite knowing that the resonance around 9kHz rings seriously.

The resonances are somewhat more visible in the phase plot for the tiny loudspeaker than they are in the magnitude plot.

I’m going to have to write up a tutorial for the book on using a real-valued fitting method for fitting a complex-valued function.

2017 June 23

Uncompensated transimpedance amplifier

Filed under: Circuits course — gasstationwithoutpumps @ 16:07

In my book Applied Electronics for Bioengineers, I have students build transimpedance amplifiers for phototransistors (and some students use them for electret microphones as well).  In the book, I never deal with compensating the transimpedance amplifiers to avoid oscillation, as I try to stay away from students having to reason about phase of signals and oscillation has never been a problem in the student designs.

But I thought that I ought to understand the method myself, especially if I need to help students trying to do higher bandwidth, higher gain transimpedance amplifiers.  First I read up on the subject—one of the better introductions is the Maxim application note 5129 Stabilize your transimpedance amplifier.  The key concepts are the following:

  • When the frequency is high enough (where the open-loop gain is limited by the gain-bandwidth product) the phase change of the amplifier is about –90° (or 90° for the negative input).
  • If we set up a transimpedance amplifier with feedback resistor R, then the feedback consists of a low-pass RC filter: a voltage divider with R on tap and the input capacitance of the amplifier and any capacitance in parallel with the current source on the bottom.
  • The phase change of a low-pass RC filter (gain \frac{1}{1+j\omega RC}) approaches –90° above the corner frequency.
  • Having a phase change of 0° and gain ≥ 1 around a feedback loop results in instability and possible oscillation.

That means that we can have instability at frequencies between \frac{1}{2\pi RC} and the gain-bandwidth product (though we probably only have problems for frequencies at least a factor of 3 above the low-pass corner frequency, since the phase change of the filter is only asymptotically –90°).  If the parasitic capacitances are low and we only request small transimpedance gain, then RC is small, and the corner frequency of the low-pass filter is above the gain-bandwidth product, so there are no problems.  Will the students ever encounter problems?

Today I tried to make an unstable transimpedance amplifier using the MCP6004 op amps that we use in class.  The op amps have a gain-bandwidth product of 1MHz, so I needed an RC time constant much larger than 160ns.  I chose 2MΩ and 47nF for an RC time constant of 94 ms and a corner frequency of 1.69Hz.

The very large bypass capacitors are to make sure that there are no sneak paths through the power supply and positive input—to make sure that I’m looking at the phenomenon I’m really interested in.

I connected the amplifier up to the Analog Discovery 2, and I definitely got instability:

There does seem to be a somewhat unstable oscillation happening.

The reasoning about the amplifier instability suggests that the oscillation should be at about the frequency where the gain around the loop is 1, that is where \frac{f_{GBW}}{f}\frac{1}{2\pi f RC}=1 or f= \sqrt{\frac{f_{GBW}}{2\pi RC}}. For the circuit I made, that would be around \sqrt{1MHz \; 1.69Hz}= 1.3kHz.

I did some FFTs of the waveform (averaging over hundreds of traces to reduce noise, since the signal is fluctuating).

The peak is around 1380Hz, very close to the predicted oscillation frequency. Also visible are harmonics of 60Hz, which are the correct output of the transimpedance amplifier (picking up stray currents by capacitive coupling).

To compensate a transimpedance amplifier, we need to add a small capacitor in parallel with the feedback resistor, making the gain of the feedback filter \frac{1+j\omega R_{F}C_{F}}{1+j\omega R_{F}(C_{F}+C_{i})}, where R_{F} and C_{F} are the feedback components and C_{i} is the input capacitance. For “optimal” compensation, we want to set the upper corner frequency 1/(2\pi R_{F}C_{F}) at the geometric mean of the lower corner frequency 1/(2\pi R_{F}(C_{F} + C_{i})) and the gain-bandwidth product f_{GBW}. Using a larger capacitor (overcompensating) increases the phase margin (thus allowing for some variation from specs) at the cost of reducing the bandwidth of the final amplifier.

We can set the equation up as 1/(2\pi R_{F}C_{F})^2 = f_{GBW}/(2\pi R_{F}(C_{F} + C_{i})), which we can simplify by assuming that C_{i} \gg C_{F} to get C_{F} = \sqrt{ \frac{C_{i}}{2 \pi R_{F}f_{GBW}}}, which for my design comes to 61pF.

A 68pF compensation capacitor cuts out the oscillation peak, but there is still a fair amount of noise around the corner frequency of the amplifier (1.2kHz). Overcompensating with a 680pF capacitor reduces the noise substantially, but the bandwidth is reduced to 120Hz.

I also tried a somewhat more realistic example, with only a 2.2nF input capacitance, which calls for about a 13pF compensation capacitor. A 20pF capacitor does fine:

The oscillation is well suppressed by the compensation capacitor.

Now I have to decide how much (if any) of this to include in my book. Perhaps it can be an optional “advanced” section in the transimpedance amplifier chapter?

2017 June 17

Kind thoughts from a student

Filed under: Circuits course — gasstationwithoutpumps @ 23:36

One of my students sent me a nice e-mail at the end of the quarter.  With her permission I’m reprinting it here:

Dear Prof. Karplus,
I just wanted to take a moment to thank you and tell you how much I enjoyed the class over the last two quarters. Even though my scores may not reflect it, I feel like I’ve gotten the opportunity to learn a lot. In addition to that, some of the projects gave me a chance to spend time and connect with my father, who’s also an engineer. He was amazed at my ability to draw and build a circuit on my own (as I did the class-D lab solo), because he claims he was never able to do so when he first started learning electronics. The last project was especially very meaningful, since EKGs are  personal to me due to some childhood problems, and I got to learn how they work. I created my graduation cap as a tribute to that project and the class (see attached picture), I hope you like it!

Hope to see you at graduation,

Manisha Marisetty’s graduation cap

A number of students in the class have told me how much they learned in the class, and not just about electronics. Other things students have mentioned include writing improvement, breaking things into subproblems, and debugging. This feedback from the students is valuable, as it keeps me motivated to keep improving the course. The course is a lot of work (for me and for the students), and it would be very easy to burn out if the course were not having much positive effect on the students.

Note: constructive criticism from the students is also useful—I’ve had several tell me that there need to be more drill exercises, for example, and there have been requests for more worked examples.  But small amounts of positive feedback help keep me motivated to do the work of addressing the problems. (Students have also suggested that I need to give more positive feedback—something I’m working on, but finding difficult to do consistently.)

I’m afraid I won’t go to the graduation ceremonies this year—I’ve got too much grading still to do, and I figure I’ll barely be completing the grading by the Tuesday deadline as it is. I’ve gotten the electrode-lab redone reports graded, and one third of the EKG labs done. I have the remaining 23 EKG lab reports to grade, an independent study, and a senior thesis. I’m on schedule, but not with a lot of time to spare.

Next Page »

Create a free website or blog at

%d bloggers like this: