Gas station without pumps

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.

constraint
the low pulse width has to be between 20µsec and 1 msec
goal
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(CAP_PIN,INPUT);
    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.
    low_pulse_usec=1;
    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);
    delay(100);
    digitalWrite(13, 1);
    delay(100);
    digitalWrite(13, 0);
    delay(100);
    digitalWrite(13, 1);
    delay(100);
    digitalWrite(13, 0);
    delay(100);
    digitalWrite(13, 1);
    delay(100);
    digitalWrite(13, 0);
    delay(100);
}

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
        delay(200);
    }
    else if (pulse_width<= low_pulse_usec)
    {   // pulse is short enough to turn LED off
    	digitalWrite(13,0);
    	// wait, to make sure LED stays off for 1/5 second
        delay(200);
    }
}

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.

4 Comments »

  1. [...] lab was a “tinkering lab”, using the oscillator board they made in the hysteresis lab as a component to make a light-controlled sound generator.  They did not have a specific goal, [...]

    Pingback by Tinkering lab « Gas station without pumps — 2013 February 14 @ 22:33 | Reply

  2. I accidentally stumble upon your blog. I can easily tell you are a very very dedicated teacher. Just want to say good job!

    Comment by Wang — 2014 February 1 @ 13:57 | Reply

    • I think that this comment may have been commercial spam (based on the link), but it is an unusually apropos link, so I’ll let it stand.

      Comment by gasstationwithoutpumps — 2014 February 1 @ 14:44 | Reply

  3. […] re-reading my notes on last year’s hysteresis lab, I realized that my schedule for this week in the Revised plan for circuits labs, with both the […]

    Pingback by Hysteresis lab too long | Gas station without pumps — 2014 April 15 @ 22:35 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 266 other followers

%d bloggers like this: