# Gas station without pumps

## 2015 May 29

### Two lectures: Jellyfish and EKG

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

I gave two lectures today: the first in Banana Slug Genomics on the k-mer counting program Jellyfish, the second in my Applied Electronics course on 2-op-amp instrumentation amps and EKGs.

The Jellyfish lecture went reasonably smoothly.  I rather like the program, because it is very old school.  It uses clever bit-hacking techniques to minimize memory usage in a straight-forward hash-table approach to kmer counting, rather than sophisticated and inscrutable data structures. It also take advantage of the CAS instruction (compare and save) to do lock-free parallel updates to the hash table. It is a computer engineering solution to kmer counting, rather than a computer science one.

The electronics lecture also went fairly well. I presented the internals of the instrumentation amp that they have been using:

The 2-op-amp instrumentation amp has a fairly simple design that is easy to remember.

In class we derived the gain equation by using three ideas:

• Negative feedback amplifiers keep the op-amp inputs at the same voltage, so V1=Vin+ and V3=Vin–.
• Kirchhoff’s current law ensures that all the currents out of V1 sum to 0, and all the ones into V1 sum to 0.
• R1=R4 and R2=R3.

We can write down the two current-law equations, and add them to cancel the terms involving V2.  That leaves us with an equation that can be rearranged to get the gain equation $V_{out}-V_{ref} = R_{1}\left(1/R_{1} + 1/R_{2} + 2 R_{gain}\right)$.  The students will have to build their own instrumentation amp as part of the EKG circuit for next week’s lab.  They won’t be able to match the resistors as exactly as the INA126P’s laser-trimmed resistors, but their op-amps have higher input impedance and rail-to-rail output, so the resulting instrumentation will be fine for them.  They can’t use much gain in it anyway, since the input ±1mV EKG signal can have as much as 200–300mV DC bias, so that they can’t use a large gain in the first stage without risking saturation of the amplifier.

After the instrumentation amp, I talked a bit about action potentials and ion channels and tried to give them an idea of how a wave moving through the heart gives rise to a voltage dipole, which is what we actually measure.  I still don’t have a crystal-clear view of that in my head that I can present on a chalkboard.  Perhaps I should look around for a video to point the students to.

I had originally planned to demo the EKG in class today, so I put on electrodes after my morning shower, but I decided to test the EKG boards I had before going in to work, and none of them functioned.  Since all of them had worked in the past, I attributed this to a failure of the electrodes, but I had no time to debug in the morning.  When I got home, I decided to try to debug the circuit.  Needless to say, when I hooked up the leads to the electrodes, the circuit worked just fine:

With 480Hz sampling, a moderate amount of capacitively coupled 60Hz interference can be seen.

A bandpass filter and pair of notch filters remove the DC offset and most of the 60Hz and 120Hz interference.

The only explanation that I’ve come up with (and the one my wife came up with without knowing any electronics), is that I was sweaty by the end of the day. If the electrodes had dried up a bit, then they might not have been very conductive. The sweat may have reduced my skin resistance and the resistance of the electrodes, giving a stronger signal (and a better Vref connection for the third electrode). I can anticipate this problem for Monday’s demo, by putting a dab of electrode gel on the electrodes before attaching them. The disposable electrodes aren’t supposed to need electrode gel, but it is a simple solution. I bought a tube of electrode gel earlier this year precisely in anticipation of needing it for dried-out electrodes.