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:
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 sine_wave(t)=sin(2.*pi*sine_freq*t) 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:
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 python.org) 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 (http://forum.arduino.cc/index.php/topic,94651.msg727588.html#msg727588) are rather scary. A more tutorial presentation is given by SparkFun at https://learn.sparkfun.com/tutorials/disabling-driver-signature-on-windows-8