Gas station without pumps

2015 April 1

Second lecture in Spring 2015 electronics

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

The lecture today started by me redoing the demo that failed on Monday, showing them how to run PteroDAQ and display the results with gnuplot.  Everything worked fine this time. I even showed them the use of two channels, by putting the Bandgap voltage reference (1v) on the second channel, and plotting its variation over time:

The ADC was measuring consistently slightly low (probably because the power supply voltage had drifted a little) from when PteroDAQ measured the bandgap reference to set the calibration).

The ADC was measuring consistently slightly low (probably because the power supply voltage had drifted a little) from when PteroDAQ measured the bandgap reference to set the calibration).

I showed them how to plot the signal divided by the bandgap signal to correct for such calibration problems.  The plot also gave a good segue to talking about resolution, precision (which I equated with repeatability), and accuracy, because the step size of about 50µV for the ADC is clearly visible (3.3V/216), but the signal is not repeatable to 50µV.  The precision is limited to about ±200µV and the inaccuracy can be as much as 700µV.

I then walked them through a gnuplot script for demonstrating sampling:

# frequencies in Hz
sine_freq = 1.100 *1.0
sample_freq= 40. *1.0

sampled(t) = sine_wave( floor(t*sample_freq+0.5)/sample_freq )

set title sprintf("Sine wave of %.2fHz, sampled at %.2fHz", sine_freq, sample_freq)
set xlabel "time [seconds]"
set ylabel "signal"

set samples 5000
set yrange[-1.05:1.05]
set xrange [0:2]
plot sampled(x) notitle, sine_wave(x) lt 3 notitle

which produces a simple example of discrete-time sampling:

Sampling a 1.1Hz signal at 40Hz does a good job of representing the waveform.

Sampling a 1.1Hz signal at 40Hz does a good job of representing the waveform.

I even explained why I used “lt 3” for making a red/blue color distinction rather than a red/green one (around 5–7% of males have some form of red-green color blindness).

I then showed them the effect of changing the sampling rate (by alternating “sample_freq=…” and “replot” commands). I think that this will help them with tomorrow’s lab, in which they use the function generators in the lab to generate sine waves, and look at them with PteroDAQ software on the KL25Z boards.

Speaking of PteroDAQ, one of the students in the class and I figured out what was going wrong on the Mac OS 10.10.1 installations of PteroDAQ. It turns out that the problem was not specific to the OS 10.10.1, or even to Macs, as we observed the same problem of not being able to select a port (because the GUI automatically deselected it) even on a Windows 7 box.  It turned out to be a problem in Python 3.4.3 (the latest release on not playing nicely with Tkinter.  Rolling back to Python 3.4.0 fixed the problem (with either Tcl/Tk 8.5 or 8.6).  We’ve not yet looked to see whether 3.4.1 or 3.4.2 work correctly.

The rollback to Python 3.4.0 worked on both Mac OS 10.10.1 and on Windows 7.  The only machines we haven’t yet gotten a demonstrably working PteroDAQ installation are Windows 8 machines—the problem there seems to be installing drivers for the USB port.  The Arduino community has encountered the same problem (Windows 8 insisting on digitally signed drivers) and the community figured out how to turn off that insistence. The instructions there (,94651.msg727588.html#msg727588) are rather scary.  A more tutorial presentation is given by SparkFun at


2015 March 31

First lab for Spring

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

I had a very long day today (as I expect all Tuesdays and Thursdays to be this quarter).  It started out with me in a panic, because I had gotten a message late yesterday afternoon, telling me that the parts kits for the course were not ready yet, but not telling me what was available, so I didn’t know whether I’d be able to run today’s lab or not. I thought I probably would be able to do the essential parts, because the main part of the lab was soldering headers onto the KL25Z boards, and the boards and headers were ordered from Digi-key, which has very fast delivery (thanks to their almost instant packing of parts for shipping and their using the post office rather than FedEx, which has been unbelievably slow this year).

I went into work a bit early this morning to check on what parts were available (after a night of thinking about what labs I could do if the KL25Z boards were not available—pretty much only the thermistor lab scheduled for next Tuesday, and that takes about an hour of setup to prepare the lab and have hot water and ice water available).  As it turns out, the person who had informed me of the incomplete parts list had sent out a spread sheet with the information—he’d just forgotten to CC me on it. The KL25Z boards, the headers, and the USB cables were all available, so we could do the main part of the lab.  We couldn’t do the unpacking of the parts kit and identifying parts, but that can happen later, as the parts come in.

For Thursday’s lab, it would be good if they had their breadboards, resistor kits, and electrolytic capacitors—but I don’t know whether those will all be ready by then (the resistor kits haven’t all arrived yet).

Once the boards arrived, I started part of the class soldering (we only had 6 soldering stations, two of which were not very functional, despite my request 2 years ago for enough soldering irons for the 12 benches).  While some were soldering, the rest were downloading the PteroDAQ software and trying to get it to work on their machines.

The soldering went well, with one serious exception.  One student soldered in the connectors on the wrong side of the board, and neither the group tutor nor I noticed in time (and we could have, because we had looked at the board and just not noticed). We helped remove the connectors (removing a 2×10 female header from a board is a lot of work), but the student did not have enough time to get all the connectors replaced by the end of lab.  The tutor will provide some supervision at another time before Thursday’s lab to finish up.  All the solder joints looked clean—I saw neither bridges nor voids.  I did send several students back (more than once) to reheat cold-solder joints, but in the end all the students had good connections.  Since only 2 or 3 of the 32 students had ever held a soldering iron before, I think that getting each to make 64 good solder connections is a pretty positive outcome.  They’ll have 3 more labs this quarter where they will have to solder (their own designs, not just headers), but I think that they’ll approach those labs with more confidence now.

The PteroDAQ downloads were not quite as successful.  I think that everyone managed to get the MBED.ORG download software installed, and transferred the daq_kl25z.bin executables to the KL25Z boards. Most (all?) got PteroDAQ working with the lab computers. But few, it any got PteroDAQ working on their own machines.  There were three classes of problems:

  • On Windows 7 machines, I forgot how to use the mbed-usb-windows.inf files to install Windows drivers for the USB port on the KL25Z board. I looked it up after class before going home and found a page about installing Windows drivers for Arduino boards that seems to have all the right instructions (but use the .inf file in the PteroDAQ extras directory, not arduino.inf):
  • On Windows 8 machines, I don’t know whether the same approach will work, but I hope that some of the students will try. The approach given in the MBED handbook did not seem to work, but I’m not very comfortable with Windows, so I may have missed something obvious to a serious Windows user.
  • On Mac OX 10 machines, we had two problems:
    1. OS 10.10, 10.10.1, and 10.10.2 were not willing to write to the MBED device. This seems to be a known problem that the MBED user community is pretty upset about. The MBED developers have been working (slowly) on the bug since last October, with patches for only a few of their many supported boards (not, so far as I can see, the KL25Z).  There are claims on the developer forum about the bug that OS X 10.10.3 beta finally fixes the bug, but no one in their right mind would suggest that students install Apple beta code on a machine that they plan to use for anything. A student was going to enter an “issue” ticket on the PteroDAQ website, but it doesn’t seem to be there yet.
    2. If the Windows 7 machines in the lab were used to put the daq_kl25z.bin onto the boards, then OS 10.10 seemed to work ok (a student got it running), but OS 10.10.1 and 10.10.2 machines failed.  The problem seemed to be with Tkinter: the selection of the port for the KL25Z was not sticky—it deselected itself within a second of being selected. Some of the students had freshly downloaded versions of Python 3.4, so the problem doesn’t seem to be with old code, though I suppose a Tcl/Tk incompatibility with Python is possible—I didn’t have any of the students try re-installing Tcl.  I hope that a student with an OS 10.10.1 or 10.10.2 machine will post an issue ticket about this issue on the PteroDAQ website also.

    I’m now very glad that I did not “upgrade” my old OS 10.6.8 Mac to 10.10 on my 2009 MacBook Pro—it seems that I would have broken many of the things that I rely on my Mac for. Perhaps I’ll wait until I get new a new laptop before “upgrading”—and I won’t buy a new Apple as long as they don’t work with MBED, even though my current laptop has a very sick battery and is beginning to show its age. (I have no intention of buying a MacBook with only one USB-C port, either: I routinely use the power cable, the ethernet port, the firewire port, the display port, both USB ports, and the SD card port, and often use three or four of these at once.)

It would be really nice to have installation instructions with PteroDAQ—I forgot some steps of how to do the installation on Windows (the driver installation), and it would be nice to have a written description of the steps for a Mac that I could just point students to, rather than walking them through it.

I set up a mailing list for the class this evening, and I hope that students who manage to get PteroDAQ working on Windows 8 or OS 10.10.1 or 10.10.2 will share the information.

%d bloggers like this: