# Gas station without pumps

## 2015 May 2

### Welded welding rod

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

I noticed an interesting corrosion pattern on one of the stainless-steel electrodes used in the applied electronics for bioengineers course:

Note the neat corrosion ring around the nearer electrode.

I think that the dark ring on the stainless-steel rod comes from welding stainless-steel wire together in the manufacturing process of making the rod, probably before the wire was drawn down to the 1/8″ diameter. Because the rod is sold for TIG welding, in which it will be melted in the normal use case, having an occasional weld in the rod where material properties change slightly should not matter. Our using the stainless steel rods as electrodes revealed a structure in the rod that is not normally visible.

I think I was lucky to see even one instance of this pattern, since I would expect that the wire-drawing process only adds welds every few hundred meters of rod (when new feedstock has to be joined), and I only sampled about 65cm of rod (26 electrodes about 2.5cm long).  But maybe I’m wrong about the process that is used for making stainless-steel welding rods, and they actually have frequent joins.

## 2014 April 24

### Stainless steel electrode analysis

Filed under: Circuits course — gasstationwithoutpumps @ 00:20
Tags: , , ,

After yesterday’s lab I wrote

I do have to get the students to start lab more efficiently. Once everyone had their setup built, they took measurements fairly quickly, but they came to lab with no schematic of their test circuit and no table set up for recording their measurements. The first hour of lab was wasted by almost everyone doing the pre-lab work that they should have done over the weekend and asked about in class on Monday.

I started out today’s lecture talking about that—how everyone was very efficient in the last hour of lab, but how it had taken them forever to set up, because they hadn’t come to lab with their schematics already drawn, ready to build, nor their data tables set up, ready to fill in.  I’ll see if they are more efficient in Thursday’s lab.

I also wrote

Tomorrow I’ll spend some time helping them write gnuplot scripts to model their impedance data.  I’m assuming it will look a lot like the data I collected last year, which means that the conventional model of polarizing electrode will not fit all that well.

I hope that we also have time for some complex impedance and voltage divider problems, so that they have a little more practice before Friday’s quiz (which I still haven’t written).

We ended up spending almost the entire hour looking at gnuplot scripting and model fitting.  In fact, the data did not fit the polarizing electrode model ($(R_{surface} || C_{surface}) + R_{bulk}$) at all well, though the students got pretty clean data from 10Hz to 300kHz. We spent some time talking about whether the model was useful, even though it was as much as 20% off, and looked at a simple power-law model that was even further off.

I showed them how to fit data for log-y plots by using fitting the log of the function to the log of the data. I don’t know how many of them got the point of that, though, as my explanation was not as clear as it might have been, and I saw some blank looks.  I’ll probably want to revisit that next week, with a clearer explanation, when we do a similar measurement lab for the loudspeaker.

The problem with the conventional polarizing model is that it predicts a fairly simple Bode plot, with a constant resistance at high frequencies (Rbulk) and at very low frequencies (Rbulk + Rsurfacec. The data actually has no flat spot at frequencies as low as we could measure,
and impedance is still dropping, though slowly, at the highest frequencies we could measure.

I’m wondering whether it is worth setting up the PteroDAQ measuring system to look at much lower frequencies, to see whether impedance flattens out at a much lower frequency than the RMS voltmeters are good for.

Another possibility is try to set up a circuit to measure phase shifts, so that we can get a better idea of the complex impedance, rather than trying to infer the complex impedance from the change in its magnitude with frequency. Both of those are going to have to wait, though, as I have to write the quiz for Friday, provide feedback on some grad student papers, grade this week’s lab, grade the quizzes, and write an all-new lab handout for transimpedance amplifiers.

Actually, I’m thinking that we should do the simple one-stage or 2-stage audio amplifier first, then the transimpedance amplifier for the optical pulse monitor.  So probably this weekend will be on rewriting the audio amplifier lab.  I’m a bit torn, though, as it would be good to do the audio amplifier and power amp back-to-back, particularly if we could do the 2-stage op-amp version in one day and spread the class-D amplifier over three days.  Oh, well, I don’t need to decide until this weekend—I’ll be too busy with the quiz before them to re-order the schedule.

## 2014 April 22

### Stainless steel electrode lab went fairly well

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

Today’s electrode lab went fairly well.  This is the lab I always panic about, because the students have to move concentrated salt water (up to 1M NaCl) around the lab, and salt water and electronics equipment must not mix! I only had to chide one student once for not using the secondary containment tub, and nothing was spilled.

I had the students do more measurements this year than last, having 4 different concentrations (1M, 0.1M, 0.02M, and 0.005M NaCl) and an unknown (tap water). Last year they only had 3 known concentrations, but had to do both stainless steel and Ag/AgCl electrodes in the same lab. Most of the students finished the lab.  One group still has one set of measurements to do on Thursday, and I stayed an hour late with the singleton student—this is a lab that goes much faster if one student records data while the other reads the meters, so I served as meter-reader for him after everyone else had left.

I spent some time at the beginning of class  to teach each pair of students how to use a vernier caliper to that they could measure the dimensions of their electrodes.  I also had them measure the thickness of the electrodes using my micrometer. I’ll have them do both again (without my instructions) for the silver wire electrodes on Thursday.  Ah—I need to bring in some salt so that I can make a strong salt solution for electroplating on the chloride!  It does not need to be pure, so I won’t use up the 1M NaCl that we have for them to measure their electrodes with.

I do have to get the students to start lab more efficiently. Once everyone had their setup built, they took measurements fairly quickly, but they came to lab with no schematic of their test circuit and no table set up for recording their measurements. The first hour of lab was wasted by almost everyone doing the pre-lab work that they should have done over the weekend and asked about in class on Monday. I did insist on seeing their schematics before I would let them have any of the salt water.  Several had to redo their circuits a few times, because they made no sense (only one wire of the function generator drawn, or a circuit that did not include their current measuring resistor).

Next year, I may have to add more explicit instructions in the pre-lab to make a schematic of their test setup and a table for recording results. Tomorrow I’ll talk to them about preparing for lab so that they can start work immediately, though I don’t know if it will do any good. For next year, I should also add some discussion to the prelab about adjusting the resistor size after making a measurement.  Almost all the groups chose to use a 1Ω resistor, which means that the voltage drop across the resistor was generally quite small (1mV to 180mv).  It would be better to use a slightly larger resistor (10Ω or 100Ω) to get larger readings.  I’ll also have to tell them to set the amplitude on the waveform generator to 10v p-p, so that the signals are large enough, as the default setting when the generator is turned on is only 100mV peak-to-peak.  I think everyone got the amplitude up to at least 1v, which may be good enough.

Tomorrow I’ll spend some time helping them write gnuplot scripts to model their impedance data.  I’m assuming it will look a lot like the data I collected last year, which means that the conventional model of polarizing electrode will not fit all that well.

I hope that we also have time for some complex impedance and voltage divider problems, so that they have a little more practice before Friday’s quiz (which I still haven’t written).

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

As planned I talked on Monday a little bit about polarizing and non-polarizing electrodes, giving them the the idea that the point of electrodes was to convert between ionic currents in solution and electron currents in wires, and that there was always a redox reaction to do the conversion.  (I did not use the term “redox” though, and I probably should have—I’ll try to work it in casually during lab today.)  I talked about three electrodes:

• the Ag/AgCl that is used for a lot of bio research, because it is non-polarizing, works well in salt water, is generally non-toxic, and is fairly cheap.
• stainless steel (particularly 316L), because it is commonly used in implants for its non-corroding, non-toxic properties, though it makes a polarizing electrode, which is not suitable for low-frequency measurement.
• platinum electrode used for the hydrogen reaction that is the standard non-polarizing reference electrode (and is used in a lot of gel-electrophoresis boxes).

Although I gave the chemical reactions for Ag/AgCl (pointing out that the ion current was chloride ions) and the hydrogen reaction, I did not attempt to do so for stainless steel, because I’m still not sure which of the many oxidation reactions are relevant. I did point out that the steel is kept from rusting mainly by a chromium oxide layer on the surface, and that the same mechanism that prevents rusting also makes stainless steel a poor transducer of electron currents to ion currents.  I’m not sure I got that message across though.

I think that it may be worthwhile, either in lab today or in our data analysis on Wednesday, to mention “redox” reactions by name, and to point out more clearly that the what makes stainless steel good for implants also makes it poor for electrodes—the notion that “metal conducts” may be too strong a prior, as students are not used to thinking about the surface properties of things, but just bulk properties.

For the second half of the lecture, I introduced the notion of load lines, with open-circuit voltage VOC and short-circuit current ISC to figure out the voltage and resistance of the Thévenin equivalent of power source. I then had them work out, as a class, the Thévenin equivalent of a simple voltage divider. They got it, eventually, but I had to work through some stubborn holes in their understanding of simple circuits from physics. I think part of the problem was terminology—they apparently did not know what “short circuit” and “open circuit” meant, which I did not realize was a difficulty until near the end of the time.

I did not get the students any RC impedance or voltage divider questions to work on—I hope we have a little time for that on Wed, before Friday’s quiz. I could assign homework with voltage dividers and RC circuits, but I’m reluctant to assign homework in this class, given the amount of work expected for their lab write-ups. Several students already aren’t doing the homework I do assign—many are not even reading the lab handouts with the pre-lab assignments until just before class, when it is too late to do the work. A lot of lab time has been wasted by students trying to do the prelab work during lab.

## 2013 December 21

### More on automatic measurement of conductivity of saline solution

I decided to look a little more at automatic measurement of conductivity of a saline solution again, continuing the ideas in Towards automatic measurement of conductivity of a saline solution.

The idea is a simple one: make a voltage divider consisting of the pair of electrodes on one leg and a known resistor on the other, put a square wave in, and measure the output voltage.  By making the measurements synchronous with the square wave, we should be able to eliminate the DC component and look just at the high-frequency response. The output should be proportional to $\frac{R}{Z+R}$, where Z is the impedance of the electrodes (which varies with frequency) and R is the known resistance.

See Better measurement of conductivity of saline solution for the variation in the magnitude of impedance with frequency for polarizable stainless steel electrodes and Making Ag/AgCl electrodes for non-polarizable silver/silver-chloride electrodes. For polarizable electrodes, we probably want to stay over 10kHz, which shouldn’t be a problem with the Freedom KL25Z board, but could be pushing the Arduino A/D converter.  I think that the Arduino scales down the 16MHz clock to 125kHz for the A/D conversion (it needs to be ≤200kHz), and at the auto-triggered rate of 13.5 clock cycles per sample, that is only 9,259Hz sampling rate.  With single samples, at 25 clocks per sample, we’re down to 5kHz sampling. (The Freedom KL25Z board looks like it could do over 300kHz at 16 bits.)

I suspect that the thickness of the oxide coating on 316L stainless steel varies a lot with conditions (thicker in oxidizing conditions, thinner in reducing conditions), so stainless steel may not be the best choice of material for a conductivity probe, even though it will contaminate solutions less than many other probe materials.  One commercial sensor (Omega CDE-45P) uses titanium for its electrodes “for greater chemical resistance.”

The commercial sensor uses a 4-electrode design, with two sense electrodes close to, but not touching, the drive electrodes.  They claim that this allows maintaining a constant drive level despite fouling of the electrodes.  I can see how that would be useful in a continuous monitoring application, where the characteristics of the electrodes would change over time.  I’m curious how well it works—something else for me to play with.

To avoid electrolysis at the electrodes, we want there to be no DC component to the drive signal, so the sense electrode should be biased to half way between the extremes of the square wave.  The crudest way to do this would be just to put a voltage divider between the power rails, and use the Thévenin equivalent resistance as R. A much fancier way would be do a low-pass filter of the drive signal and use that to bias a patch-clamp amplifier—something like this:

Possible circuit for the front end of a 2-electrode conductivity tester. U2 is a unity gain amplifier that monitors the drive electrode and feeds the RC low-pass filter, which sets the DC bias voltage for the sense electrode through the current-to-voltage amplifier made with U1.

A design like this should work so long as the drive signal remains between the rails of the op amp power supply. The output is proportional to the current through the electrodes, which is $I=\pm \frac{V_{hi}-V_{lo}}{2(Z+R_{3})}$, so $V_{out} = \pm \frac{V_{hi}-V_{lo}}{2}\frac{R_2}{Z+R_{3}} + \frac{V_{hi}+V_{lo}}{2}$.

The resistor R3 keeps the current small enough that the output of the of the current-to-voltage converter stays between the rails.  Both R2 and R3 could be increased to reduce the current, as long as R3 ≥ R2.  If R2 is set too low, then the signal for low-conductivity solutions will be too small to measure reliably, while if  R2 and R3 are set too high, then high-conductivity solutions will be difficult to measure, being too close to the full-scale range of the analog-to-digital converter.

Of course, if we know the high and low voltages of the input signal, we can get rid of the low-pass filter and amplifiers:

Simplified circuit for conductivity tester.

With the simplified circuit, the two resistors form a voltage divider, so that we have a Thévenin equivalent that is half the resistance to the voltage midway between the high and low voltage. This makes the output $V_{out} = \pm \frac{V_{hi}-V_{lo}}{2}\frac{R/2}{Z+R/2}+ \frac{V_{hi}+V_{lo}}{2}$.  This circuit is simple enough for the freshman design seminar, so I should check out how well it works.

The KL25 chip has regular-drive and high-drive digital outputs, rated for 5mA and 18mA respectively (with a 3.3v power supply).  PTB0, PTB1, PTD6, and PTD7 I/O have both high drive and normal drive capability selected by the associated PTx_PCRn[DSE] control bit. All other GPIOs are normal drive only.

I started out playing with the PWM outputs on the KL25Z board, because the interface for making nice square waves is so simple.  I found that the MBED pwmout_api.c file has some serious errors in it: the periods are off by 1 count and the default prescaling they chose does not allow integer numbers of µsec.  I fixed the off-by-one errors on period and changed the prescaling to be 48MHz/16=3MHz for the timer.  This allows integer arithmetic for setting in µsec and msec, but limits the period to 216/3 µsec = 21845µsec (instead of ~87.381 msec).

I have not yet figured out a good way to do analog-to-digital sampling triggered by both edges of the PWM output. I may end up using interrupts on the rising edge (timer interrupt, setting TOIE=1) and on the falling edge (channel interrupt, setting CHnIE=1).

Before that, I should probably make up some salt solutions and check that the waveforms look ok with the electrodes.  Let’s see—1M NaCl would be 58.44 g/l, or 29.22 g for 500ml, and 0.1M would be 2.922 g for 500ml. I made some 1M NaCl (probably a little lower concentration, since I used commercial table salt, which generally has a few other thing mixed in with the NaCl).

I set up the simpler 2-resistor circuit, and wrote a little program for the Freedom KL25Z board that produced square waves, using the touch sensor to get 2 virtual buttons to increase or decrease the frequency.  I examined the waveforms with the Bitscope USB oscilloscope (using the differential probe, though that wasn’t really necessary here).

At 1kHz (1000µs period), the input square wave (yellow) shows a little rounding and the output across the resistor (green) shows a bit of sharpening, both due to the capacitance of the polarizable electrodes. (click to embiggen)

At 100kHz, both the voltage and current waveforms look like pretty good square waves.

I made a table of measurements using the Bitscope cursors (a rather tedious method, but my son hasn’t made the Data Logger code for the Freedom  KL25Z yet, and I’m too lazy to do it myself).  The Bitscope showed considerable distortion of the 500kHz signal (not evident on a higher-bandwidth scope, so probabably due to the limitations of the BitScope amplifier—see my post on the Bitscope differential probe).

period µs freq kHz Vin
Vout
2 500 2.74–2.948 2.52–2.633
5 200 2.812 2.56–2.605
10 100 2.763 2.54–2.60
20 50 2.763 2.50–2.60
50 20 2.773 2.48–2.624
100 10 2.763 2.42–2.674
200 5 2.77 2.36–2.732
500 2 2.72–2.763 2.24–2.849
1000 1 2.70–2.782 2.02–3.00
2000 0.500 2.62–2.854 1.78–3.211
5000 0.200 2.56–2.941 1.34–3.642
10000 0.100 2.48–3.006 1.06–3.793
20000 0.050 2.40–3.072 0.74–4.069

Once the period gets longer than about 200µs, exactly when you look at the signals begins to really matter, as the voltage and current waveforms deviate more from a square wave. Below are the waveforms at 50Hz, which is as slow as I measured:

50Hz square wave input (yellow) does not look very square on the oscilloscope. The green output waveform (which is the current through the electrodes) shows the effect of the capacitance of the polarizable electrodes. (click to embiggen)

Using the results for the 100kHz square wave, I get that the resistance of the 1M NaCL solution with the 316L stainless steel electrodes is about 4.69Ω, similar to the 5.5Ω I estimated from sine-wave measurements last August (with a different 1M stock solution, not as carefully made). I can’t get this into any sort of standard unit, except by calibration with known reference solutions, since the value measured depends on the geometry of hte electrodes.  The same is true of commercial conductivity testers also.

Next Page »