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 27

Inductance of large inductor summarized

Filed under: home school — gasstationwithoutpumps @ 11:25
Tags: , , , ,

This post summarizes my inductance measurements, some of which I did with my son, some independently.

The goal was to determine the inductance of the large inductor that my wife found lying in the street and that I’ve used for a few things in the physics class with my son (like the Speed of sound lab).

Our first measurement used the Arduino data logger to measure an L/R time constant. Using a Schmitt trigger to clean up a mechanical switch output, we measured the voltage across a series resistor (hence the current) for step inputs (both upward and downward).  The upward steps were not useful, as internal resistance of the Schmitt-trigger inverter meant that the step was not clean—the voltage drooped as the current went up. The downward step did not have this problem. The inductance and resistance of the coil were determined by making measurements with both a 10Ω and a 100Ω external resistor, and fitting exponential time constants to the downward steps.  This gave a pair of linear equations in L and R to solve: L=(R+10\Omega)T_{10} and L=(R+100\Omega)T_{100}.  From these equations I got estimates of 78.5Ω and 0.410H. Note that the resistance includes all the wiring resistance, which was substantial, as I was using flexible jumper wires that are not made from copper and have a high resistance.

The next successful measurement again used a series connection of the unknown inductor and a 100Ω resistor, but the stimulus was a sine wave, rather than a step.  I measured the RMS voltage across the resistor and across the inductor for several different frequencies, and fit an L+R model to the magnitude of the impedance as a function of frequency: |R + j 2 \pi f L| = V_{L}/V_{100\Omega} 100\Omega.  With this method, I measured the inductance and resistance as 0.369H and 73Ω.  I also tested an AIUR-06-221 inductor (nominally 220µH and 0.252Ω) with a 1Ω current-measuring resistor and got 229µH and 0.258Ω.

Once I finally figured out that DC bias changes capacitance of ceramic capacitors enormously, I managed to get a Colpitts oscillator to work. I should be able to use the frequencies of oscillation with the small inductor and with the large inductor to get an estimate of the inductance of the large inductor.  With the center of the Colpitts tank at virtual ground, the AIUR-06-221 inductor oscillates at 7691Hz and the large one at 180.04 Hz  (both after a few minutes of warmup, as the frequency changes initially).  The ratio of the inductances should be the square of the ratio of the frequencies, that is L = \mbox{220E-6 H} (7691/180.04)^2 = 0.401 \mbox{H}, or 0.418H, if we use 229µH as the inductance of the AIUR-06-221. Note that this measurement depends on knowing the inductance of the small inductor, but does not require knowing the capacitance of the ceramic capacitors—just that the capacitance is the same for either inductor.

These oscillator measurements and the step-response measurements are consistent, but the modeling of the magnitude of impedance from the voltage measurements at different frequencies seems a bit out of line with them.  The problem may have been that the current-measuring resistor was small, so that the voltage measurements were small.  Perhaps I need another series of measurements with a 10kΩ current-measuring resistor, which should allow a better estimate of L (though not a good estimate of R). I tried again using a 10kΩ resistor and a frequency range from 320Hz to 15kHz, and got a fit for L=0.349H, the lowest estimate so far!

I’m not sure what the problem is with the measurements using the external sine wave.  Perhaps I should do another set using a different function generator, as the Bitscope Pocket analyzer produces pretty bad harmonic distortion at the higher frequencies.  I tried with the Elenco FG-500 function generator (which also has bad harmonic distortion, but different) from about 70Hz to about 16kHz, and got a fit for 0.356H.  This is similar to the measurements I got with the Bitscope function generator.

So, I’m left with a discrepancy that I can’t explain:  measurements of  0.35H for the sine-wave excitation and 0.41H for the L/R step and the Colpitts LC oscillator.


2013 June 26

Capacitance depends on DC bias in ceramic capacitors

Filed under: home school — gasstationwithoutpumps @ 06:56
Tags: , , , ,

I think I now understand why my Colpitts oscillator oscillated at a different frequency than I expected, and why the 4.7µF capacitor appeared to be a 4.0µF capacitor when I measured it. The problem is most likely the DC bias on the capacitors.

It turns out that cheap ceramic capacitors have highly variable capacitance, depending on temperature, DC bias, and AC voltage applied.  There is a pretty good explanation of these effects from Kemet, a capacitor manufacturer: Tech Report 2008-03: Why 47 uF capacitor drops to 37 uF- 30 uF- or lower.  The paper talks about several different voltage, temperature, aging, and frequency effects of both electrolytic capacitors and multiple-layer ceramic capacitors (MLCCs).

There is actually some interesting physics going on.  They explain that there are 4 different polarization mechanisms that can cause a material to exhibit a higher dielectric constant: electric, atomic, dipole orientation, and space charge.  These correspond mainly to the magnitude of the movements of charges.  The most important of them for the ferromagnetic ceramics used in MLCCs is the dipole orientation.  What happens with DC bias is that many of the dipoles are already aligned to the electric field, and so fewer of them can rotate as a result of any AC signal added to the DC, resulting in a lower effective dielectric constant and hence lower capacitance.

The effect depends mainly on the magnitude of the electric field.  A capacitor with a low voltage rating has a thinner dielectric, and hence exhibits this drop in capacitance at lower voltages than one with a high voltage rating.  They give an example of a 22µF capacitor with X5R dielectric dropping fairly linearly to about 18µF  (–18%) at 30% of its rated voltage then more steeply to  9µF (–60%) at 80% of its rated voltage.  The effect depends somewhat on which dielectric is used, but they don’t give the details in this survey.  This effect looks like a good reason to use a 3 times higher voltage rating on ceramic capacitors than the voltage you actually plan to use.

They do talk about the rating system for MLCC dielectrics (those mysterious codes like Y5V and X7R).  It turns out that these are talking about the temperature dependence of the dielectric.  The first letter gives the low temperature limit (X=–55˚C, Y=–30˚C, Z=+10˚C), the middle digit gives the upper temperature limit (2=+45˚C, 4=+65˚C, 5=+85˚C, 6=+105˚C, 7=+125˚C, 8=+150˚C, 9=+200˚C), and the last letter gives the capacitance deviation over the temperature range (A=±1%, B=±1.5%, C=±2.2%, D=±3.3%, E=±4.7%, F=±7.5%, P=±10%, R=±15%, S=±22%, T=+22/–33%, U=+22/–56%, V=+22/–82%).  Note: these ratings are for Class 2 and Class 3 dielectrics: Class 1 dielectrics use a different scheme for specifying temperature coefficient,which they also provide (those codes look like C0G or M3K, not starting with X, Y, or Z, and specify a temperature coefficient in PPM/˚C).

So an X7R capacitor has a ±15% variation over a temperature range of –55˚C to +125˚C, while a Y5V has a +22/-82% variation over –30˚C to +85˚C.  Now I see why the TI datasheet for the LM3668 Buck/Boost converter says “Multilayer ceramic capacitors such as X5R or X7R with low ESR [are] a good choice for this as well. These capacitors provide an ideal balance between small size, cost, reliability and performance. Do not use Y5V ceramic capacitors as they have poor dielectric performance over temperature and poor voltage characteristic for a given value.” Apparently, the high temperature dependence also results in high voltage dependence, which could be a real disadvantage in a capacitor used for smoothing out ripple in a DC power supply.

Unfortunately, I’ve forgotten exactly which capacitors I ordered last year, and I don’t have the original packaging.  Based on the price (I bought the cheapest at Digikey), they probably have X7R or X5R dielectrics, which appear to be the popular ones with a good tradeoff between size and performance. These shouldn’t shift much with temperature, but the voltage dependence may still be large enough to explain the effects I’m seeing.

If the problem is indeed the DC bias on the capacitors, then I should be able to control the frequency of the LC oscillator by replacing the ground connection between the capacitors of the Colpitts oscillator with an adjustable voltage source.  I used a potentiometer and a unity-gain buffer to provide a voltage source that was between the 2.5V virtual ground and the 0V power rail.  When the voltage source was at virtual ground, the frequency of the oscillator was 7.4kHz, but when the voltage was –2.44V relative to virtual ground, the frequency was 8.6kHz, a 16% change in frequency or a 26% drop in capacitance.  The change was fairly smooth with the bias voltage and was reversible and repeatable, so I’m reasonably convinced that what I was seeing was indeed a DC bias effect on the capacitors.

I had not been aware that the DC bias effect was so large in ceramic capacitors.

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: