Gas station without pumps

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:

Current-control-for-low-current

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:

Current-control-with-pFET

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.

 

Current-control-with-PNP

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).

2017 December 16

Laser cutting electrode holders

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

Because my applied electronics lab will have labs of 50 students (25 stations), I’ve needed to make a number of new setups. The lab will be taught in a space that is not normally a lab, so I’ll need to wheel in the equipment and set it up before the lab sessions and pack it all back up and wheel it out every Tuesday and Thursday.  Luckily, the lab is not very expensive—equipping all 25 stations, including storage tubs and the cart, cost lest than $10,000.  That is less than the cost of one station in the lab that we used in the past.

Some of the setups for the lab require me to build some equipment (pressure sensor breakout boards, stainless steel electrodes, electrode holders for silver wire electrodes, … ).  I made the stainless steel electrodes over the summer, and this week I made new electrode holders.

The electrode holders are laser cut from acrylic sheet.  Earlier this quarter I tried cutting them from 3mm acrylic from the hardware store, but that did not turn out well.  The lines that were supposed to be etched only partway through the pieces ended up cutting all the way through, even though I was using the laser cutter on its lowest setting and highest speed.

This week I used some 5.3mm thick acrylic sheet.  I cut at 8mm/s at the highest setting, and made the marking lines at 180mm/s at 20–25% power (the lowest setting).

A holder as it came from the laser cutter, with the protective paper still covering the acrylic.

The same holder with protective paper removed.

The holder with 6″ silver wire mounted so that alligator clips can attach to the wires at the top, while the bottom is immersed in salt water.

The marking worked fine, and the first few holders I cut were fine, but several of them did not get cut all the way through, which I did not notice until I had removed the acrylic from the laser cutter (so I couldn’t just cut the lines again).  I ended up having to snap several of the partially cut holders from the waste material.

One of the failed cuts—the ear broke off when I tried snapping the holder from the waste material around it.

I made enough spares that the two for which the ears broke off can be discarded, but I will have to use my rifflers to smooth some of the edges and open up notches on a few of the holders.

2016 December 16

Two-electrode vs. four-electrode impedance spectroscopy

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 16:49
Tags: , ,

Four electrodes with 1cm spacing.

Four electrodes with 1cm spacing.

Today I decided to revisit the water-conductivity experiments for the course, now that I have an easy way to do proper impedance spectroscopy (including phase information as well as magnitude), using the network analyzer function of the Analog Discovery 2 USB oscilloscope. I wanted to look at 4-electrode measurements, as well as the 2-electrode measurements we’ve done in the past.

First, I made myself a 4-electrode device, by cutting some ⅛” stainless-steel welding rod (316L rod for TIG welding) into 15cm pieces, drilling 4 ⅛” holes in a scrap of cutting-board plastic, and driving the rods through the holes with a hammer.

I then immersed the short end in tap water (using a mason jar, so that the long end stuck out the top) and used alligator clips to attach wires from the electrodes to a breadboard.

I connected the function generator through a series 1kΩ resistor to one of the end electrodes and ground to the other end electrode.  Channel one of the oscilloscope measured the voltage across the 1kΩ resistor (hence the current in milliamps).

Channel two of the oscilloscope was connected to either the two end electrodes (making a 2-electrode measurement similar to what we’ve done for years in the class), or to the two middle electrodes, for a 4-electrode measurement.  The idea of a 4-electrode measurement is that there is an electric field established in the bulk material by the outer electrodes, and the middle electrodes can measure that field without interference from surface effects that occur on the electrodes that are providing the current.

I used the network analyzer function to sweep from 2Hz to 10MHz.  I exported the data so that I could plot it as impedance (rather than as just the dB ratio of the two measured voltages).  For the 2-electrode measurement, we are measuring the impedance of the water and electrodes (voltage across the electrodes divided by the current through them), but for the middle electrodes, we’re looking at the voltage across the middle electrodes, divided by the current through the end electrodes.

The voltage across the middle electrodes is nearly a constant, up to about 1MHz, where wiring inductance starts to matter. The surface chemistry interferes with measurement of bulk properties at low frequencies for the 2-electrode measurement.

The voltage across the middle electrodes is nearly a constant, up to about 1MHz, where wiring inductance starts to matter. The surface chemistry interferes with measurement of bulk properties at low frequencies for the 2-electrode measurement.

The plot of the phase shows even better why 4-electrode measurement is useful:

The capacitive nature of the two-electrode system is seen at low frequencies, but the 4-electrode system has a resistive, nearly 0° phase shift (up to the point where the inductance of the wiring to the reference impedance starts to matter).

The capacitive nature of the two-electrode system is seen at low frequencies, but the 4-electrode system has a resistive, nearly 0° phase shift (up to the point where the inductance of the wiring to the reference impedance starts to matter).

I don’t think I’ll switch to 4-electrode measurements this year (if for no other reason than that I’d have to make a dozen new electrode sets), but I’ll keep it in mind for next year.

2015 May 3

Ag/AgCl electrode lab went ok

Filed under: Circuits course — gasstationwithoutpumps @ 23:15
Tags: , , , , ,

Like on Tuesday, on Thursday I spent a long time in the lab, from about 9 a.m. to after 6 p.m., because it takes a fair amount of time to set up and clean up when we are dealing with liquids (in this case, salt water) in the electronics lab.  The lab itself went fairly smoothly and the students all seemed to be collecting good data.

As I feared, we ran out of one of the 4 stock solutions: 3l per concentration for 28 students was not enough, unless students shared by transferring solutions from one group to another.  Next year I’ll have to get 200ml/student made up, or change the way the lab is run so that students have 6 sets of cups already pre-poured, and just grab a cup that they haven’t already used.  I worry a bit about careless students not cleaning and drying their electrodes between uses, though and contaminating a low-salt solution with salty electrodes.

I had one surprise this year.  We changed which brand of EKG electrodes we ordered (from Vermed to some foam-backed electrode with no brand name—not a substitution I remember approving, but I probably would have if asked).  It turns out that the new electrodes do not seem to be silver/silver-chloride.  Instead of resistance around 10Ω as the Vermed electrodes have, the new ones are in the 10MΩ range.  They must be using some polarizable electrodes instead of non-polarizable Ag/AgCl.  I hope that they work ok for the EKG lab at the end of the quarter (10MΩ should be ok, as the instrumentation amps and op amps have input impedances of 1GΩ and 10TΩ respectively, so a mere 10MΩ resistance should be negligible).

I am going to have to rework a big chunk of the book this summer, though, as the measurements ran into trouble with the input impedance of the voltmeters not being too large to matter, as we usually assume.  The AC voltmeters claim to have 1MΩ  || 100pF, which is great at low frequency but at 1MHz, that’s only 1.6kΩ.  The 1MΩ is tightly specified, but I believe that the 100pF is only an upper bound: there may be considerable variation in the capacitance from meter to meter.

The students who were attempting to measure the impedance of the new foam-backed EKG electrodes were probably actually measuring the impedance of the voltmeter.  Several of the measurements of the stainless-steel electrodes were also marred by the input impedance of the voltmeters.  On Tuesday afternoon, if I have any spare time in the lab, I’ll try measuring the input impedance of the voltmeters myself, to see what it looks like.  The test setup will be a simple one: two voltmeters in series, driven by a function generator.  I’ll shunt one of the voltmeters with a smallish resistor (say around 500Ω) and plot the ratio of the two voltages as a function of frequency (I’ll need a moderately high voltage from the function generator to make sure that the voltmeter on the shunt has enough voltage).  The voltage ratio should follow a simple pattern: \frac{V_{meter1}}{V_{shunt}}=\left| \frac{Z_{meter1}}{R_{shunt} || Z_{meter2}} \right|.  I can model the meters as a 1MΩ resistor in parallel with an unknown capacitor and fit the parameters (trying both meters having the same capacitance, and having different capacitances).  I can even do another set of measurements swapping which meter I shunt.

I think that a lot of the weird data we saw in Tuesday’s lab came from using large shunt resistors, so that the voltmeter impedance became more important (smaller) than the shunt resistor.

I’m considering also putting in the book a derivation of how to compensate for the meter impedance (if it is known).  I think that I’ll move the electrode lab later next year, closer to the EKG lab, so that we can go more directly from the microphone lab and the loudspeaker lab into the audio amplifier lab, and so that the electrode characterization is more immediately motivated.

In Friday’s lecture, I talked briefly about the possibility that the problems we were seeing with model fitting were that we had neglected the voltmeter input impedance, but I did not work out the details, because I had to introduce them to op amps and negative-feedback amplifier configurations.

I like to use a generic negative-feedback configuration, which includes inverting and non-inverting amplifiers as special cases, as well as the single-power-supply variants:

Generic negative-feedback amplifier design using op amps.

Generic negative-feedback amplifier design using op amps.

On Friday we got through the derivation of the various gain formulas, based on letting the open-loop gain go to infinity, but I’ll have to refresh that on Monday and introduce the unity-gain buffer: especially the unity-gain buffer as a voltage source for a reference voltage between the power supply rails.

2015 April 29

More model fitting in lecture

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

Today’s lecture was all about fitting models for the electrode data. I started by showing them how one could hand-sketch Bode plots, at least for RC and RL circuits.  We did a hand plot and a gnuplot plot for the R_{s} + (R_{p} || Z_{c}(C)) model with arbitrary values, showing the initial horizontal R_{s} + R_{p}, the final horizontal R_{s}, and the diagonal at \frac{1}{2\pi f C}.

In class I went through trying to do fits to data collected for stainless-steel electrodes, and showing how to debug various problems (it was all live-action plotting—I did not script my actions).  The biggest problems were getting very bad fits (in one case from taking the log of the function but not the log of the data, in another case from having bad initial values) and singular matrices (mainly from having variables in the function that didn’t affect the fit, though in some cases from trying to fit complex models to real data without taking absolute value of the complex model).

It turns out that the standard R+(R||Z_C) model is very hard to fit to the data we collected for the stainless steel electrodes.  The oxide coatings don’t leak much current, so we had no low-frequency plateau for estimating the parallel resistance from.  I suggested making the parallel resistance infinite and using a simple R+Z_C serial connection.  That can model the data well at high frequencies, where the change in |Z| is fairly small, but at low frequencies the model is poor.

I came up with a different model on the spur of the moment (not one I had ever tried before on electrode data): R + \frac{1}{j \omega^\alpha D} with a capacitor-like element having a smaller slope that the normal 1/f slope of a capacitor (about 0.6).  This turned out to fit the data quite well.  I don’t have a convincing physical explanation for the exponent α, but I suspect it has to do with diffusion times for ions near the surface of the electrode and depletion regions in the electrolyte.

In the new model, the R term probably corresponds to the bulk properties of the electrolyte solution and the \frac{1}{j \omega^\alpha D} term to the surface chemistry at the electrode, so 1/R should be proportional to the concentration of the NaCl, I think.  I wonder whether students will get that result in their fits.  I’m thinking that I should rewrite some of the book to incorporate this model.

I ended by trying to model some of the data collected by students that did not work well—they had a huge inductance uptick at high frequency (fitting nicely to something like a 3mH inductance).  I’ve no idea how they got that data, as I saw their setup and they couldn’t have had more than a few µH of stray inductance.  Other students had small upticks at the high frequencies that were almost certainly stray inductance, since moving the voltmeter leads to connect directly to the electrodes eliminated the uptick, which did not happen with the students whose data I tried modeling.  I showed students how to model the uptick with an additional inductor, but I really don’t know what went wrong with the student data—I didn’t see any problems with their setup or recording, so I can only assume we all missed something.

Some of the students at least are getting the idea that modeling is not forcing your data to fit the theory in the book, but looking for regularities in the data.

 

Next Page »

%d bloggers like this: