Gas station without pumps

2013 February 8

Fourteenth day of circuits class

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

Today’s class started with another do-now problem: What is the voltage gain of the following circuit?

voltage-divider-virtual-ground-ampThis circuit was intended to be more of a hook than as a test of former material, though they’ve had all the tools needed to solve it.  I worked them through finding the Thévenin equivalent of the pair of 2.2kΩ resistors (which is tricky, since the equivalent voltage is 0V, and the short circuit current is also 0—the resistance needs to be determined at some other voltage).  We then plugged the circuit back together and everyone could get the right gain.

I did one more explanation, of the voltmeter symbol and how you could decompose a bridge circuit into two voltage dividers, and I turned them loose on doing quiz corrections in groups for the rest of the class time. They broke into 3 groups and I circulated around the room, answering questions and occasionally giving advice.  Every once in a while I would answer a question by going to the board and doing a 2-minute explanation, which everyone in the room watched, even those not in the group that asked the question. I’m requiring them to turn in quizzes on Monday with all the answers correct.

The students seemed to be getting into doing the quiz corrections, and a lot of good questions came up that exposed misconceptions.  I forgot to ask students to bring laptops on Monday, so I think I’ll push the gnuplot in-class work to Wednesday.  That will give me some time in the lab after class on Monday to gather some data to do another modeling project with.  On Wednesday we’ll go through building the model to explain the data.  I’m thinking of modeling the impedance of their loudspeakers as a function of frequency, as that should have some interesting modeling issues, provide clean data for fitting, and be useful to them later on when they have to design the class-D amplifier.

On Monday, we’ll probably do a bit more on the quiz corrections (if people still have questions that they are struggling with), and start on inductors, as we’ll need them for modeling loudspeakers.  I might introduce inverting amplifiers also.

2013 January 18

Sixth day of circuits class

Filed under: Circuits course — gasstationwithoutpumps @ 19:32
Tags: , , ,
Circuit for third version of  design to get specified output voltage.

Circuit for third version of design to get specified output voltage.

I started today with yet another variant of the “do-now” problem:

You have sensor whose resistance varies from 1kΩ to 4kΩ with the property it measures and a 6v power supply.  Set the parameters for the following circuit to get an output voltage that varies from 1v (at 1kΩ) to 2v (at 4kΩ).

I did not give them the solution, but promised them a shortcut solution at the end of class.

My co-instructor then proceeded to develop voltage sources, current sources, load and source resistances, load lines (though he did not use that name nor prove that it was a line), Thévenin circuits, and Norton circuits. He showed how Thévenin and Norton circuits were indistinguishable from the outside, but ran out of time before getting to the Thévenin equivalent of a voltage divider.  His presentation was in a bit different order than I would have done it—I would have introduced the non-ideal voltage source first, plotted its load line, and then talked about the resistance of the ideal voltage source. I’ll have to think about whether I now like his order better or not.

The shortcut solution that I was going to give the students relied on that last step.  I did suggest that the students look at splitting the circuit into a voltage divider and the load resistance RC, and come up with a Thévenin equivalent for the voltage divider. Since we had already determined that a 3V source with a 2kΩ resistor  would convert the load resistance into the desired voltages, all we need to do is to come up with a voltage divider that changes the 6v source into a 3v source with a 2kΩ resistance.  Setting RA=RB=4kΩ does that.

I think that it is interesting to compare this circuit with the circuit using series resistors from Wednesday’s lecture (using a 6v power supply for each), using a gnuplot script.  Although both designs meet the specs for the voltage at the endpoints, they behave differently in between.

The following gnuplot script illustrates the differences:


s_circuit(r,ra,rb) = Vin*(r+rb)/(r+ra+rb)
sp_circuit(r,ra,rb) =Vin*parallel(r,rb)/(ra+parallel(r,rb))


set title "Calibration curve for resistance->voltage conversions"
set xlabel "Resistance RC (ohms)"
set ylabel "Output voltage (V)"
set xrange [1000:4000]

set key top left
unset label
unset arrow

plot s_circuit(x,10000,1000) title "series RA=10kohm, RB=1kohm",\
	 sp_circuit(x,4000,4000)  title "series-parallel RA=4kohm, RB=4kohm"

The series-parallel circuit from today's do-now question provides more curvature of the V-vs.-R plot than the series circuit of Wednesday's question.

The series-parallel circuit from today’s do-now question provides more curvature of the V-vs.-R plot than the series circuit of Wednesday’s question.

The series-parallel conversion might be more appropriate if we need more sensitivity at the low end, and the all-series one if we need more uniform sensitivity. That decision depends on how the resistance is related to the phenomenon we are measuring.

The series-parallel conversion circuit always draws more current from the 6v source than the all-series one, with 1.25mA at the low end and 1mA at the high end, instead of 0.5mA at the low end and 0.4mA at the high end.

I’m trying to decide whether to spend any more class time on this problem, or simply hand out this solution.  We will certainly revisit Thévenin equivalents, since they are such a useful tool.

There is no class Monday, and we have a lot of “stuff” to cover before the students can do next Thursday’s lab, so I need to see how much I can pack into the next lecture without losing the students.  At a minimum, they’ll need

  • complex numbers: e^{j\omega t} = cos(\omega t) + j sin(\omega t).  I’ll probably have to do this one by fiat, rather than any sort of elegant math, and there won’t be time in this lecture to do a nice development of phasors—that will have to wait until after the lab.
  • differential equation for capacitors: I = \frac{dV}{dt} C, derived from Q=CV (which they got reminded of earlier this week).
  • current for a capacitor with a sinusoidal voltage V(t)=e^{j\omega t} gives I(t) = j \omega C e^{j \omega t}
  • complex impedance (voltage over current)  Z = 1/(j \omega C)
  • behavior of RC circuits (just looking at amplitude, not phase)
  • gnuplot commands for setting up impedance functions for capacitors and series and parallel circuits (which can be done with a handout, rather than lecture time).

2012 June 24

Temperature lab, part 3: voltage divider

In Temperature lab, part2, I carefully measured the resistance vs. temperature curve for the Vishay BC Components NTCLE413E2103F520L thermistor, finding that either my thermometer was badly miscalibrated, or the manufacturer’s data sheet was misleading.  I got a resistance of 9.7kΩ (not 10kΩ±1%) at 25° C and a B-value of 3174°K, not 3435°K±1%.  A big part of the discrepancy is that I calibrated over a different temperature range, and the measured values deviated most from the manufacturer’s spec at low temperatures.

Actually, the manufacturer’s data sheet is not as bad as all that.  They give specs for the ratio of the resistance at various temperatures to the resistance at 25° C, and their numbers do not fall along a simple A e^{B/T} curve.  The report the B-value as a 2-point fit for T=25° C and T=85° C, but they also report resistance values every 5° C from –40° C to 105° C.  One can compute the B-value for any pair:

R(T_1) = Ae^{B/T_1}

R(T_2) = Ae^{B/T_2}

R(T_1)/R(T_2) = e^{B/T_1-B/T_2}

\ln \left( R(T_1)/R(T_2)\right) = B(1/T_1-1/T_2)

B = \frac{\ln \left( R(T_1)/R(T_2)\right)}{1/T_1-1/T_2}

But even if I use their calibration data down to 0° C, I don’t get as small a B-value as I get from my measurements. My calibration curve does not fit their spec, even if I look at the table, rather than the simple B-value model (though the table is closer to my measurements, it doesn’t match).

How big a difference would if make if I used their Ae^{B/T} curve rather than mine?  At R=6685Ω, we get the same temperature either way (96.446° F).  At the resistance they claim for 0° C (27348Ω), their B-value model would give 33.90° F and mine would give 29.37° F.  At the resistance I measured for 0° C (25.5kΩ), their model would give 36.67° F, while mine gives 32.32° F (which is closer than the measurement error I had on temperatures).  So it looks like relying blindly on their B-value model introduces an error of over 4° F at low temperature, but in a digital thermometer for human body temperature, one would get nearly the same result with either calibration.

Voltage divider

The second part of the lab was to use the calibration curve to design a circuit to convert the resistance variation into a voltage variation that is nearly linear with temperature, at least over a small range.  The simplest circuit to convert a resistance to a voltage is a voltage divider, which just requires a voltage source and another resistor.

A simple voltage divider for converting the thermistor resistance to a voltage. Because I want the output voltage to increase with temperature, but the resistance R(T) decreases with temperature, I put the thermistor on the top branch and fixed resistance on the lower branch.
Circuit drawn with the Circuit Lab editor.

The formula for the output voltage is simple: V_{out} = V_{dd} R_1/(R_1+R(T)), where we are approximating R(T) \approx A e^{B/T} for temperature T in Kelvin. We’d like the voltage to be as linear as possible, which means we want the second derivative of Vout with respect to T to be zero. Obviously, we can’t do that for all values of T, but we might be able to do it for a particular value of T, and to have a small second derivative in that neighborhood.

We can take the derivatives by hand (or use a tool like Maple or Mathematica):
\frac{d V_{out}}{d T} = V_{dd} \frac{R_1 B R(T)}{(R_1+R(T))^2 T^2}
\frac{d^2 V_{out}}{d T^2} = V_{dd} \frac{R_1 B R(T) (R_1(B+2T)-R(T)(B-2T))}{(R_1+R(T))^3 T^4}
The second derivative is 0 if R_1(B+2T)-R(T)(B-2T)=0, that is if R_1 = R(T) \frac{B-2T}{B+2T}.

We can use this formula to set the value for any temperature, for example, if we want linearity around 98.6° F (310.15° K), we can set the series resistor to 4323.64Ω.

Expected voltage curve using a voltage divider with series resistor optimized for 98.6° F. Note that the curve is fairly linear from about 70° F to about 130° F (where the red non-linear curve and the green linear approximation at 98.6° F are quite close.

Of course, commercially available resistors don’t come in values like 4323.64Ω, so in doing a design one has to pick an available resistor, using the EIA table of standard resistor values.  A 4.7kΩ resistor looks pretty close, which would be color code yellow-violet-red.  Too bad that I don’t have one.  I do have a 5.1kΩ resistor, which would be optimal for linearizing at 90.06° F.  We should, of course, ask students to do the resistor selection for a different temperature than the one we use in an example, and they should be using their own B-value.

Testing the voltage divider

I set up the voltage divider on a breadboard.  Because I knew my wall wart had a huge ripple, I added a low-pass RC filter consisting of a 100Ω resistor and a 470µF electrolytic capacitor.  This slightly complicates the analysis of the voltage output, since the Vdd voltage is itself dependent on a voltage divider.

Low-pass filter to clean up the output of the wall wart. With the low-pass filter in place, we can model the power supply as a 5.166V source and 100Ω series resistor.

Here is what the low-pass filter looks like on the breadboard. The red and black wires from the bottom come from the connector to the wall wart. The 100Ω resistor runs vertically up the center, and the electrolytic capacitor connects across to the ground. The red clip lead is from the multimeter and is set up for measuring the voltage at the output of the filter.

Here is the full breadboard, showing the RC filter, the series resistor, the leads to the thermistor (the red and yellow lines with the crimp-on connectors), and the clip leads to the multimeter (the red and black alligator clips). I’ve found it very handy to have a number of double-sided header pins to make easy connection points on the breadboard for clip leads.

Here is the setup used for testing. The thermistor and thermometer are in the ceramic-cup water bath, with the thermometer held to keep the bulb in contact with the thermistor. You can see that the least-significant digit of the LCD display is a bit hard to read—applying some pressure to the display often makes it readable. Clip leads are essential to doing this experiment—holding the multimeter probes to test points would be a major hassle.

I only made 21 measurements of voltage, since I was not going to be fitting a model to the data, but just using the model I fit from the resistance measurements.

Plot of measured and theoretical voltage vs. temperature for the thermistor. The non-linear theoretical curve seems to be a pretty good fit (though it was not fit on this data, but on the previous series of resistance measurements).

The range of the voltages with the series resistor (from about 0.85v at freezing to 4.15v at boiling) is fairly reasonable for direct conversion to digital for the Arduino 10-bit ADC. In the middle of the range, the slope is about 0.0233 V/°F, which would give a resolution of about 0.2°F for Arduino readings.  (Of course, with the Arduino, we would not need the low-pass filter, and Vdd would be a well-regulated 5v, so this calibration curve would have to be redone.)  Even if we use the computational power of the Arduino to correct the non-linearity of the voltage curve, it is still useful to select the series resistor for the temperature we are most interested in, since that point gets the largest slope and hence the highest temperature resolution for fixed-size steps in voltage quantization.


A lot of thermistor circuits on the web have a resistor in parallel with the thermistor, as well as the one in series. I wondered what the effect of this extra resistor was.

Circuit with resistor in parallel with the thermistor, as well as in series.

I tried analyzing this circuit also, using the same brute-force approach of computing the second derivative of the voltage and setting it to zero.  I got a result that surprised me initially:  the second derivative is zero if R_e(B+2T)-R(T)(B-2T)=0, where R_e is the resistance one would get for putting the series and parallel resistors in parallel. This is exactly the same condition as before, but with R_e replacing the series resistor R_1.

After I thought about this for a while, I realized that I should have been able to get there directly. If you think of the circuit as connecting the thermistor to a voltage divider consisting of R2 and R1, then you can replace the ground and that voltage divider by the Thévenin equivalent, which would be a voltage source with voltage V_{dd}\frac{R_1}{R_1+R_2} and a series resistor consisting of  R1 and R2 in parallel: \frac{R_1 R_2}{R_1 + R_2}.  The only reason to put in a parallel resistor would be to restrict the voltage range (which might be useful if the output were to be amplified, but is not useful if the output is going directly into an analog-to-digital converter whose full-scale range is 0 to Vdd).

%d bloggers like this: