# Gas station without pumps

## 2018 December 16

### Project Baseline

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

This month I joined a research project, Project Baseline, that is collecting detailed medical information on 10,000 subjects across the US.  I’ve not joined as a researcher, but as subject.

I wish I could tell you precisely what the goals of Project Baseline are, but none of their materials are very clear about that. The name suggests that they are trying to collect information about what results to expect from medical tests for asymptomatic patients—so many of the standard medical tests are only applied to people who are already ill that there is little idea what the results would be for a normal person.  Because the study runs for 4 years for each subject, they may also be looking for early-warning signals from tests—do any of the tests predict problems up to 4 years in advance?

The structure of the study is fairly straightforward—each subject gets extensive medical tests on an annual basis, wears a watch that monitors pulse and motion, and keeps a sleep monitor in their bed.  The selection of subjects is pretty broad: almost any US resident 18 or older who can get to one of the study sites is eligible.(You have not be allergic to nickel or metal jewelry, be able to speak and read English or Spanish, not work for Project Baseline, and be willing to share health information with them.)

I’ve been wanting to do a bunch of baseline fitness and health tests for a few years, but the retail cost of them has been prohibitive—with Project Baseline, not only were the tests free, but they pay me a tiny stipend for participating.  They also issued me a fancy watch for the pulse monitor and ECG and a sleep monitor to put under my mattress.

The watch, a Verily Life Sciences “Study Watch” has a nice E-ink display, but the firmware (BASELINE 000.048.009.BSL) is set up to make it less useful to me than my previous watch, a dime-store Casio model.  The study watch shows me only the date and time—and the time only to the nearest minute and only in 12-hour, not 24-hour format.  My dime-store watch showed seconds, could be set to 24-hour mode, and could be used as a stopwatch—none of which is possible with the study watch.

The wristwatch supposedly has an accelerometer for step counting—not a very useful feature for someone whose main aerobic exercise is bicycling. They should make an ankle bracelet for bicyclists—one that doesn’t look like the GPS ankle monitors worn by felons.  In any case, the step counter feature is not very useful, as the watch has no bluetooth synchronization, and only updates records when it is returned to its charging station.  That limitation makes it rather weird that the step count information is available only through a phone app, and not the Project Baseline web portal.  Because I don’t have a cellphone (and don’t see it as worthwhile to get one to view day-old step information), I have no access to this data record either.

The study watch is taking my pulse continually—it has a pair of green LEDs on the back of the watch that sample at 30 Hz (600µs on, 32.733 ms off).  It will also do a 1-minute ECG recording whenever I request one, which I’m supposed to do at least once a day.  Unfortunately, it never tells me my pulse nor is there anywhere I can look up either the pulse recordings or the ECG recordings, both of which I would find very interesting.  I’d really like to know what my pulse gets up to on my commute up the hill in the morning, and how long it takes to recover afterwards.  That information is being sent to Project Baseline, but they are not sharing it with me.

Similarly, the under-mattress sleep tracker is recording something about my sleep that I would be interested in knowing, but I have no access to that data either.

I had two 4–5-hour sessions of medical tests in Palo Alto as part of the study.  These seemed to focus mainly on cardiovascular tests, though there was a large panel of blood and urine tests also, and I had to ship them a bowl full of frozen poop by FedEx.

The first day included measuring my ankle-branchial index (the ratio of systolic blood pressure in the ankles to systolic blood pressure in the arms), to check for peripheral vascular disease.  One part of that is interesting, in that they listen to the blood flow with an ultrasonic Doppler-shift probe, which allows them to listen to a single artery at a time, presumably with more accuracy than just using a stethoscope.

They also took about 300 mL of my blood in many tiny tubes.  They ended up having to stick me three times: the first time the phlebotomist missed the vein, the second time they got only halfway through the tubes before the blood clotted enough to seal off the puncture, and the third time they managed to finish (though that puncture was the most painful of the lot).  I was not impressed with the competence of the phlebotomist—I’ve had less discomfort from the bigger needles of blood donations.

Other samples collected that day included urine, saliva (for oral microbiome I think, but possibly for genetic tests), tears, and swabs of ears, nose, inside cheeks.

They also took a 12-lead ECG, which I did not get to see.

They also spent a lot of time trying to get my medical history recorded.  I had brought detailed notes (which I left with them), but they had to enter it all into Google Forms, which seemed very poorly chosen for the task.

The second visit included some simple strength and balance tests, timed walking, vision screening, photos of cornea and retina, pulmonary function (including gas exchange), an echocardiogram, a stress EKG and echocardiogram, CT scan of my chest, and chest X-ray.  The timed walking consisted of some very short timed walks at low speed and high speed, then a 6-minute walk in the corridor at “normal speed”.  The person measuring that thought I might have set a course record in their hallway at 630m, but that is only 6.3 km/h or 3.9 mph, which not a particularly fast walking pace.  I suspect that many people find it difficult to walk at a normal pace when you have to reverse direction every 20m.

The pulmonary function and echocardiogram tests were the most interesting—it was particularly cool to see my heart beating and the false color showing the flow rate of the blood through the valves.

This is the MicroGard II mouthpiece that was used for the pulmonary tests.

The commercial mouthpiece used in the pulmonary function test might be useful for student lab kits next year, in place of the PVC elbow and barbed connector that the students currently use for their breath-pressure measurements.  The cost per student would be about the same, but I would have to make adapters as lab equipment—the circular tube fits tightly in a 1″ PVC slip connector, so it would not be difficult to make the adapters, but it would cost about $100 to make 25 adapters with barbed connectors and a 2mm vent hole. The main advantages to using the commercial mouthpiece are that it has a filter to prevent cross-contamination, that it holds the mouth comfortably open, that it comes with a nose clip to prevent air leakage through the nose, and that it is a standard medical component, and so will seem more real to students. The main disadvantage is that students would not get to practice using the drill press to drill the 2mm holes in the PVC elbows. Of course, they would still get to drill holes in Lego bricks for the pulse-monitor lab. The stress ECG and echocardiogram involved walking (and starting to jog) on a treadmill until the cardiologist thought I was working hard enough and had me immediately lie down to get an echocardiogram with my heart pounding. I believe that the intent was to get me up to my maximum heart rate, but I don’t think we achieved that, as I was not feeling that I was going all out when the cardiologist started telling me to stop any time. I got my heart rate to 163 bpm (which is over the normal guideline of 220 − age in years), but I think I could have gone higher. If they do the test again next year, I’ll have to tell the cardiologist not to hint at when to stop but to just keep increasing the treadmill speed until I call a halt. They were supposed to administer a hearing test, but I don’t remember getting one. It has been about a year since I last was tested by an audiologist, but I don’t think that there has been much change since then. If they want the data, they can probably access my medical records. Project Baseline has sent me a few results from the lab tests. All the numerous blood and urinalysis standard lab tests came back in the normal range, except the cholesterol test—and I already knew about my cholesterol. Besides which, the blood tests were not done fasting, so the cholesterol test was rather useless anyway—I did not bother adding it to my cholesterol records. They also sent me some results from my CAT scan, which were again mainly normal: the biggest reports were that I had no spleen (which I knew already) and that I may have had a viral infection in my lung (I did have a cold that week). The main thing they were looking for, calcification in the heart and arteries, came up with 0 calcium scores, though they also reported “trace focus of atherosclerotic calcification in the left anterior descending artery” and “calcifications of the aortic valve”. Aortic valve calcification is a common condition in older adults, but “usually doesn’t cause significant heart problems, but requires regular checkups to make sure your condition isn’t worsening” according to the Mayo Clinic. I suspect that Project Baseline will be doing those regular checkups for the next few years, but after the study ends I’ll have to make a point of having my valves checked every few years. The chest X-rays did tell me something I didn’t know—I have “azygos fissure”, which occurs in 0.4–1.2% of the population (different sources give different frequencies, depending on how the estimate was made). An azygos fissure is a result of a normal variant in embryonic development, in which the right lung grows around the right posterior cardinal vein, one of the precursors of the azygos vein, instead of the vein moving to the left as the lung grows. It generally is of no clinical significance, unless thoracic surgery is needed or it gets misinterpreted as something else when images are read. ## 2017 December 18 ### EKG without amplifier Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 18:24 Tags: , , , , I have done a lot of EKG projects on this blog, mostly for the Applied Electronics course, where an EKG amplifier is Lab 12, but some just for fun. Today I decided to see whether one could do an EKG with just the Teensy LC board or just an Analog Discovery 2 USB oscilloscope. The project was partly inspired by the Digilent post DIY ECG using a Analog Discovery 2 and LabVIEW, which I saw the title for and assumed that they were using just the USB oscilloscope. It turns out that wasn’t what they meant—it is just a simple 6-op-amp EKG amplifier looked at with the USB oscilloscope. The setup I tried was about as simple as you can get—I put on three electrodes wired up as Lead I (see earlier post for this configuration), connected the body electrode to ground, and the other two electrodes to the plus and minus leads of channel 1 of the Analog Discovery 2. The signal I got was quite small (about 1mV) and buried in 60Hz noise: The raw signal from the oscilloscope, sampling at 1200 Hz, shows some spiking from the pulse, but a lot of noise. The big R spike is only about 3 LSB, so quantization noise is a problem. I ran the recording through a digital filter to bandpass filter it to 0.1Hz–100Hz and put in a notch from 58Hz to 62Hz. The 100Hz low-pass had the effect of averaging out the noise, producing a signal with much finer resolution than the raw ADC values: After filtering, the EKG signal is fairly clear. I don’t recommend trying to use only a couple of the lower-order bits of an ADC, but it is surprising how much information can be recovered by the filter. I also tried using a Teensy LC board running PteroDAQ, using the A10–A11 differential channel. I had to bias my body between 0V and 3.3V, so I used a pair of 120kΩ resistors (one to GND, one to 3.3V) to connect to the body electrode. Once again the raw signal was not great: The signal had less noise than the signal to the Analog Discovery 2, but the signal was smaller also, negating the value of the finer steps of the ADC on the Teensy LC. Once again, digital filtering restored the signal: The signal-to-noise ratio here looks a little worse than for the Analog Discovery 2, despite the raw signal looking cleaner. I managed to get a cleaner signal for the Analog Discovery 2 by turning off the surge protector, so that there was no 60Hz current anywhere nearby. The results after filtering were no better (and possibly worse) than from the signal with the 60Hz interference, so I did not bother plotting them for this post. My conclusion is that it is possible to get EKG signals without adding an amplifier, but you can only see the signal clearly if you do some filtering. I’ll have to decide whether to recommend to students that they record signals directly from the EKG electrodes to get an idea what their amplifiers have to work with. ## 2015 June 3 ### Crude theremin On Monday I again had 2 lectures: one in Banana Slug Genomics on the Burrows-Wheeler Transform and FM index, and one in applied electronics finishing up the EKG preparation and starting into optional material. The BWT and FM-index lecture was a bit rough though I had prepped on the material for a fair amount of time over the weekend. I think that the written presentations I’d used to prep from (which included the Li and Durbin paper on BWA) were better than my lecture, so I ended up pointing the students to them as well, hoping that my lecture would at least make them more willing to click through and read the paper. In the electronics class, I provided some feedback on the lab reports (reminding students once again how to figure out the DC bias resistor for an electret microphone). Over the weekend I had finally caught up on the grading, so of course Monday saw a huge stack of redone work being turned in—I did the prelab grading Monday night, but I did not have the heart to start on the redone work last night or tonight. After the feedback, and questions from the class on the EKG lab, I gave the EKG demo (which had worked fine before cycling up the hill). Needless to say, it did not work when I hooked everything up in front of a live audience. But I turned this into a teachable moment by explaining what I thought the problem was (bad electrode connections, because touching the reference wire produced a change in the output), and getting out three new electrodes, adding a a little electrode gel, sticking them on next to the ones I was already wearing, and moving the clips over. Luckily, that was the problem, so I was able to demonstrate debugging, even with no lab equipment. The EKG demo concluded the required material for the course, and so I asked students for suggestions on what I should cover next. I suggested the electronics of the nanopore and nanopipette labs, and asked them for other ideas. One student wanted me to explain how theremins work, and a couple of others agreed that would be an interesting topic. So I finished Monday’s lecture on the nanopore electronics (basically telling them it was just a transimpedance amplifier, but engineered for high gain and very low noise, and talking a bit about the copper boxes around the stations to reduce capacitive coupling), and told them I’d try to talk about theremins on Wednesday. Tuesday’s lab went fairly smoothly, but I was kept busy helping students debug their designs—most often the problem was miswiring, but some students had electrodes that weren’t making good contact. I had on a set of working electrodes, so that we could swap the leads to my electrodes to see if the problem was the electrodes or their boards. A lot of the students had a lot more 60Hz noise pick up (even with my electrodes) than I was getting, and I could not always determine why. In some cases it was simply long wires on the breadboard. They’ll be soldering up their EKGs on Thursday, and the wiring should be much more compact there. Tuesday night I read up on a bunch of analog circuits relevant to Theremin design, and in today’s class I presented • a block diagram for a theremin (two oscillators—one with an antenna, a mixer, and a low-pass filter to pass only the difference frequency) • I showed them a rather crude theremin that they could implement from what they already knew: two relaxation oscillators using Schmitt triggers, an XOR gate, and an RC low-pass filter. (Only the XOR gate was new to them.) • I then talked about mixers, presenting a ring modulator (which they probably didn’t understand, as we’ve not done transformers except in passing), a simple two-resistors plus a diode non-linear mixer, and a synchronous decoder using a switch to change an op amp gain from +1 to –1. I mentioned a couple of Wikipedia articles they could look up for other mixer designs (Gilbert Cell and frequency mixer). • I then introduced the notion of a sine-wave oscillator as a loop with gain exactly 1 and a phase change of 2πn for some integer n. • The first oscillator I showed them was a Wien oscillator using an op amp, for which I derived that at $\omega RC = 1$ the phase change of the positive feedback was 0 and the gain was 1/3, so we could set the positive gain to 3 to satisfy the requirements. I mentioned the first Hewlett-Packard oscillator, and the trick of using an incandescent light bulb to control the gain and avoid clipping. I showed them a plot of the amplitude and phase change for the feedback circuit, using gnuplot functions that they are familiar with from their own modeling. • Next I showed them an LC tank circuit, and derived the infinite impedance resonance $\omega^2 LC = 1$. • I then got to a Colpitts oscillator, showing them a possible circuit using an op amp, and how to model it as cascaded voltage dividers using gnuplot. I showed them that the phase change of the feedback was 180° and that the phase change moved away from 180° very fast. I was running out of time, so I briefly mentioned the Hartley oscillator and the Clapp oscillator, but didn’t really go into them. On Friday, I plan to cover one-transistor amplifiers (common emitter with emitter degeneration and common collector—I probably won’t do common base), as those seem to be popular in theremin designs. Tonight, since I was not willing to face grading, I decided to try out the crude relaxation oscillator Theremin. Here is the circuit I ended up with (not including the bypass capacitors): I used the potentiometer on the second oscillator to do crude pitch matching for the two oscillators, just looking at the period on an oscilloscope. The emitter-follower amplifier was used to get enough current to drive the loudspeaker. The crude theremin only sort-of works. I could get high-pitched theremin-like noises from it, but when the difference frequency dropped to 500Hz, the two oscillators phase-locked and the speaker went silent (often with very irritating on-off stuttering). The phase lock occurred even though the oscillators were on different chips at opposite ends of the breadboard, and I had 10µF ceramic bypass capacitors on each Schmitt trigger package and a 470µF electrolytic on the middle of the power bus. Everything was powered to 5V with the USB power from my MacBook Pro. I also often got 60Hz modulation of the signal, often as a on/off square wave, when the frequency difference was close to the point where the oscillators phase locked. I’m not sure how the oscillators are getting coupled so that they phase lock when the difference frequency is small, so I’m not sure how to fix the problem. The 60Hz sensitivity is almost inherent in the relaxation oscillator design, since the thresholds for the hysteresis on the Schmitt trigger remain fixed, but the hand near the antenna couples in 60Hz interference. I suppose that over the summer I should try building a theremin with Colpitts oscillators or Clapp oscillators, to see if that works any better. ## 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. ## 2015 March 18 ### Freshman design projects moderately successful I just finished grading this year’s freshman design projects. I think that the projects were more successful this year than last year, in part because I kept the students focussed on electronics and programming (for which they had lab access and which I could help them debug), and in part because the projects were somewhat less ambitious. There were two groups doing EKGs and 4 groups doing blood pressure meters. Both EKG groups managed to demonstrate their projects working, as did one of the blood-pressure groups. (I’m being fairly generous here about what “working” means—they had to get their electronics to work, capture the data, and plot the waveforms, but further interpretation or software was not required.) The other three blood pressure groups did not manage to demonstrate their projects, but one of them managed to plot waveforms for the pressure measurements (without getting their high-pass filter and amplifier working for the pulse measurements). Some things I learned for next year: • Tell the students what op amp to get. A number of students picked op amps that turned out to be rather old-fashioned ones with very low input impedance (as low as 2MΩ), rather limited output ranges, and external nulling circuits. The cheap MCP6002 or MCP6004 chips would have worked better at lower cost. In fact, I gave one group that seemed to have a good schematic (but couldn’t get their circuit to work) an MCP6002 chip, which they wired in place of the op amp they had been using, and their circuit worked immediately. I would have done the same for other groups, but the others with poorly chosen op amps were about a week behind and did not have circuits that were that close to being functional. • Warn students sooner not to use FedEx. My son’s and my experience with FedEx this year has been that they are ludicrously slow. At least one group was burned by a ridiculously long delivery time, having ordered with FedEx delivery just hours before I warned the class about them. (The US Post Office is faster and cheaper for lightweight electronics orders from Digi-Key.) • Students who never ask questions in class probably don’t understand much that is going on—all the groups that successfully demonstrated their projects had at least one active participant in class. • Students who fail to turn in their progress report are almost certainly not going to complete the project on time—I need to be more assertive in getting them moving and demanding that they show me their schematics. Almost everyone had errors in their schematics on their first design (and one of the successful groups went through 4 incorrect designs before getting to one that worked). Students that are afraid to show me incorrect or incomplete work don’t get the feedback they need to correct the problems—I need to normalize errors more and insist on seeing stuff, even if it is wrong. • The MXP5050DP pressure sensors are very easy for students to use, though a bit pricey at$16 each.  The built-in amplifier makes doing pressure measurements with an Arduino fairly trivial (hook up the three wires of the sensor to A0, +5V, and GND).  They were a good choice for the freshman design seminar, though I’ll continue to use MPX2053DP sensors without an integrated amplifier for the applied circuits class—that assignment is intended to get students to design with an instrumentation amp and to understand a bit about strain gauges.
• Get the students to plot stuff earlier in the quarter. One group tried installing gnuplot on a Mac in the lab in the last few hours, which did not go well for them.  They did eventually find a plotting program that they could install and run, but then did not have time to run the data they collected through the filtering program I’d written for the class.  Their signals were pretty clean, though, and the plots they produced were good even with just the RC high-pass filter in their amplifier, without digital filtering.
• The students seemed (for the most part) pretty excited about the projects—even those whose projects didn’t quite work seem to have gotten a lot out of the lab times.  I should look in a couple of years to see how many have stuck with engineering majors (I suspect that some might switch to computer science or computer engineering, rather than sticking with bioengineering, but that’s ok).
Next Page »