Gas station without pumps

2016 April 28

Revised microphone pre-amp lab too long

Filed under: Circuits course — gasstationwithoutpumps @ 23:47
Tags: , , ,

How many of my posts have the theme “lab too long”? (answer: too many)

I spent 10 hours in the instructional lab on Tuesday and 11 hours today (Thursday) helping students do the microphone pre-amp lab, and my group tutor is going to have to open the lab on Sunday for several students to finish soldering and testing their boards.

This means that the lab is between 1.5–2× longer than it should be.  You’d think that I would be able to predict the length of a lab better by my fourth year of teaching this course!

What went wrong, and how can I fix it for next year?

  • The design is somewhat harder for the first op-amp lab than in previous years, because I made a decision to do all the op-amp labs this year with a single power supply, not dual supplies.  That makes for a slightly more difficult start, but students don’t have to make the transition from dual supplies (which are getting quite rare these days) to single supplies. The transition is a surprisingly hard one for students to make, as the simplification that they learned for the case when the reference voltage is zero no longer apply, and they have to learn everything over again.  Learning the more general form first will, I believe, result in less confusion in the long run, but it does make for a slightly more complex first project.
  • This year I’m having students solder their pre-amp boards, so that they can re-use them as part of their class-D power amplifier in three weeks.  This was a deliberate choice, to reduce the amount of effort in the class-D lab, which was running too long in previous years, but it roughly doubled the time it took students to finish the lab.
  • Because students had larger ceramic capacitors this year, and I had them set the high-pass cutoff frequency near their speaker resonances, some students opted to use very large capacitors and small resistors for their high-pass filters. This made a very small impedance in the passband, and attenuated the signal from the microphone and its large-impedance biasing resistor.
    I’ll have to put a warning in the book about the high-pass filter needing to have a larger impedance than the bias resistor, to avoid changing the current-to-voltage conversion.
  • Some students had the opposite problem, putting a small capacitor with a very large resistor, so that there was a very high impedance signal driving the input to the amplifier. Since we are using op amps with tiny bias currents, this is not a problem for the circuit’s functioning, but it made looking at the signals with the oscilloscope difficult—increasing the difficulty of debugging.
  • Many students were surprised to see that the output voltage was not centered at their Vref voltage.  This provided a teaching moment for looking at the MCP6004 data sheet and explaining the notion of the input offset voltage. Because they were using gains of 100×–300×, the ±4.5mV offset became an output offset of ±0.45V–1.35V, sometimes resulting in serious clipping.  I need to warn students about that imperfection of op amps before they do the design.  A better design would use a multi-stage amplifier, with high-pass filters between stages to get rid of accumulated DC offset.
  • I suggested to several students that they look at Vout vs. Vin, by recording a slow sine wave (say 300Hz) at 5kHz sampling with PteroDAQ.  This turned out to have some interesting effects when students used 32× averaging, because the time delay between the two channels was enough to get the signals far enough out of phase to open up the plot into an ellipse. Again, I’ll need to talk about that in class tomorrow.
  • Lots of students made the mistake of incorrectly applying Ohm’s Law and getting too large a bias resistor, so that their microphones were not in saturation at the power-supply voltage of 3.3V.  Luckily, increasing the voltage to 5V (as we will do in the power-amp lab) will rescue their designs.
  • Lots of students made the standard mistakes of skipping a wire or two, or putting a wire in the wrong hole while soldering, but a surprisingly large number connected both nodes for a resistor to the same end of a resistor, leaving the other end unconnected.  I’ve not seen that mistake before, so I don’t know what triggered it.
  • The lead-free solder we have to work with this year (99.3% Sn, 0.7% Cu) is a pain to work with—it doesn’t tin the soldering irons well, and it is difficult to remove from the boards in the event of a mistake.

I think that the soldering lab should not be the first op-amp lab, but I still like the idea of the students having to solder up their microphone preamps. So I’ll have to do a major reorganization of the book this summer, to move a different lab into the first position.

Currently, I’m thinking that the transimpedance amplifier and pulse monitor lab would be a good choice as the first op-amp lab.  It would be a bit unusual to start with a transimpedance amplifier rather than a standard voltage amplifier, but the transimpedance amplifier is actually conceptually simpler.  Unfortunately, the pulse monitor using a transimpedance amplifier really needs to be 2 stages, with a transimpedance amplifier to bias the phototransistor, a high-pass filter, and an AC gain stage.  (Yes, I know I’ve posted about pulse monitors without amplifiers, but a major point of the lab is to teach about transimpedance amplifiers.)

The corner frequencies for the pulse monitor are really low, requiring big resistors even with their biggest capacitors, so the “too small a resistor” problem goes away, though not the “too big a resistor” problem.

By making the microphone preamp the second, or even third, op amp lab, students will spend less time on getting a breadboarded design working, and more time on learning to lay out and solder their circuits. They’ll also be much more amenable to a 2-stage design, to reduce the output offset voltage.  I think that rearranging the labs may be worth the effort it will take to rewrite the corresponding chapters of the book, but undoubtedly something else will go wrong next year, and I’ll have to do yet another major revision.

Ah well, at least I’ve gotten the demo for tomorrow’s class (blood and breath pressure) working tonight, and I’ll be able to get to bed before midnight.

2015 September 6

Ultrasonic rangefinder pings

Filed under: Uncategorized — gasstationwithoutpumps @ 23:00
Tags: , , ,

Earlier today I made a comment:

One of these days (when I’m not working on my book or teaching classes) I’ll have to get out the ultrasonic rangefinders again and experiment with them to find out what the problem really is. I think that the problem is that they are just sending a pulse and listening for the echo, and that the echoes are weak from small targets. It would take some sophisticated signal processing to detect and deconvolve the echoes when they are weak, and the cheap sensors just don’t have the capability to do that.

The MaxBotix MB1020 that I have only claims a 1″ resolution, which is probably not good enough for physics labs (they also make sensors for which they claim 1mm resolution). It sends out a 42kHz square-wave burst and provides 3 different ways of interfacing the return value. It has a free-running mode that could interface well with PteroDAQ.

The Ping))) sensor that I have uses a 40kHz square wave (8-cycle burst), but does not report a resolution—I suspect that resolution is limited by the noise in the filter that detects the return pulse, and varies a lot depending on the strength of the return signal. It requires sending a pulse to the sensor to initiate each measurement—something that PteroDAQ doesn’t currently offer (though we’ve thought a bit about how to add that sort of capability to PteroDAQ).

Since it is Sunday today, and I was feeling too fuzzy-headed to do any more work on the book, I decided to use my new microphone pre-amplifier and the Bitscope oscilloscope to look at the pings put out by the Maxbotix  MB1020 and Ping))) ultrasonic rangefinders. (Note: I bought both of these 4 years ago, and they may well have changed designs somewhat since then.)

The electret microphone I’m using only has specifications to 20kHz, but it looked like it had slow rolloff, so I figured it would still respond at 40kHz.

The Ping))) sensor datasheet says that it sends out 8 cycles of 40kHz waveform when triggered, so I wrote a little routine to trigger it repeatedly (on an Arduino Duemilanove board, so 5V power).  The Maxbotix sensor triggers itself as long as power is supplied, so I powered it off the same board, again at 5V.

With the gain on my mic preamplifier turned all the way up, I got good records of the signals:

The Ping))) sensor seems to do 8 pulses as claimed (though it may be 9), and then lets the transducer ring for a long time.

The Ping))) sensor seems to do 8 pulses as claimed (though it may be 9), and then lets the transducer ring for a long time.

The Ping))) sensor can get away with allowing long ringing, because they listen to the echo with a different transducer. I also looked at the signals going to the transmit transceiver, which goes from 3.4V when off to –4.5V for the 8 pulses, then shows the ringing:

The initial part of the waveform is the driving signal—the ringing afterwards is from the transducer, not from the op amp.

The initial part of the waveform is the driving signal—the ringing afterwards is from the transducer, not from the op amp.

 

The Maxbotix chip has a more complex output waveform:

The Maxbotix pulse is at 42kHz as claimed, but the envelope is rather complicated.

The Maxbotix pulse is at 42kHz as claimed, but the envelope is rather complicated.

The Maxbotix sensor is louder, and I was wondering whether they were doing active cancellation to try to stop the ringing—they need to have the ringing stop quickly in order to turn the transducer around and use it as a receiver.

The input pulse to the Maxbotix transducer is more symmetric, a 9.4Vpp signal instead of the 7.9V non-centered signal for the Ping))) sensor.

The Macbotix sensor has 13 cycles of excitation, and the sensor does not seem to exhibit much ringing afterwards electronically (though it certainly did when listening with the mic).

The Macbotix sensor has 13 cycles of excitation, and the sensor does not seem to exhibit much ringing afterwards electronically (though it certainly did when listening with the mic).

Clearly they are not doing active cancellation of the ringing. Another possibility just occurred to me—they may be driving a 40kHz resonant transducer at 42kHz, and the complex envelope could be a beat pattern between the driving signal and the natural resonance. But if that were the case, I’d expect the ringing to shift frequency towards the 40kHz resonance, and I’m not seeing that shift, even when I use the Bitscope to zoom in on the later parts of the ringing.  Despite not seeing a frequency shift, I think that the beat pattern in the best explanation I have for the waveform envelope.  That envelop shaping would also explain why Maxbotix is using  42kHz signal, when 40±1kHz seems to be the standard spec for most cheap ultrasonic transducers.

2015 September 5

Microphone preamplifier

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 15:47
Tags: , ,

I tried out the new op-amp prototyping boards by wiring up microphone pre-amplifier (a slightly more sophisticated version of Lab 7 from the book).

The new boards have just a quad op-amp chip, rather than a quad op-amp and an instrumentation amp. This allowed more room for resistors and a somewhat looser layout, making wiring and routing easier.

The new boards have just a quad op-amp chip, rather than a quad op-amp and an instrumentation amp. This allowed more room for resistors and a somewhat looser layout, making wiring and routing easier.

I made some of the mistakes I chide my students about:

  • I didn’t check my wiring carefully against my layout—I had left out the wire from the microphone to the bias resistor for the microphone, resulting in 0V for the mic and no signal to amplify.  Debugging this only took a couple of minutes, but I had to get out the soldering iron again, because I had 0ver-confidently put it away.
  • I hadn’t checked my layout carefully against my schematic—I had accidentally routed the microphone bias resistor to 1.65V instead of 3.3V.  This required removing 2 wires and replacing them.

After fixing those wiring mistakes, the circuit worked fine.  I also determined that it is possible to do the microphone pre-amp lab without an oscilloscope.  PteroDAQ does a reasonable job of capturing the waveforms:

Screenshot of PteroDAQ showing the sparklines for a 330Hz sine wave.  Note that for steady-state signals, the RMS reported can be used for calculating the gain.

Screenshot of PteroDAQ showing the sparklines for a 330Hz sine wave. Note that for steady-state signals, the RMS reported can be used for calculating the gain.  Here I had the gain for the amplifier set fairly low (2.49 in the first stage, and 6.61 in the second stage).  When I get near the resonant frequency of the loudspeaker (around 156Hz), the high-gain waveform goes rail-to-rail.

%d bloggers like this: