# 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).

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:

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 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

## 1 Comment »

1. One student managed to get pterodaq working for Windows 8.1. Assuming you have your board properly configured

Install python 3.4.0
Set PATH (C:\Python34\;C:\Python34\Scripts)
> pip install pyserial
> python -m tkinter (verify which version, 8.6 confirmed to work)
> shutdown /r /o
Advanced options -> Startup Settings -> 7 (Disable driver signature enforcement)
Device Manager -> Install .inf from pterodaq/extras
Restart command prompt
Start pterodaq

Comment by gasstationwithoutpumps — 2015 April 2 @ 07:56

This site uses Akismet to reduce spam. Learn how your comment data is processed.