Gas station without pumps

2014 April 17

Hysteresis lab ended well

Today’s lab went well, with very little intervention on my part. Students finished up their RC calculations, picked their resistors and capacitors, and got their relaxation oscillators working.  They then adjusted their R or C values to bring the oscillator into spec, if needed. Most of the help I gave during all this was getting the students comfortable with using the Tektronix digital scopes, which have an extremely complicated and confusing menu system. The “autoset” feature on the scopes is almost essential, since they can have been left in any sort of weird state by the previous user, and finding and clearing all the weirdness takes a while.

Students then made their touch sensors (aluminum foil folded up to be sturdy, then wrapped with a layer of packing tape), and connected them to the oscillators. Most students got a substantial change in frequency, as expected, but one group had chosen a large C and small R, and so got almost no change. With only minimal prompting, they figured out why the frequency wasn’t changing, fixed their values and got it working.

The students did observe a change in frequency if they connected a scope probe to the input of the Schmitt trigger, and most eventually figured out that this meant that the scope probe was acting like a capacitor.  When I did it with my scope probe at home, I got a change from 60kHz to 35.22kHz, about a 70% increase in the RC time constant.  Since the capacitor I was using was 30pF, this looks like it implies a 21pF capacitance.   It doesn’t make much difference whether I connect the scope ground to the ground or the 3.3v lead—the change in frequency is the same either way, so we’re seeing an effect due to capacitance, not due to current through the oscilloscope input resistance. I looked up the specs for the input capacitance of my probes, and it is supposed to be 20pF in 10× mode and 130pF in 1× mode.  From that I worked out an approximate circuit for the probe:

Approximate circuit for my cheap 60MHz scope probes.

Approximate circuit for my cheap 60MHz scope probes.

With the 1× probe setting, the 1MΩ input resistance of the oscilloscope matters—connecting up the scope drops the oscillation frequency to 5kHz if the ground of the scope is grounded, and stops oscillation completely if the ground of the scope is connected to 3.3v.

The Bitscope DP01 differential probe, with no jumper plugs in place (so 2:1 setting on the Bitscope screen) reduces the frequency from 59.7kHz to 38.6kHz, implying about a 16.5pF input capacitance, while the spec claims only 2.5pF differential and 5pF common-mode. I don’t seem to be able to get a signal on the BitScope screen with the differential probe in high-gain mode, and I’m not sure why (the voltages shouldn’t be exceeding the voltage limits).  There may be some problem with powering both the BitScope and the device being tested from the same underlying USB power source, though it caused no problems in the low-gain mode.

Students soldered up the boards without problems. The only intermittent error that I had to help debug turned out to be a misuse of an alligator clip (the wire had not been screwed down, but only wrapped around the clip). No one soldered a chip in backwards and I did not need any of the spare boards or chips that I had brought along, just in case.

Luckily not everyone was ready to solder at the same time, as the lab support people had no board holders available, so only the two I brought from home were available.  I’ll have to ask them to get some PanaVise juniors (about $27 each) or, if they are too cheap to buy them, then some alligator-clip-based board holders for about $7 each.

Some students had enough time after soldering up their boards that I showed them how to get the frequency information that the KL25Z program was reporting to the SDA USB serial port (using the Arduino Serial Monitor).  Unfortunately, the old version of Windows running on the lab computers seems to have serious problems with cut-and-paste operations, and it was difficult to get more than a screenful of data that way.

2013 January 31

First soldering lab went fairly well

Filed under: Circuits course — gasstationwithoutpumps @ 22:31
Tags: , , , ,

Today’s lab, the hysteresis oscillator lab, went fairly well, though it needs a bit of tweaking for next year.  There were three parts to the lab: finding the upper and lower threshold voltages of the 74HC14N Schmitt-trigger chip, choosing a resistor and capacitor for the relaxation oscillator and testing it on the breadboard, then soldering the circuit and demonstrating it working as a capacitance touch sensor.

The first part, finding the threshold voltages, took longer than I expected.  Students needed more help than I thought they would in setting up a circuit to determine the thresholds—not unreasonably more, but I was a little over-optimistic about how independent they would be at this point.   I think I should provide a bit more support for the threshold measurements in the lab handout, and allow a bit more time for it. Using a bench power supply to provide the input voltage confused them and did not really save much time compared to setting up a pot from the 5V supply, as they did for the microphone characterization.

The hysteresis oscillator was the main design challenge, deepening their understanding of RC timing.  They had the circuit for the oscillator (though I should switch to using a CircuitLab circuit, since the Eagle one for the board was too confusing with the extra symbols for off-board connectors and extra holes).  All they needed to do was to pick appropriate resistor and capacitor values and wire it up.  There was one constraint and one design goal.

the low pulse width has to be between 20µsec and 1 msec
the low pulse width has to increase by 40% or more when the capacitive touch sensor is touched

For the pre-lab students were supposed to have computed the approximate increase in capacitance of the touch sensor  they made (Al foil covered with a layer of packing tape) when touched by a finger, but many were scrambling to do it during lab, which increased the lab time. I did not tell students whether they had gotten the value right, nor whether their resistor and capacitor values were reasonable. Instead, I told them what my Dad always said, “Try it and see!” [I need to make a poster for that!] In fact, some students appeared to have calculated the capacitance close enough, while others messed up their units and were off by a factor of 100–1000.  I hope that in their design reports, they provide both the corrected estimates and what they did with the initial mis-calculation.

I did do a 5-minute mini-lecture when one of the students was stumped because he couldn’t find a formula to compute the resistance and capacitance, and several other seemed similarly stuck but were too nervous to say so.  I had a mini-tirade about how the course wasn’t about finding the right formula, but about thinking through problems with the tiny set of  formulas on the study sheet they’d gotten the day before.  Then I calmed down and stepped them through a series of questions to show them how to think about the problem:  the goal was to pick R and C to get the right low pulse width.  What was the capacitor doing when the output was low?  About what voltage did it have? About what current was there?  How much charge had to be removed from the capacitor to get it from one threshold to the other?  How long would that take with that current?  I did say that they could use the proper exponential decay formula if they wanted, but that we only needed crude approximations, so a constant-current approximation was good enough.

One of the beauties of the Schmitt trigger oscillator is that it will oscillate over a huge range of resistor and capacitor values, so even if the students were way off in their component values, the circuit would still oscillate, once they wired it up correctly.  A lot of them are still rather careless about converting schematics to wires on the board, and fixing wiring errors was a big part of their debugging time.  Several still had the wires in place from the hysteresis voltage measurement, which really interfered with the oscillator.  When the oscillations were visible on the scope, I  had them touch their capacitive sensors to see how much the pulse width changed.  Most of the students who had mis-computed the capacitance of the touch found almost no change when the sensor was touched, but (with only a little hinting) could figure out that this meant they had used too large a capacitor and tried again with a much smaller one.  (I’m so glad I had them buy a large assortment of capacitors, so that they didn’t get strong hints about the “right” values from what was in the parts kit.)

Once they had an oscillator that responded to touch with a large change in period, I had the students estimate the low pulse widths from the scope display.  Many found that they were not in spec for the pulse width, so had to change their resistor values.  I think that this exploration of the design space is a valuable aspect of this lab, so I actually am pleased that students did not immediately get the “right” answers.  I hope that some students recorded the low pulse widths with and without the sensor touched, and use it to compute a better estimate of the capacitance of the touch.  (If they didn’t, that is a quick addition to the lab that they could do Monday after class, since it only requires the oscillator board, an oscilloscope, and a 5V power supply—they don’t even need the Arduino.)

Once they had the oscillator working, I had them connect up to the Arduino boards, downloading the following code that I had written for them:

// Capacitive sensor switch
// Sun 2013 Jan 27 15:23 Kevin Karplus

// To use, connect the output of the hysteresis oscillator to
// pin CAP_PIN (default is digital pin 2) on the Arduino.
// The code turns on the LED on pin 13 when a touch is sensed.

// The Arduino measures the width of one LOW pulse on pin CAP_PIN.
// The LED is turned on if the pulse width is more than high_pulse_usec
// The LED is turned off if the pulse width is less than low_pulse_usec
// The LED state is unchanged if the pulse width is between these

// pin that oscillator output connected to
#define CAP_PIN (2)

// Two thresholds for detecting touch by change in period of oscillator
// The initial values here are not used---the values are automatically
// set when the Arduino is reset.
// The sensor should not be touched until the LED is flashed 3 times,
// to indicate that the automatic sensing is done.
static uint16_t low_pulse_usec=40;
static uint16_t high_pulse_usec=50;

void setup(void)
    pinMode(13, OUTPUT);
    digitalWrite(13, 0);

    // Assuming that the touch sensor is not touched when resetting,
    // find the maximum typical value for untouched sensor,
    // and use this for the lower threshold.
    uint32_t start_time=millis();
    while (millis()-start_time < 300)
    {   uint32_t pulse=pulseIn(CAP_PIN,LOW);
        if (pulse>low_pulse_usec)
	    {    low_pulse_usec =pulse;
    low_pulse_usec += 1;	// add some room for noise

    // Set the high threshold for detecting the pulse at 20% longer low time
    high_pulse_usec = 12*low_pulse_usec/10;

    // flash the LED three times to indicate that the board is ready
    digitalWrite(13, 0);
    digitalWrite(13, 1);
    digitalWrite(13, 0);
    digitalWrite(13, 1);
    digitalWrite(13, 0);
    digitalWrite(13, 1);
    digitalWrite(13, 0);

void loop(void)
    // Measure the pulse width from the hysteresis oscillator
    uint32_t pulse_width= pulseIn(CAP_PIN,LOW);

    if (pulse_width>= high_pulse_usec)
    {   // pulse is long enough to turn LED on
    	digitalWrite(13, 1);
    	// wait, to make sure LED stays on for 1/5 second
    else if (pulse_width<= low_pulse_usec)
    {   // pulse is short enough to turn LED off
    	// wait, to make sure LED stays off for 1/5 second

Most students had no trouble getting this code to turn an LED on and off from their capacitance touch sensor. A few students had trouble with poor wire connections to the Arduino headers. The 24-gauge wire that is provided in the lab is really too fine a gauge—a 22-gauge wire would work better. I think I may want to mention the flexible wire jumpers that I use for connecting off a breadboard (I prefer short solid wires on the breadboard, but flexible wires for off-breadboard connections). There are lots of hobbyist electronics places that sell the jumper wires (for as low as $4.32 for 65 jumpers ordered from China or $5.50 for 75 shipped from California by wosang). They aren’t really needed for the course, so I didn’t include them in the parts kit, but they do make connection to the Arduino a bit easier.

My co-instructor gave a brief tutorial on soldering, which included having students melt solder on scraps of copper-covered PC boards (blanks, not etched) to see the flow when the solder is hot enough.

The students were all showing me their solder joints after soldering up the boards, and most were ok, though I had to send a few back for reheating the cold solder joints. One student who was in a hurry had to reheat his solder joints twice, because they were cold both times, and the oscillator did not work. After the second time, he heated the joints enough and the board worked beautifully. (He was late for his next class, though.) A couple of student had gotten solder blobs into vias that they needed to put components through. In one case, we were able to clear it fairly easily with a solder sucker, but in the other case, the via and attached trace delaminated from the board by the time the hole was cleared. It is probably easier for the student to start over with a new board (I ordered lots of extras of this board), rather than try a complicated repair. Only one student soldered the 14-pin DIP in backwards. While it is possible to unsolder the chip and turn it around, that’s a real pain and it will be faster to start over with a new board and a new chip—the 50¢ board and 30¢ chip are not worth trying to salvage. The 60¢ screw terminal probably is worth removing—not for the part value but for the desoldering practice, since it is pretty easy to remove and reuse.

Overall, the soldering went fairly well for a group of students who had never held a soldering iron in their lives. A few students did not get the soldering finished, but will come in over the weekend (supervised by the undergrad group tutor) or after class on Monday (supervised by me). There will be two more soldering projects later this quarter, after which the students will be as good as most hobbyists at through-hole soldering (I’m not going to try surface-mount soldering with them!)

I’m not sure where best to break this lab in two next year. There are really three distinct parts: determining the hysteresis voltages, designing the relaxation oscillator, and soldering the oscillator (perhaps plotting out the full Vout vs. Vin transfer characteristic). I think it could profitably be broken into three shorter labs, spending a bit more time on characterizing the 74HC14N, then having a day to think about the RC values before coming back to the lab, then having a separate day just doing the soldering.

Overall, I think that the students are beginning to get the idea of the course, and starting to have some fun with the labs. I definitely need more time for the labs next year—I was in the lab from 2 to 7 today, and that is too long a stretch at once. I’m beginning to think that I’ll need to have three days a week of lab and only two of lecture.

2012 October 23

Rethinking the pressure sensor lab

I’ve had several posts now relating to building a shaker table and putting together a pressure sensor lab project for the circuits course:

  1. Pressure sensing lab possibilities
  2. PC board for pressure sensor
  3. Characterizing tactile transducer
  4. Characterizing tactile transducer again
  5. New amplifier and shaker table
  6. Good and bad news for circuit course
  7. Pressure sensor assembly
  8. Pressure sensor miswired
  9. Pressure sensor noise problems

I’m beginning to think that this lab, as I originally envisioned it, is both too much work to set up and too much work for the students. It was also beginning to look like a major spill hazard (much more so than the thermistor lab or the electrode characterization lab).

I want to back off now and see whether there is a lab that fits better into the course and is less trouble both for me and for the students.  Let’s look at the different parts of the lab, and see which are the most important—discarding the parts that are more trouble than they are worth.

  • Building an audio amplifier (op amp plus one discrete transistor) to drive shaker table.
  • Building an instrumentation amplifier with gain in the range 500–2000 to read strain-gauge bridge pressure sensor.
  • Calibrating pressure sensor with a water column.
  • Inducing pressure waves in water with shaker table, and measuring with pressure sensor.
  • Making measurements at two ends of a flexible hose to try to characterize water in hose using the hydraulic analogy.

I like the idea of having students build an audio amplifier.  In fact, we were planning a simple amplifier in an earlier lab, so extending it to drive more current than the op amp chip can source is a good one.  But we don’t need to build a shaker table for that—we can buy cheap 4Ω or 8Ω speakers and have them build amplifiers for the speakers.

I definitely like the idea of having the students learn about strain gauges and build an instrumentation amplifier for them.  The $5 MPX2300DT1 pressure sensor is a good example of a strain-gauge bridge (with temperature compensation).  We could go with the uncompensated MPX53DP for $7.80, the $8 MPXV53GC7U or the $11 temperature compensated MPX2053DP.  I rather like the sturdier “unibody” packaging for the differential pressure sensors (the DP suffix), and we could attach a hose to them directly, since they have barbed ports (which look like they are designed for 3/16″ ID tubing).  I’d still want a breakout board with screw terminals for the sensor, but assembling it would be easier, since the sensor can be soldered as a through-hole component and  screwed to the PC board, eliminating the gluing I needed for the MPX2300DT1.

I’m currently leaning towards a simpler (and cheaper) setup—eliminating the shaker table, the ¾” PVC plug, and the PVC water reservoir, and just having an MPX2053DP (or even MPX53DP) pressure sensor on a breakout board.  This would discard the hydraulic analogy part of the lab, but students would still build an instrumentation amplifier, characterize the pressure with a water column (easily measured as the height of water in clear tubing), and use the pressure sensor to measure breath pressure (inhalation and exhalation).

The maximum pressure of human breath is about 25kPa or 100″ H2O, so the ±50kPa range of the differential sensor should be plenty. The MPX2053 sensor is spec’ed at 800µV/kPa with a 10V power supply, so with a 5V supply it would provide 400µV/kPa.  We probably want a 0–5V output for a -25kPa to +25kPa input, so an amplifier gain of 250 is called for.  That’s a bit less touchy than the gain of 1000 I  used with the MPX2300DT1, but will still be good warmup for the EKG amplifier (which needs higher gain and has to use two stages to avoid saturating from small DC offsets in the first stage).

The uncompensated MPX53DP is spec’ed at 1.2mV/kPa at 3v (2mV/kPa at 5V), so less gain would be needed for the uncompensated part.  If you don’t need temperature correction, then the cheaper part gives you greater sensitivity. I’ll have to think about which would be pedagogically more useful—currently I lean towards the temperature-compensated part, as a concept that they should learn and because it forces them to make a higher gain amplifier.

Building the instrumentation amp and making breath pressure measurements should only take one 3-hour lab period, rather than two, so if I go with this design, I’ll need to come up with another lab.  Perhaps a second audio amplifier lab, with an output transistor and some filtering would be a good lab to insert I have to decide whether that should be a soldering lab or a breadboard lab.  I think that the two instrumentation labs (pressure sensor and EKG) should be done by soldering on a PC board, but I’m not sure the instrumentation amps should be their first soldering projects.

2012 April 20

Make: Kit Reviews | The Ultimate Kit Guide

About a month ago, Make magazine released their reviews of various kits, Make: Kit Reviews | The Ultimate Kit Guide.  I have been a big fan of kits as a way to get kids into the habit of building things and knowing how they are put together.  They provide an intermediate point between ready-made consumer goods and hand-made artisanal goods.

I’ve talked before about my fondness for Heathkit electronics kits when I was growing up (Thanks, Dad!) and about how I was glad to see that they were finally back in the kit business. The kit issue of Make has a number of cool things in it ranging from the $3 Learn-to-Solder badge to $800 model submarines, $1000 mini CNC milling machines, $1300 3D printers, and $863 wood-fired hot tubs.  Although there are few kits in the issue that I really want, it is cool to see just how much is available in kit form these days.  Some are old-school kits (tube amplifiers! crystal radios! Nixie tubes!) and some are very modern (RFID breakout boards, quadracopters, drone planes).

My son has made a number of kits over the years (like the Velleman MK150 shaking dice kit or the K5300 Stroboscope with a xenon tube), and he is now moderately competent with soldering iron, solder sucker, diagonal cutters, and long nose pliers.  I suppose I should get him doing some surface-mount soldering, as my fine-motor control is a little shaky for 1mm × 2mm capacitors and 0.05″ pitch leads on ICs.  (Yes, I’ve seen instructions for making solder reflow ovens out of toaster ovens, and doing soldering with a skillet, but I’m not yet convinced that those are functional enough to be worth the investment in time and fried parts.)

Leads torn on pressure sensor.

The point about SMD soldering comes up this week because the pressure sensor superglued to the inside of the dry box for the underwater vehicle had its leads torn apart. This is probably my fault, since I had suggested the idea of supergluing the pressure sensor to the inside of the dry box without giving any consideration to the forces on the tiny little leads of the pressure sensor.

I had some spare sensor boards, but I had to order more pressure sensors from Digikey and assemble a new board for them.  This weekend, they’ll drill yet another hole in the drybox and glue the replacement pressure sensor in place, but this time there will be a couple of pieces of plastic glued to the PC board (about 4.8mm thick, to match the thickness of the pressure sensor body) also glued to the inside of the dry box, so that unplugging the cables will not put strain on the tiny wires of the pressure gauge.

The new hole will make the 6th penetration of the dry box.  Somewhat amazingly, none of these penetrations have leaked, although we have had problems with the underwater connector that they designed for the motor wires.  We’re hoping that problem will be fixed this weekend.

2012 January 20

Soldering problems

Filed under: Uncategorized — gasstationwithoutpumps @ 20:29
Tags: , ,

In Newton’s measurement of g, I said “In preparation for this, I had bought a “photo interrupter” from Sparkfun and a breakout board to mount it. (Actually, I ordered 2, which was a good thing, since one of them did not work—Sparkfun is sending me a replacement).”

I think I owe Sparkfun a couple of bucks for that replacement, because I now no longer believe that the part was faulty.

The replacement part arrived yesterday, so this morning I unsoldered the part that I believed was faulty and put in the new one.  Getting the holes clear enough to insert the new part was a bit difficult with just a soldering iron and a solder sucker, but I eventually managed to do it.  Since I already had the good photogate set up for the physics lab, I did not get a chance to test the spare until after lab was over.  It didn’t work either!

Now, I’m willing to believe in one random part failing, but two in a row seemed unlikely.  That lead me to suspect problems with either the soldering or with the breakout board.I had already checked thoroughly for shorts (I always do that before powering up a board), and I knew there were none.

I had noticed when taking pictures of the photogate that the IR LED is clearly visible on the camera’s LCD display (strangely, it comes out looking blue, not red), so I looked at the IR diode through the camera—not lit up!  I double checked with the good part and it lit up very visibly.

I then checked the bad board for open circuits.  I quickly found that the resistor, which should be connected on one side to the ground plane was not connected to the ground pin of the header.  I re-examined all the solder joints, and one of the ones on the resistor looked a little bit less than perfect, so I reflowed the solder joints on the resistor.  Still nothing.

In desperation, I tried reflowing the solder joints on the header, although they all looked good.  Success!  It seems that the solder to the ground pad, though looking like a perfect connection, was not connecting. Now the second photogate is working just as well as the first, and I’m feeling very sheepish about having trusted visual inspection of a solder joint—I should know better than to do that.  I certainly should have done a better job of debugging before complaining to SparkFun, who were very nice about replacing the part, no questions asked.

So what can I do?  I feel I owe Sparkfun for the $1.95 part they sent me, but I’m not sure that the effort to get them the money wouldn’t cost them so much in labor costs for handling something unusual that they would lose money on my attempt to pay them.  About all I can do is encourage others to do business with them, since they seem to have real superb customer service.

If anyone does get Sparkfun’s photogate and breakout board, look at the easy Lego mounting I have in More on pendulums, which was easy to set up and worked very well. And check your solder joints carefully!

« Previous PageNext Page »

%d bloggers like this: