Gas station without pumps

2014 April 5

Hysteresis lab on KL25Z

Relaxation oscillator used in the hysteresis lab.  The "variable capacitor" in this schematic is a person's finger and a touch plate made from aluminum foil and packing tape.

Relaxation oscillator used in the hysteresis lab. The “variable capacitor” in this schematic is a person’s finger and a touch plate made from aluminum foil and packing tape.

I spent today writing code for the KL25Z board to act as a period or frequency detector for the hysteresis lab, where they build a relaxation oscillator using a 74HC14N Schmitt trigger inverter and use it to make a capacitance touch sensor (pictures of last year’s setup in Weekend work). I had written code for the Arduino boards last year, and I started by trying to do the same thing on the KL25Z, using the MBED online development system.  The Arduino code used “PulseIn()” to measure pulse duration, and the MBED system does not have an equivalent function.  I could have implemented PulseIn() with a couple of busy waits and a microsecond-resolution timer, but I decided to try using “InterruptIn” to get interrupts on each rising edge instead.

The basic idea of last year’s code (and the first couple versions I wrote today) was to determine the pulse duration or period when the board is reset, finding the maximum over a few hundred cycles, and using that as a set point to create two thresholds for switching an LED on or off. I got the code working, but I was not happy with it as a tool for the students to use.

The biggest problem is that the touch plate couples in 60Hz noise from the user’s finger, so the oscillator output signal is frequency modulated.  This frequency modulation can be large compared with the change in frequency from touching or not touching the plate (depending on how big C1 is), so setting the resistor and capacitor values for the oscillator got rather tricky, and the results were unreliable.

I then changed from reading instantaneous period to measuring frequency by counting edges in a 1/60th-second window.  That way the 60Hz frequency modulation of the oscillator gets averaged out, and we can get a fairly stable frequency reading.  The elimination of the 60Hz noise allows me to use less hysteresis in the on/off decision for the LED, making the touch sensor more sensitive without getting flicker on transitions. The code worked fairly well, but I was not happy with the maximum frequency that it could handle—the touch sensor gets more sensitive if C1 is small, which tends to result in high frequency oscillations. The problem with the code was that MBED’s InterruptIn implementation seems to have a lot of overhead, and the code missed the edge interrupts if they came more often than about every 12µsec.  Because I was interrupting on both rising and falling edges, the effective maximum frequency was about 40kHz, which was much lower than I wanted.

To fix the frequency limitation, I replaced MBED’s InterruptIn with my own interrupt service routine for PortD (I was using pin PTD4 as the interrupt input). With this change, I could go to about 800kHz (1.6e6 interrupts per second), which is plenty for this lab.  If I wanted to go to higher frequencies, I’d look at only rising edges, rather than rising+falling edges, to get another factor of two at the high end.  I didn’t make that change, because doing so would reduce the resolution of the frequency measurement at the low end, and I didn’t think that the tradeoff was worth it here.

The code is now robust to fairly large variations in the oscillator design.  It needs a 20% drop in frequency to turn on the green LED, but the initial frequency can be anywhere in the range 400Hz–800kHz.

To make it easier for students to debug their circuits, I took advantage of having an RGB LED on the board to indicate the state of the program: on reset, the LED is yellow, turning blue once a proper oscillator input has been detected, or red if the oscillator frequency is not in range. When the frequency drops sufficiently, the LED turns from blue to green, turning back to blue when the frequency goes up again.

For even more debugging help, I output the frequency that the board sees through the USB serial connection every 1/60th second, so that a program like the Arduino serial monitor can be used to see how much the frequency is changing.  I took advantage of that feature to make a plot of the frequency as the touch sensor was touched.

Plot of frequency of hysteresis oscillator, as the touch pad is touched three times.  Note that the thresholds are very conservatively set relative to the noise, but that the sensitivity is still much higher than needed to detect the finger touches.

Plot of frequency of hysteresis oscillator, as the touch pad is touched three times. Note that the thresholds are very conservatively set relative to the noise, but that the sensitivity is still much higher than needed to detect the finger touches.

Overall, I think that the code for the KL25Z is better than what I wrote last year for the Arduino—now I have to rewrite the lab handout to match! I actually need to update two lab handouts this weekend, since week 3 will have both the hysteresis lab and the sampling and aliasing lab. Unfortunately, the features needed for those labs (trigger on rising and falling edges and downsampling) are not working in PteroDAQ yet.

Here is the code that I wrote for the frequency detector:

// freq_detector_own_isr
// Kevin Karplus 
// 2014 Apr 5

// This program is intended to be used as a "capacitive touch sensor" 
// with an external relaxation oscillator whose frequency
// varies with the capacitance of a touch.

// The program expects a periodic square wave on pin PTD4 with a frequency between 
// about 400Hz and 800kHz. (LOW_FREQ_LIMIT and HIGH_FREQ_LIMIT).
// On reset, it displays a yellow light, then measures the frequency to store as the "off" frequency.
// If the frequency is out of range (say for a disconnected input), then the light is set to red, 
//     and the off frequency checked again.
// Otherwise the LED is turned blue.
// After initialization, if the program detects a frequency 20% less than the initial freq, 
// it turns the light green, 
// turning it blue again when the the frequency increases to 90% of the original frequency.
// No floating-point is used, just integer arithmetic.
// Frequency measurements are made by counting the number of rising and falling edges
// in one cycle of the mains frequency (1/60 sec), giving somewhat poor resolution at lower 
// frequencies.  
// The counting time is chosen to that frequency modulation by the mains voltages is averaged out.
// This version of the code uses my own setup for the interrupt service routine, because InterruptIn has
// too much overhead.  I can go to over 800kHz (1.6e6 interrupts/second) with this setup, 
// but only about 40kHz (80e3) interrupts/sec with mbed's InterruptIn.

#include "mbed.h"

#define PCR_PORT_TO_USE (PORTD->PCR[4])   // pin PTD3 is the pin to use

#define MAINS_FREQ (60)     // frequency of electrical mains in Hz
#define COUNTING_TIME (1000000/MAINS_FREQ)   // duration in usec of one period of electrical mains

// off_frequency must be between LOW_FREQ_LIMIT and HIGH_FREQ_LIMIT for program to accept it
#define LOW_FREQ_LIMIT (400)
#define HIGH_FREQ_LIMIT (800000)

// on-board RGB LED
PwmOut rled(LED_RED);
PwmOut gled(LED_GREEN);
PwmOut bled(LED_BLUE);
#define PWM_PERIOD (255)  // for the on-board LEDs in microseconds

// Set the RGB led color to R,G,B  with 0 being off and PWM_PERIOD being full-on
void set_RGB_color(uint8_t R, uint8_t G, uint8_t B)

// InterruptIn square_in(PTD4);
volatile uint32_t edges_counted;

uint32_t low_freq_threshold, high_freq_threshold;  // thresholds for detecting frequency changes

extern "C"{
// interrupt routine that counts edges into edges_counted
    void PORTD_IRQHandler(void) 

// return the frequency for the square_in input in Hz
uint32_t frequency(void)
    PCR_PORT_TO_USE &= ~PORT_PCR_IRQC_MASK;  // disable interrupts on pin PTD3
    PCR_PORT_TO_USE |= PORT_PCR_ISF_MASK | PORT_PCR_IRQC(11);  // clear interrupt for PTD3, and enable interrupt on either edge
    PCR_PORT_TO_USE &= ~PORT_PCR_IRQC_MASK;  // disable interrupts on pin PTD3
    uint32_t freq=edges_counted*MAINS_FREQ/2; 
    return freq; 

int main() 
    set_RGB_color(255,255,0);   // set light to yellow
    SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK; // make sure port D has clocks on
    PCR_PORT_TO_USE &= ~PORT_PCR_MUX_MASK;  // clearing the MUX field
    PCR_PORT_TO_USE |= PORT_PCR_MUX(1);     // Setting pin as GPIO
    FPTD->PDDR &= ~ (1<<4);  // make sure pin is input pin
    NVIC_EnableIRQ(PORTD_IRQn);            // enable interrupts for port D

    uint32_t off_frequency= frequency();
    while ( off_frequency<low_freq_limit ||="" off_frequency="">HIGH_FREQ_LIMIT)
    {   // timed out.  set color to red and keep trying
        printf("FREQ out of range: %luHz\n", off_frequency);
        off_frequency= frequency();
    uint32_t low_freq= 8*off_frequency/10;  // 80% of off_frequency
    uint32_t high_freq= 9*off_frequency/10;  // 90% of off_frequency
    printf("off= %luHz lo_thresh=%luHz hi_thresh=%luHz\n",off_frequency, low_freq, high_freq);
    {   uint32_t freq=frequency();
        printf("%lu Hz\n",freq);  
        if (freq < low_freq)
        {   // low_fequency found, turn LED green
        else if (freq >= high_freq)
        {   // high frequency found, turn LED blue again

2014 April 4

Third day of circuits class was low key

Filed under: Circuits course,Printed Circuit Boards — gasstationwithoutpumps @ 21:34
Tags: , , ,

Today’s class was not content-rich, but a low-key decompression after yesterday’s too-long lab.

I started out taking some questions from the class, which were mainly about what to do in the design report.

I then discussed my ideas about what had gone wrong with yesterday’s lab that made it take so long, and both how I planned to fix the problem next year, and what we could do as a class to keep it from happening again this year. I particularly stressed the importance of doing the pre-lab work early, so that they could ask questions in the lecture portion of the class, rather than taking up valuable lab time. I also suggested that they do the writeups for the Tuesday lab before Wednesday’s class, so that they would have much less to write up after the Thursday lab—making the Friday deadline for the writeup feasible.

I asked the students for their ideas about what were problems with the lab, and they agreed that the soldering and installing PteroDAQ software took up almost 2 hours, so it would be best to separate that into its own lab period. They also brought up their frustration with the design problems I had given them: not so much the optimization for the lab, but the design exercise I had added: Design a circuit to convert a 1kΩ–3.3kΩ variable resistance sensor to a 1v–2v voltage output, with 1v for the 1kΩ resistance and 2v for the 3.3kΩ resistance. Use standard resistor values that you have in your kit. They were frustrated because they did not know how they were supposed to approach the problem.

This gave me an opportunity to explain what I was trying to do with problems like that. It was indeed entirely appropriate that they should have been uncomfortable with the problem, because I was trying to push them to think in new ways—to handle problems that were not completely laid out for them ahead of time, but where they had to struggle a bit to figure out how to formulate the problem. This is precisely what engineers have to do—to take problem statements that may be unclear or not precisely solvable, figure out how to formulate them more precisely, set up equations, solve them, check that the design they come up with makes sense, and (often) adjust the problem statement to reflect what is actually doable.  (I didn’t say it, but in this case you have to accept a few percent error in the output voltage or the resistances in order to use standard values.)  I promised them more uncomfortable problems in future, in an attempt to stretch them.  They seemed a little more at ease with the difficulty they’d been having, once they realized that this was expected—I think some had been afraid that they were in over their heads and were panicking.

Another student mentioned having heard of an analogy between programming and engineering. I pointed out that programming was a form of engineering, and that all engineering required identifying problems, breaking them into subproblems, and solving the subproblems.  Programming tends to involve many, many subproblems, with formal interfaces between them, but even the simple hardware we’d do in this course involves breaking problems into subproblems, using block diagrams (which I promised to talk more about later in the course).

Somewhere in the discussion of what engineers do, I brought up the example of the student who had presorted his resistors and taped them into a booklet.  What the student had done was to identify a problem (that it would be hard to find the resistors he needed), come up with a solution, and implemented it. I pointed out that the technology he used (scotch tape) was available to them all, as was the notion of sorting. The engineering thinking comes in looking at something unpleasant (finding a sheet of resistors in a pile of 64 different sizes) as a design problem to solve, rather than something to get irked about or try to avoid. I’m hoping to get them thinking more like engineers during the course of the quarter—anticipating problems and looking for ways to solve them.

Generic voltage divider circuit.

Generic voltage divider circuit.


I took more questions from the class—there were a few about voltage dividers, which I explained again in a different way, using analogies to similar triangles and giving them the voltage divider formula in the form I = \frac{V_{out}}{R_{1}} = \frac{V_{in}}{R_{1}+R_{2}}.  I did not give the voltage divider in the “ground-reference” format shown to the left, but drew lines out horizontally from the nodes, and had the voltages indicated as distances between the lines (like in a mechanical drawing), to give them a more visual representation of voltages as differences.  I also had them figure out what the voltage across R2 would be and how it would relate to the other voltages.

The more different ways they work with voltage dividers, the better they will internalize the concepts and be able to use them in designs.

The circuit I had given as an exercise, asking them to determine the output voltage V_out.

The circuit I had given as an exercise, asking them to determine the output voltage V_out.

The circuit with explicit sources and voltmeter implied by the circuit I had given them.

The circuit with explicit sources and voltmeter implied by the circuit I had given them.

A question also came up about what it meant to have 2 input voltages with no ground shown in a circuit (as I had given them as an exercise in the first lab handout).  That is an excellent question—one that uncovered an assumption I had been making that I had never explained to them! I explained that what an “input voltage” meant was shorthand way of drawing two voltage sources.

I’ll have to fix the handout next year to include this explicit explanation of a common shorthand—I’ve used it for so many decades that it simply hadn’t occurred to me that it wasn’t obvious. I apologized to the class for having skipped the explanation, and pointed out the importance of them asking questions, because otherwise I would never know where some omission like this was confusing them unnecessarily.

When they ran out of questions, I got in some new material, explaining the difference between “precision”, “repeatability”, and “accuracy”. The digital thermometers they used in lab were a good example—they had a precision of 0.1°C, were repeatable within a single thermometer to about ±0.2°C, but between thermometers were repeatable only to about ±2°C. The accuracy is unknown, since we did not have anything traceable to a temperature standard, but the ice water baths should have been close to 0°C, so the thermometers we used on Thursday were probably less than 1°C off, but the larger set we used on Tuesday included some that were 3°C or 4°C off. In the repeatability part of the talk, I managed to bring in the biologists’ notion of technical replicates (different measurements of the same sample) and biological replicates (different cultures or tissue samples), and why biological replicates show less repeatability.

I also used this as a chance to talk about the uselessness of ±0.1°C or error bars without an explanation of what the range means (standard deviation, 90% confidence interval, 3σ, 5σ, observed range, …), and the even greater uselessness of “significant figures” as a way of expressing uncertainty.  I told them that I’d rather see 1.031±0.2 than 1.0 as a way of expressing the uncertainty in a measurement.

Towards the end of the 70-minute period, I got in a little discussion of AC voltages as time-varying voltages, and that we usually did analysis in terms of simple sinusoids, rather than the complex waveforms that we’d actually be measuring. I did assure them that, though there was a lot of mathematical machinery (Fourier analysis) that justified this way of doing things, the math was outside the scope of the class and I’d only be giving them intuitive ways of working with AC. I only got as far as giving them amplitude—telling them that I’d start with RMS voltage next time. (I’d originally hoped to explain RMS voltage today, but that would have taken another five minutes, and we were already 3 minutes over.)

Overall, I was fairly pleased with how today’s class went—the students are getting more comfortable asking questions and I’m getting a better sense of what they already know and what they need explained.  Undoubtedly I’ll make more mistakes like not explaining the “hidden voltage source at inputs” convention, but I think we’ll recover from such mistakes a little quicker each time, as the students get more confident in asking for clarification.

2014 March 31

First day of S14 circuits class went ok

Filed under: Circuits course — gasstationwithoutpumps @ 21:21
Tags: , , , , , ,

I went into the class with a long to-do list, and managed to cover the following:

  1. Issued permission codes for students with missing prereqs to register but I forgot that they’d need permission codes for BME 101L as well—I’ll give those out as soon as I get them. The class is up to 9 students, which is still much less than the 20–40 I had projected. I’m going to have to use the same parts next year, so that the over purchase doesn’t cause budget problems.
  2. Went over syllabus .I showed them the syllabus and managed to go over scheduling of labs, partner work, and online texts, but did not get to some of the boilerplate about cheating and about disability services.  Oh well, it is enough that the boilerplate is on the syllabus.
  3. Demoed pressure sensor and EKG with PteroDAQ on KL25Z board. I explained that I chose these labs to demo, since they were soldered onto protoboards, and so sturdier than ones built on breadboards. Amazingly, the alpha prototype of PteroDAQ worked fine for the demo. I was even able to illustrate a debugging technique. The EKG seemed to be missing a lot of my heartbeats, so I saved the data to a file, looked at it with gnuplot, and zoomed in, where it became obvious that the problem was that the R pulses on the EKG were shorter than the time between samples. I went back to the PteroDAQ control panel, increased the sampling rate from 20Hz to 120Hz, and took another 30 seconds of samples.  Saving that and viewing it with gnuplot made it clear that the EKG amplifier was working fine, and the PQRST parts of the EKG signal were all quite clear.
  4. Ohm’s Law V=IR:  The students volunteered this when I asked them the relationship between voltage and current.  Good!
  5. Kirchhoff’s Current Law:  Again many had heard of the concept that if charge is not accumulating (steady-state), then the current into a node is the same as the current out of the node. In general, that the sum of all currents into a node is 0.
  6. Explained about voltage being a difference between two nodes or across a component, and contrasted that with the current through a component. I implicitly used Kirchhoff’s Voltage Law by introducing the notion of voltage at a node, as the voltage between that node and an arbitrarily chosen node that we call “ground”.
  7. I showed them a voltage divider and had them derive the voltage across each resistor (from having the same current), then from there deriving the voltage across the resistors in series (thus deriving the idea that series resistors add). We then solved for I in the Vin equation and plugged it into the equation for Vout, getting the standard voltage-divider formula V_{out} = V_{in} \frac{R_{down}}{R_{up}+R_{down}}.
  8. I introduced the notion of an NTC thermistor (and listed other temperature sensors: PTC thermistor, RTD, thermocouple, bandgap temperature sensor, giving a brief idea when each would be used). I did not plot the resistance as a function of temperature based on the model , but that would be a good thing to do in the gnuplot lesson on Wednesday.
  9. I did explain the notion of sensitivity of a sensor: the derivative of the output with respect to the input, and went over (in a general way, with helpful suggestions from the students) how one would go about maximizing sensitivity of a voltage divider with a thermistor and fixed resistor at a particular operating temperature.  I’ll see in lab tomorrow or during the analysis session on Wednesday whether students got the idea or not.

It was a very content-full class, but I did manage to get in a number of side remarks:

  • reading the lab handouts well before lab, since they weren’t fill-in-the-blanks worksheets, but sometimes had design assignments buried in them.
  • partners changing every week, so no one gets a free ride for very long and no one has to suffer with a freeloader.
  • no failures on lab reports—just REDO, until the end of the quarter, when all un-redone work turns to F.
  • need for perfect schematics. Sloppy schematics will trigger an automatic REDO.
  • one of the students asked about the circuits-class t-shirt I was wearing, and I explained that I’d created the shirt for last year’s class and that if students were interested we could do another order this year.

Overall, I’m fairly happy with how the first day of class went.

I’m less happy with the rest of the day, though. In the morning my son accompanied me to the lab to help me set up the Windows drivers and to test PteroDAQ on the Windows machines, but the lab staff had changed the system they used for authenticating administrators, so I couldn’t install the drivers. I knocked on their door (no answer) and sent them e-mail through the request system, but it took them about 3 hours to answer (by which time my son had gone home and I was teaching class). After they had reauthorized me, I spent 2 hours installing Windows drivers on the 12 machines in the lab, so that they could talk with the KL25Z boards.  (Windows is a major pain—I really hate having to deal with it.)  I finally got a chance to test PteroDAQ on the Windows machine, and it didn’t work—I tried installing Python3.4 on one of the machines and that changed the nature of the error, but did not fix it. [Did I mention that the students have to be able to use it on Thursday?]

My son will go in with me again tomorrow (he’s on Spring break) and try to get the PteroDAQ function at least to the level that it is at on the Mac, which is minimally functional under Python3, but with a mysterious failure to open the USB serial port under Python2.7.

I also found out that the missing parts that the lab staff forgot to order have just been shipped from Hong Kong, and should be here next week.  Unfortunately, that includes the USB cables that the students will need to connect up the KL25Z boards. [Did I mention that the students have to be able to use it on Thursday?]

Also, the TA union is probably going on strike system-wide Wednesday and Thursday. I don’t have a TA, but there will probably be pickets at the base of campus and city buses won’t cross the picket lines, so there will probably be some students who can’t make it to class or lab. (I never penalize students for honoring picket lines, but it is going to be very difficult to get back on schedule if we fall behind.

On the subject of possibly falling behind—the campus facilities people are promising some long power outages mid-week one or more times during the quarter—they find it better to make everyone else stop working rather than work on weekends themselves, I guess.

I did get the cups and coffee urn for the water baths needed in this weeks lab transported to the lab, but I found out that the staff had not ordered any 22 gauge hookup wire—there was only a small amount of red and black 24 gauge wire in the lab. The soldering irons weren’t in the lab either, but I need them for tomorrow’s lab. With the small class, I can probably get away with only 5 soldering stations, but I don’t even have a working one I can bring in from home.

One of the students in classed asked about the jumper wires I was using to connect to the KL25Z board.  I was using 9″ long female-female jumper cables with double-male pins (something like these from Adafruit though I probably bought them elsewhere).  I have a very cheap set of male-male jumpers, but I rarely use them, because they are incredibly high resistance (on the order of ohms instead of milliohms).  Adafruit has some high-quality male-male jumpers, which may be easier to work with than the female-female ones that I’ve been using. Sparkfun has a mixed pack (half M/M and half F/F), but a set of 100 is is $25.

The students are supposed to have double-male header pins in their kits anyway, since the pins are very handy for making oscilloscope probe points on a breadboard.




New modeling lab for electret microphone

Last year, in Mic modeling lab rethought, I designed the DC measurement of an electret microphone around the capabilities of the Arduino analog-to-digital converters:

Circuit for measuring DC characteristics of an electret microphone.  The four labeled nodes are connected to the Arduino.

Circuit for measuring DC characteristics of an electret microphone. The four labeled nodes are connected to the Arduino.

  • The highest voltage allowed is 5v and the lowest is 0v.
  • The resolution is only 10 bits (1024 steps).
  • The steps seem to be more uniformly spaced at the low end of the range than the high end (so differences at the high end are less accurate than differences at the low end).
  • The external reference voltage AREF must be at least 0.5v (this is not in the data sheet, but when I tried lower AREF voltages, the reading was always 1023).

Test fixture for measuring I-vs-V DC characteristics of electret microphone.

Test fixture for measuring I-vs-V DC characteristics of electret microphone.

This year we’ll be using the KL25Z boards, which have different constraints:

  • The highest voltage is 3.3v and the lowest is 0v.
  • The resolution is 16 bits (15 bits in differential mode).
  • Differential mode only works if you stay away from the power rails—clipping occurs if you get too close.
  • The external reference must be at least 1.13v.  With less than a 3-fold range for the external reference, varying the external reference to get different ranges seems rather limited.

I think I’ll still have the students start with using the multimeter and the bench power supply to measure voltage and current pairs for 1V to 10v in steps of 1v.  But then I’ll have them wire up a different test fixture. The resistor R2 is one that students will have to choose to get an appropriate measuring range. Resistors R3 and R4 keep the voltages for the differential measurements E20–E21 and E22–E23 away from the power rails. I tried using smaller values, but 200Ω was not enough—I still got clipping problems. So 63mV is too close to the rails, but 275mV seems fine.  I suspect that the limit is around 100mV to 150mV, but I did not try to narrow it down.

I found that the differential measurements had less noise than single-ended measurements, despite having a resolution of about 100µV rather than the 50µV of single-ended measurements. Doing 32× hardware averaging also helped keep the noise down. (Note: the data sheet for the KL25 chip does claim a higher effective number of bits for differential measurement than for single-ended measurement, perhaps because of reduction in common-mode noise.)

I was able to get fairly clean measurements with just two different resistor sizes, to which I fit 4 different models:

  • linear resistance: I = V /R
  • constant current I = I_{sat}
  • blended: I = V/ \sqrt{ R^2 + (V/I_{sat})^2)}
  • blended with exponent: I = V/ \sqrt{ R^2 + (V^p/I_{sat})^2)}


    The blended fit with the extra exponent on voltage does a pretty good job of fitting over the full range (it looks good on a log-log scale also)

The blended fit with the extra exponent on voltage does a pretty good job of fitting over the full range (it looks good on a log-log scale also)

Because of the large characters used for the data points, the lines look fat, but the noise level is fairly small—about ±300µV Some of that may be due to the movement of the potentiometer, as the voltage and current aren’t measured at precisely the same time, but I suspect most is electrical noise in the processor itself.

2014 March 17

Revised plan for circuits labs

Filed under: Circuits course — gasstationwithoutpumps @ 14:39
Tags: , , , ,

In Plan for rearranged circuits labs I provided a tentative schedule for the applied circuits course and lab,  which starts on 2014 March 31.But after my experimenting with optical pulse detection this weekend, I need to rearrange the labs to move the phototransistor lab later and allow more time for it.  This post is my attempt to do that rearrangement.

Monday 2014 Mar 31 Administrivia: structure of course, rotating partners, labs not cookbook—need to read carefully before coming to lab. Pre-lab homework. Demo pressure sensor or EKG?
Ohms law, voltage dividers.
Homework: install gnuplot on own computers, read Wikipedia on thermistors and the Steinhart-Hart equation, draw voltage divider with schematic capture tool (probably Digi-key’s SchemeIt)
Tuesday 2014 Apr 1 Unpacking parts, labeling capacitor bags, using wire strippers, making clip leads, measuring input resistance of multimeter, measuring thermistor resistance at many temperatures.
Wednesday 2014 Apr 2 Do-now resistance-to-voltage converter. Gnuplot: fitting thermistor theory to measured data. Derivatives of voltage w.r.t. temperature to maximize sensitivity (and linearize output). Homework: install data logger on own computer and KL25Z, record accelerometer?
Thursday 2014 Apr 3 Soldering headers onto KL25Z boards, downloading data logger to KL25Z, if not already done. Measuring voltage of thermistor voltage divider, recording voltage vs. time.
See soldering instructions at Soldering headers on a Freedom board and Jameco soldering tips
Friday 2014 Apr 4 Voltage-divider do-now exercise. Other temperature measuring devices (RTDs, thermocouples, silicon bandgap temp sensors).
Monday 2014 Apr 7 Three-resistor do-now question. Feedback on design reports, i-vs-v plots, how electret mic works.  AC voltage (sine wave: amplitude, peak-to-peak, RMS voltage). DC blocking capacitors, RC filters (without complex impedance).
Tuesday 2014 Apr 8 Measure I-vs-V DC characteristic of resistor and of electret mic, both with multimeter and with KL25Z board.
Wednesday 2014 Apr 9 Gnuplot: plotting transformed data, fitting various models to i-vs-v (resistor, current source, blending of resistor and current source, more complex model).
Thursday 2014 Apr 10 Look at mic with resistor load on oscilloscope (AC & DC coupling).  Capacitor for own AC coupling. Loudspeaker on function generator?
Friday 2014 Apr 11 Another 3-resistor do-now question. Voltage sources, current sources, load lines, Thévenin and Norton equivalents.
Monday 2014 April 14 Hysteresis. Applications: cleaning up noisy signals to on/off signals, feedback control. Differential equation for capacitor, derived from Q=CV, RC time constant. Basic idea of hysteresis oscillator (demo of touch tensor?)
Tuesday 2014 Apr 15 Characterize hysteresis in Schmitt trigger chip using data logger. Breadboard hysteresis oscillator with various R and C values, measuring frequency or period (oscilloscope or frequency meter?).
Make and test touch sensor with breadboard oscillator. Solder hysteresis oscillator. Estimate capacitance of touch from change in period of hysteresis oscillator.
Note:I’ll have to write touch sensor code for KL25Z.
Wednesday 2014 Apr 16 Theory of sampling and aliasing
Thursday 2014 Apr 17 Sampling and aliasing lab. Awkward that this gets split from sampling and aliasing theory, but I want to analyze loudspeaker data this week.
Friday 2014 Apr 18 High-pass and low-pass RC filters as voltage dividers. Gnuplot plots and Bode plots for amplitude. Make sure they see ω=0 and ω=∞ simplifications, and straight-line approximations (f, 1/f, constant) away from corner frequency.  Introduce dB and dB/decade rolloff.
Monday 2014 Apr 21 RC filter/voltage divider quiz/midterm
Tuesday 2014 Apr 22 Impedance of stainless steel (polarizing) electrodes in different NaCl concentrations (at several frequencies).
Wednesday 2014 Apr 23 Gnuplot: Functions for impedance: Z_C, Z_L, Z_parallel. Fitting R1+(R2‖C) models to data, maybe fitting other models?
Polarizing and nonpolarizing electrodes.
Properties of stainless steel (corrosion resistance in oxidizing environments, biocompatibility, poor choice for electrodes)
Thursday 2014 Apr 24 Impedance of Ag/AgCl (non-polarizing) electrodes in different NaCl concentrations (at several frequencies)
Friday 2014 Apr 25 Intro to op amps, unity gain buffer, transimpedance amplifier.
Monday 2014 Apr 28 Inverting and non-inverting amplifier.
Tuesday 2014 Apr 29 Characterizing impedance of loudspeaker vs. frequency
Wednesday 2014 Apr 30 Gnuplot: fitting models for loudspeaker impedance.
Thursday 2014 May 1 Measuring nFET current with constant VDS and varying VGS, also with constant VGS and varying VDS. (pFET also?)
Friday 2014 May 2 Gnuplot: fitting nMOS transistor models to measured data. nFET and pFET as switches.
Monday 2014 May 5 System thinking and block diagrams: developing for audio amplifier
Tuesday 2014 May 6 Low-power single-stage audio amplifier with op amp
Wednesday 2014 May 7 Op-amp quiz/midterm
Thursday 2014 May 8 catchup day? characterizing pFET? characterizing LED?
Friday 2014 May 9 Op amps with RC voltage dividers (active filters)
Monday 2014 May 12 Do now: transimpedance amplifier.  Models for photodiodes and phototransistors.  (other photosensors?)
Tuesday 2014 May 13 Photodiode and phototransistor with single-stage simple transimpedance amplifier.
Freeform soldering to attach leads for fingertip transmission sensor. I need to drill a dozen blocks of wood for the fingertip alignment blocks.
Cut-and-try design for transimpedance gain needed to see reasonable signal without saturating amplifier. (Determine AC and DC components of current)
Wednesday 2014 May 14 Gnuplot: model gain of 1-stage and 2-stage amplifiers with RC filters.  Develop block diagram for 2-stage pulse detector with approximately 0.3Hz–30Hz bandpass.
Thursday 2014 May 15 Fingertip pulse sensor with 2-stage amplifier and bandpass filtering.
Friday 2014 May 16 class D amplifier  concept.
Monday 2014 May19 Developing class D block diagram
Tuesday 2014 May 20 class D audio amplifier day 1(preamp and comparators)
Wednesday 2014 May 21 Gnuplot: analyzing loudspeaker load, adding LC filter in front of loudspeaker to make sharp cutoff without ringing.
Thursday 2014 May 22 class D audio amplifier day 2 (output stage)
Friday 2014 May 23 Do-now: Wheatstone bridge. Strain gauges and Wheatstone bridges. Instrumentation amps.
Homework: block diagram and design for pressure sensor.
Monday 2014 May 26 Memorial Day, no class
Tuesday 2014 May 27 Pressure sensor day 1: design and soldering instrumentation amp prototype board
Wednesday 2014 May 28 catch up day?
Thursday 2014 May 29 Pressure sensor day 2: further debugging.
Recording pressure pulses from aquarium air pump?  Would need to buy some more air pumps.
Friday 2014 May 30 Action potentials in nerve and muscle cells?
Monday 2014 Jun 2 Why EKG signals differ based on placement of electrodes.  (Vector model)
Tuesday 2014 Jun 3 EKG day 1:  breadboard and debugging (confident students could go directly to soldering)
Wednesday 2014 Jun 4 Catch up?
Thursday 2014 Jun 5 EKG day 2: soldering, debugging, and demo.  Last day for any catchup labs.
Friday 2014 Jun 6 Catch up?
Monday 2014 Jun 9 4–7 p.m. Final exam? (probably not needed, except as a lab catch-up day)

I’m not 100% satisfied with this schedule, and things will probably slip as I discover unexpected difficulties in student preparation, but I think it is likely to run more smoothly than last year, and last year was not bad.

If any of my readers have suggestions on improvements that could be made in the labs or the order of topics, please let me know. I have to buckle down and (re)write the lab handouts soon!

« Previous PageNext Page »

%d bloggers like this: