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.

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.

2013 June 23

Colpitts LC oscillator

Filed under: home school — gasstationwithoutpumps @ 19:07
Tags: , , ,

I wanted to try a different way of estimating the inductance of the large coil that we used for the L/R time constant lab.  In that lab, we had fitted an exponential to the current curve after a step change in the voltage, and gotten an estimate of L=0.41H, with a series resistance of 78.5Ω, but the resistance measurement was not quite compatible with the DC resistance measurement of 69.71Ω.  (The DC measurements are different each time I report them, because I’m using different connection wires, and the flexible breadboard wires have significant resistance.  With the connection wire resistance removed, the DC resistance of the coil is about 68.82Ω.)

Op-amp-based LC oscillator using the Colpitts oscillator design.

Op-amp-based LC oscillator using the Colpitts oscillator design.

I expected the oscillator to oscillate at the frequency of the LC tank, when the gain was set high enough to meet the Barkhausen stability criterion, that the loop gain be one and the phase shift be 0 (or an integer multiple of 2π).

The frequency of oscillation should be determined by (2 \pi f)^2 = \frac{1}{LC},

I built the circuit with two different inductors, one the AIUR-06-221 inductor, which from the spec sheet has an inductance of 220µH and a series resistance of 0.252Ω, the other the large unknown inductor.

  • With the 220µH AIUR-06-221 inductor and the 2 4.7µF capacitors in series, the resonant frequency should be 7kHz. What I actually measured for the oscillator was 9024Hz (with R3 at 1kΩ, not 3.9kΩ), which is way off from what I expected.  The gain needed from the inverting amplifier was –16.6, so the tank feedback circuit had a loss of about 24.4dB. The frequency is dependent on the gain setting: with the gain set so high that the output was very clipped, the frequency was around 8881Hz, while with the gain set barely high enough to get oscillation, the frequency was 9080Hz.
  • With the large inductor, I measured 229±2Hz, with R3=3.9kΩ and a gain of about –15.6 (23.9dB).  Scaling the known inductance of the 220µH inductor by the square of the frequency ratio implies that the large inductor is about 0.34H (not 0.41H).

I don’t understand why the frequencies are so far off from what I expected. I don’t see how to analyze the circuit to get the observed frequency—the phase shift of the feedback network is not particularly dependent on the gain of the amplifier, even if I include the input impedance of the amplifier in the analysis.  The op amp spec sheet makes a big deal about the phase not shifting even when the output is clipped, and I’m definitely observing a 180˚ phase shift in the feedback network at the oscillator frequency.  Perhaps I need to remove the tank circuit from the oscillator, and drive it with an external sine wave, to see how the phase shift varies with frequency, and compare that to my calculations using gnuplot.

I tried putting a sine wave into the 1kΩ resistor plus LC tank, and measuring the sine wave.  I used the Bitscope USB oscilloscope both to produce the sine wave and to observe it.  By using the XY plot and tweaking the frequency, I found a 180˚ phase shift at 9020Hz, which is consistent with how the oscillator behaved at moderate gains.  With the large inductor, I get the 180˚ phase shift around 225Hz, again fairly consistent with the behavior of the oscillator.  I confirmed that this was not an artifact of the Bitscope by observing the same signals on my Kikusui Cos5060 analog scope.   The frequency at which the phase shift was 180˚ varied slightly at different times (possibly temperature dependent?)—for the 220µH inductor, it was 9kHz±30Hz.

When I use an external oscillator, I see the 180˚ phase shift and peak in the output amplitude at 12.7kHz, not at 9kHz.    Now I’m even more confused.

One possible cause of confusion is that my external oscillator has a large DC offset.  When I add a 220µF DC-blocking capacitor, the resonance is around 8.6–8.8kHz, almost consistent with the oscillator behavior.  But when I use the DC blocking capacitor to decouple the Bitscope sine wave source, I  get the resonance initially at 7.6kHz, gradually rising to 8.4kHz.  If I use the external oscillator with the DC-blocking capacitor, but briefly short the inductor to rezero the big capacitor, I again get a resonance around 8.4kHz.

Would adding a DC component to the signal change the inductance of a ferrite-core inductor? I suspect so, due to changes in the distribution of magnetic domains in the ferrite—but that much??  The 220µH inductor would have to behave like a 150µH inductor to get the observed frequencies, unless all my thinking is messed up.  I’m now trying to think up a way I could test this: perhaps providing an adjustable DC bias to the tank circuit and measuring the inductance by change in the resonant frequency?  I think I’ll post this as is and hope for another post later.


Note: the CircuitlLab schematics now come with a “Thanks for using the free edition …” chunk of text at the bottom. I could have cut this off easily enough, but see no harm in advertising their service, which I’ve been using for about a year.  I had been wondering how they were going to monetize the service, but now I know—the free service now puts up obnoxious “please upgrade” messages every few minutes and blocks you from doing further work for a minute.  Their why-upgrade? page explains:

CircuitLab has been our primary project over the past two years, and we’ve been honored to deliver our user-friendly and high quality product without charge over this time. We are so excited to be able to offer you this continually improving software for a small monthly fee. Though we know this may take some of our loyal users as a surprise, we look forward to your continued support as we develop CircuitLab into everything we’ve always imagined it could be!

While I would not mind buying the circuit lab software, I’ve never been fond of the “small monthly fee” model, especially as their “small fee” is $5 a month for Hacker Lite, the equivalent of their old free service with no commercial use allowed, up to $100 a month for the “Platinum Service”, which includes commercial use, beta testing of new features, and priority support.  Given that I’ve had very few circuits that were actually simulatable with their simulator (they don’t handle oscillators well and their op amp models have stability problems), and they don’t have all the parts I need (they don’t have Schmitt triggers, instrumentation amps, or phototransistors; their  microphones are non-simulatable; and they don’t have parameters for the MCP6002 op amps I use), it isn’t clear to me that the schematic editor alone is worth $5/month or $49/year.  I may be looking for another schematic capture system (the Eagle schematics are too ugly to be a viable alternative).  I wonder if CircuitLab has any way to get the schematics out of their system into some other schematic representation (or vice versa).  Having a closed system was ok as long as it was free, but I would not want to invest money as well as time in something that I could not use on my own later. I already have 105 circuits in their system, and it would be nice to be able to have a backup copy on my own machine.

%d bloggers like this: