# Gas station without pumps

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