# Gas station without pumps

## 2014 April 2

### Gnuplot demo

Filed under: Circuits course — gasstationwithoutpumps @ 17:29
Tags: ,

At the beginning of class, I told students about standard resistor values and pointed them to a web site that has tables of the standard values, telling them that they would need to do their designs using resistors that were in their kits. One student cleverly asked what to do when the computed resistance was not a standard value, suggesting combining resistors. I agreed that one could combine resistors, but that a more common approach was to round to a nearby standard value.  If you need to have the value more exact than the standard values, then you need to switch to a more expensive, higher-accuracy series of resistors, and then you have a finer set of standard values.

Either before or after the standard resistor spiel, I gave the students a homework problem:

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.

Last year I had done a similar problem as a “do-now” problem, and it had taken about 20 minutes of class time. I did not want to spend that much class time today on it, because I wanted to get them an intro gnuplot tutorial. I’ll look at their results on the design tomorrow at the beginning of lab, and have them build and test their designs. I’ll also be having them build the circuits they came up with for converting their thermistor resistances to voltages, where they were supposed to have done the calculus to get maximum sensitivity for the circuit at some operating temperature Top.

After the homework assignment and the resistor standard values, I developed a gnuplot script for plotting the data the students collected yesterday in the lab and fitting the two-parameter model. I had the students follow along with gnuplot on their own laptops using their own data.

Because I was winging it, without a pre-written script to follow, I made several mistakes along the way (stopping at one point to rederive an equation, as the one I was using got ridiculous answers—it turned I had the parameter B on the wrong side of the division bar in a fraction).  The entire script development was done by alternating between a window editing the script and a terminal window with gnuplot running, where I just kept re-running a “load” command for the script.

I started out showing them how to plot data, gradually adding log scales (you get a nice straight line if you use log scale for the resistance), axis labels, plot title, functions, functions in the “using” field (to convert my Fahrenheit data to Kelvin), ranges, fitting models to data, printing the fit parameters on the plot, and creating a PDF file from the script.  I thought we managed to get a lot covered in 70 minutes, and at least some of the students were keeping up, so that they can help each other. I released the script we developed on the class website, along with the plot we produced from my data: thermistor data plot (sorry, that’s a PDF file, and wordpress.com doesn’t accept PDF files as images—you’ll have to click through to see it).

Overall, I think that this approach is likely to be much better than what I tried last year, where the students were given a complete and complicated script and expected to figure it out and modify it. I ended up teaching gnuplot in the second week last year, when it would have been better to start sooner.

Two of the students with Macs had not been able to get gnuplot installed before class.  I pointed them to the comment on my previous post. I hope they’ll be able to get it installed this evening.  (The students with Windows machines managed to find already built binaries at http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/, via the link on http://www.gnuplot.info/download.html (the mac installers listed on the gnuplot download page did not work for the students, supposedly).