Gas station without pumps

2015 May 23

Interesting observation with PteroDAQ

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 19:35
Tags: , , ,

In the lab reports on the optical pulse monitor lab, one pair of students made an interesting observation: the DC offset of the signal they were observing with the PteroDAQ data acquisition system seemed to be periodic with a period of about 46 seconds. In the electronics course, they learn early on about aliasing, because we usually sample our signals at 10Hz, 15Hz, 20Hz, 30Hz, or 60Hz so that the AC noise picked up and amplified can be aliased to DC and result in a DC offset, rather than making a mess of our signals.  There is a large 60Hz interference in the pulse-monitor lab, as students are generally doing transimpedance amplifiers with a total gain of around 100MΩ, so 10nA of stray current at the input results in a 1V output signal.  The aliasing trick gets rid of that 60Hz signal in the output, as long as the amplifier is not clipping as a result of the interference.

They attributed the periodic offset to slight errors in the 20Hz or 30Hz sampling frequency, so that the 60Hz interference was not being completely canceled, but was being aliased to 0.022Hz.  They did not have a very long recording, so I was not sure whether their explanation was correct—it was plausible, but so was random drift, and I wanted more evidence.

So I set up my own amplifier picking up 60Hz line noise in my house, and I did my own recording at 30Hz:

This waveform looks like a time-reversed and slowed down version of the signal I saw on the oscilloscope.

This waveform looks like a time-reversed and slowed down version of the signal I saw on the oscilloscope.

Sure enough, there is clear evidence of aliasing. The period is about 93.7s. That would be an error of having 1 sample too few every 2811 samples, an error of 356 parts per million. That would be a huge error for the crystal-controlled timer on the KL25Z board (the ABM3B crystal on the FRDM KL25Z board has a ±50ppm error or better—the ABM3B F3C marking does not correspond to the part numbers on the ABM3B datasheet, so it is possible that the F3C codes for a tighter spec). I also considered a software error, setting the counts wrong for the interrupt timer. It is unlikely to be an off-by-one error in the programming, though, since the number of counts with the prescaling of the timer should be 8333 (not near 2811), and the separate timer that reports the intervals is not showing any drift in the timing of the interrupts. So I think that the PteroDAQ is doing 30Hz sampling too accurately to explain the aliasing, if the line frequency is really 60Hz.

The beat frequency is about 0.0107Hz, which would correspond to the 60Hz line frequency actually being around 59.9893Hz (a bit too slow, so that we sample slightly earlier in each period, to get the time reversal). Is that in spec for the power grid? According to “Legal and Technical Measurement Requirements for Time and Frequency” by Michael A. Lombardi  [Measure 1(3):60–69  Sept 2006,],

The 60 Hz frequency delivered to consumers is sometimes used as the resonator for low-priced electric clocks and timers that lack quartz oscillators. The legally allowable tolerance for the 60 Hz frequency is only ±0.02 Hz, or 0.033 % [17], but under normal operating conditions the actual tolerance is much tighter.

So being off by 0.01Hz is within spec for the line frequency, but the 46s period that the students saw was out of spec, unless the frequency spec is for a long-term average and not for a window of only a few minutes.

Note that the ±50ppm for the KL25Z crystal is good enough for a lot of purposes (like USB signalling), but is not nearly as tight a tolerance as a digital wristwatch, which is typically ±6 ppm (there is no legal requirement in the US for wristwatch accuracy).  Of course, people who really care about the time use GPS, which has an accuracy of 6 parts per 1014 (in the satellite—the accuracy is considerably less by the time it gets to the receiver).

2015 May 21

Limited Edition Kinetics have arrived!

Filed under: Uncategorized — gasstationwithoutpumps @ 22:55
Tags: , , , , ,

I received my order of Limited Edition Kinetic lights from Futuristic Lights today! I suspect that others who ordered Limited Edition sets will be getting theirs in the mail very soon also (the company started shipping on Tuesday—I got mine fast because I’m in the same county as they shipped from).

Here is what comes in the set: 2 gloves, 10 lights with cases, diffusers, and batteries, a folded instruction card, and a black drawstring bag with the company logo printed subtly on it.

Here is what comes in the set: 2 gloves, 10 lights with cases, diffusers, and batteries, a folded instruction card, and a black drawstring bag with the company logo printed subtly on it.

Note that there are 64 items that need to be assembled for each set: 2 gloves, 10 Kinetic boards, 10 cases, 10 diffusers, 20 batteries, 10 battery tabs, a drawstring bag, and an instruction card.  Even working very efficiently, it is probably going to take them a couple of weeks to get all the preorders shipped.  There’s no way that they could have afforded a standard “fulfillment” service for doing the shipping, as those generally set their prices based in large part on how many items need to be assembled for each order.

Component sourcing, manufacturing, packaging, and shipping have all been much more difficult than they anticipated, and they are shipping at the end of their estimated delivery time (even though they thought that they had allowed lots and lots of extra time—I thought that they would be able to ship in March, which shows how little help I was in anticipating what might go wrong for them). As it is, they are shipping without the boxes they had ordered, because the box printer was taking far longer to print the boxes than they had allowed for (and they hadn’t put a penalty clause in the order for late delivery). I suspect that they won’t be ordering from that box manufacturer again.

The amount that the founders of Futuristic Lights have learned from their first commercial product is amazing (way more than most engineering and business students get in four years of college), and they haven’t lost their enthusiasm for the process—they have already started work on the next 2 or 3 products. For those products, they’ll apply the lessons they learned on the Kinetics—they’ll have more realistic manufacturing lead times and will (probably) be able to reduce the manufacturing costs through better part procurement and different manufacturing partners.

Perhaps even more amazingly, my son has managed to maintain his part in the manufacturing and engineering effort while excelling on a full load of computer science and math courses at UCSB (in Winter quarter he had 24 units, instead of the standard 16, but he decided that the load was too much on top of all the engineering work he was doing for Futuristic Lights and dropped back to a saner load for Spring quarter). So far, most of his courses have been extensions of stuff he has learned partially on his own, and not all-new material. I suspect that courses may be a little more difficult next year as he tackles parts of computer science that he hasn’t already nearly mastered.

For this summer, he’ll be working on new products for Futuristic Lights, except for two weeks of summer Shakespeare with WEST Performing Arts, one week of which will be watching plays at the Oregon Shakespeare Festival in Ashland, the other week of which will be a conservatory with WEST and Santa Cruz Shakespeare.  He’s done both before, and is looking forward to it again this summer.

Pulse monitor lab part 2 and power-amp lecture

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

Wednesday’s lecture covered a reasonable amount.  I went over PWM again, stressing the key concept: that the relevant value is the average value of the output. I showed the derivation of the average value from the high value, low value, and duty cycle.  I introduced nMOS (and, to a lesser extent, pMOS) field-effect transistors, and showed how they worked as switches, which is the only way we’ll use them.  I introduced both nMOS low-side switches and cMOS output stages, and talked about shoot-through current.

I did not get to comparators, open-collector outputs, and how to create PWM signals from a comparator and a triangle-wave generator, which is the meat of tomorrow’s lecture.

I spent over 9 hours in the lab again today, because I’ve promised the students that I’ll be in the lab 5 p.m.–7 p.m Tuesdays and Thursdays for the rest of the quarter, but the students were done with this week’s lab by 6 p.m.  I think all but one or two of the groups got working pulse monitors.  Debugging was difficult today.  The most common problems were

  • Wires in the wrong holes on the breadboards—usually an off-by-one error.
  • Phototransistor connected up backwards. Students kept thinking in terms of “long lead” and “short lead” and somewhat arbitrarily assigned a positive and negative meaning to them, without going back to the datasheet to see which was the collector and which the emitter.  This was difficult for me to debug, because the phototransistors had wires soldered on and were covered with electrical tape, so I could not see the original wire length nor the flat on the package, and had to trust the students’ claims about which wire was which.  In one case the problem was only debugged after I connected my LED and phototransistor (where I knew the color coding I’d used) to the student’s circuit and saw that the circuit was working.
  • Centering the high-pass filter and second stage of the amplifier at 0V, even though we were using a single-sided power supply, so they needed to make a virtual ground.
  • Swapping the wiring of the LED and the phototransistor.
  • Insufficient gain in the second stage.
  • Difficulty getting appropriate amounts of pressure on the finger to get a good pulse fluctuation.

The students having the most trouble had not prepared a schematic to work from or had very sloppy un-color-coded wiring, or both.  I’ll have to remind students that taking a half hour at the beginning to set things up carefully can save hours of debugging—too many want to dive in and wire up stuff without a clear idea what they are going to do, just hoping that it will somehow get fixed by the group tutor or me debugging their work. I refuse to do debugging for a group without a schematic, and in some cases I gave students some properly colored wire and asked them to rewire the circuit so that it could be debugged.

One student was unable to get a pulse reading from his finger on anyone’s circuit (including mine).  I don’t know what the difficulty was—he attributed it to too much caffeine today, so that he could not hold his finger steady in the block.  I suspect that he might have been pressing down too hard and squeezing the blood out of his finger.  One student even managed to get a pulse  reading through fingernail polish (she was wearing a red polish, which apparently was transparent enough to still work).

I had set up my transimpedance amplifier (which has adjustable gain from 66MΩ on up) with an oscilloscope for students to see what a good signal looked like.  There is a lot of 60Hz noise capacitively coupled in, but I was getting a 0.5V pulse signal with only about 200mV of interference.  I probably want to lower the corner frequency for the low-pass filter, to reduce the 60Hz signal further (one group that had miscomputed their corner frequency had very low interference, but their signal was also attenuated too much—I think that a reasonable compromise position can be found).  Even groups with very high 60Hz interference were able to get clean signals by sampling at a multiple of 1/60th of a second (20Hz or 30Hz, for example)—the aliasing eliminates the 60Hz signal, turning it into a DC offset.  The only ones who ran into trouble with 60Hz interference were ones who had the gain set so high that the 60Hz interference caused clipping, obscuring the pulse waveform added to the interference.

I expected this lab to be a little easier for students than it turned out to be, but I think that several students who had been having trouble with some of the concepts (like the virtual ground) were now getting the idea.  I hope so, as most of what they did in this lab will be directly applicable to the EKG lab in the last week of classes.

2015 May 19

Pulse monitor lecture and lab

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

I didn’t get a blog post up for last Friday’s lecture, because I spent the weekend alternately socializing with my in-laws and grading. Monday night was spent grading and working on the next chapter of the book, and most of today (Tuesday) was spent working on the book.

Last Friday was the one day I talked about pulse monitors, photodiodes, phototransistors, and transimpedance amplifiers.  It was a rather packed lecture, but seemed to go all right.

Monday’s lecture started out OK, answering questions about the homework exercises the students were about to turn in, but then fell apart when I tried to cover real power and pulse-width modulation.  Both presentations seemed too vague to me—having neither mathematical rigor nor clear exposition.  The written presentation I wrote for the book is much better than the lecture, which is a bit unusual for me.  I think I need to start getting more sleep, if my presentations have deteriorated to that level.

The prelabs I graded Monday night indicated to me that many students can’t follow a long chain of computations for computing signal levels, even when the chain is broken down into single steps for them.  The problem was estimating how much photocurrent we would get from an LED shining through a finger, starting from the power into the LED, figuring out how much light that would produce, how much would be absorbed by hemoglobin, how much scattered, how much collected by the phototransistor, and how much photocurrent the transistor would produce.  Some students managed to get about 80% of the steps, but a lot got only parts of one step right.

Today’s lab (the first half of the optical pulse monitor lab) took too long, because the students wasted a lot of lab time trying to redo the prelab computations that they had messed up over the weekend, rather than moving on to measuring the photocurrent as I had asked in the lab.  Only a few of the groups got as far as I thought they should have in the first half of the lab: getting their transimpedance amplifiers working and showing a pulse-rate fluctuation. They’ll be set up for adding a high-pass filter and second gain stage on Thursday, and recording pulse waveforms to pass through the digital filter script I provided them.

I spent a long time in the lab today, since I promised the students a 5–7 p.m. lab time for make-up or redone labs. I ended up in the lab from before 10 a.m. to after 7:30 p.m., and I expect to do that every Tuesday and Thursday for the rest of the quarter (2 and a half more weeks). I spent the time when I wasn’t helping students working on revising the class-D power amp chapter of the book, so that I could release the new draft of the book to the class—they’ll have to start work on the design of the class-D amplifier before they have quite finished the pulse monitor, or they won’t have enough time—there is no class next Monday for answering questions.

2015 May 15

Blood pressure lab part 2

Filed under: Circuits course — gasstationwithoutpumps @ 11:36
Tags: , ,

I spent long hours in the lab yesterday (10 a.m.–6:30 p.m.), because students were not as far along as I had thought by the end of Tuesday. I stay in the lab until all the students are finished, even if that is a couple of hours past when the lab should end. A lot of students were still debugging their breadboarded instrumentation-amp circuits 2 hours into the lab session, when I had thought that they would be soldering after at most an hour more breadboarding.

Debugging on both the breadboards and the soldered boards took a lot of time, but the problems were pretty much the standard ones:

  • power not connected
  • wire missing
  • wire to wrong location
  • power supply hooked up backwards to one of the chips
  • bent pin on chip not making contact with breadboard

A couple of groups asked me for debugging help but did not have a drawn schematic to work from.  As I had said earlier in the quarter, I would not help them debug unless they had a schematic to work from.  (I think in both cases the problem was that they had connected up one wire incorrectly, but without a correct schematic to work from, there was no way that they could detect the error.)  Some students have been a bit sloppy about trying to work out of their heads rather than putting things down on paper, and this sloppiness is beginning to be a problem for them.  It has mainly been the weaker students who have been being this sloppy, so perhaps it has been more the case that they have been trying to work out of other people’s heads—copying bits and pieces from other students rather than working things out themselves and then implementing it.

I won’t be helping students debug unless they have shown some effort at making their designs debuggable (like having a clean schematic before they wire things up).

I’m not 100% sure, but I think that all but one group got a soldered instrumentation amplifier working and a blood-pressure measurement run done with it.  The one group that didn’t get that far did have a breadboarded amplifier working.

There were some students missing due to illness, so I’ll probably have to arrange some time next week for make-up lab times.  I’m not sure when that can be.

Next Page »

The Rubric Theme. Blog at


Get every new post delivered to your Inbox.

Join 314 other followers

%d bloggers like this: