I think a Python measurement framework would be nice. Maybe we can use some parts of the project at
http://sigrok.org that @lwatts666 mentioned?
An idea: a generic base class "Instrument". All instruments in common is the capability to measure something. An instrument has a fixed number of inputs (and maybe outputs?). Concrete instrument classes for a HP34401A, or a HM8012, are derived from the abstract base class and implement all the instrument specific initialization and communication. It might be possible to configure an input, e.g. select volt or ohm, and select a range or auto-range. For each input you can get an input reader, which reads this input and knows about more about the input, like the unit, e.g. V or A, or the instrument channel.Then a logger class. You can add inputs to it and it automatically reads all inputs and writes them with a timestamp to a file, in a selected interval.
Sounds difficult if you are not an object oriented programmer, but it makes it really easy to write your own custom measurement script for an advanced end user. Goal should be that you can write a script for an instrument, without knowing the GPIB commands or other details of the instrument, except some instrument specific configuration for selecting AC or DC etc. A logger program could look like this (I don't know much about Python, so this might not compile) :
try {
# create a new instrument object. Opens the default port for this instrument
# and initializes it to be used with the framework, e.g. ASCII output format, 9 digits etc.
voltageMeter = new HP34401A();
# application specific configuration of an input of the instrument.
# optional parameter: channel=x, if there are more than one input
voltageMeter.configure(command=HP34401A.DCV, value=10);
# creates a new instrument object for a LM75A temperature sensor
# uses the default I2C address 0x48 for A0-A2=0, if not specified in the constructor
# the I2C address could be a generic parameter "port", which could be the GPIB address, or an I2C address,
# and a factory function in the instrument which lists all available ports, to create a GUI for port selection later
i2cTempSensor = new LM75A();
# create a new logger object and add all inputs. The getInputtReader-function could have an optional channel parameter
log = new Logging("/pub/logs/test.csv");
log.add(voltageMeter.getInputReader());
log.addInstrument(i2cTempSensor.getInputtReader());
# start logging
# this creates the log file, writes the CSV header and saves the current time for the exact measurement interval
log.start();
while (true) {
# measures all configured inputs and writes it to the CSV file, with a leading timestamp
log.measureInputs();
# waits for the specified number of seconds, relative to the last call of this function, so that there is an the exact same interval between every measurement
log.waitSeconds(10);
}
log.createWebpage("/pub/html/test.html");
} catch (exception) {
print(exception);
}
So all you need to write for a volt/temperature combination logger, with website output, are about 10 lines of easy to understand code, which can be mixed with custom tasks, like switching relays after some time etc. The generated CSV file header should name the instrument and unit, and optionally the channel, or I2C address etc.:
(timestamp) | (HP34401A, V) | (LM75A, C) |
10/12/2016-07:53:27 | 9.152 | 22.3 |
10/12/2016-07:53:37 | 9.264 | 22.2 |
The InputReader class has a function "measure", which returns a float for the measured value, and it has a function getUnit. Now the log object can have a function to create a standard webpage to display all configured instruments and inputs, with some nice diagram header and axis labeling. There could be also a getLastMeasure function in the InputReader class, which you can use in the measure loop to get the last value, if you want to compare it to something to do something, in addition to the log output.
One step further: There is a webpage, which lists all available instruments. You can add multiple instruments with a mouse click and individually configure each instrument and the measurement interval. The set of instruments with the configuration can be saved as a project. You can start a measurement and then a log file is named with the project name and a sequential number suffix. You can click on a log file to display, download and delete it.
An instrument can list the possible set of configuration parameters so that you can edit this in the web page when configuring an instrument. There could be some templates for an instrument with a set of configuration parameters, e.g. "measure DC voltage", "measure AC ampere", so that you don't have to lookup the meaning of all parameters. The templates are provided by the concrete instrument class. Each parameter has a description, so that it is self documenting, without needing to read a manual for an instrument.
For the webserver it might be a good idea to use the Python webserver
http.server, because then it is easier to access the Python instrument classes and configuration. The Python webserver could also provide a JSON server interface, so that you can call your Raspberry Pi from other systems and create a set of distributed network connected measurement devices.
Shouldn't be too difficult to implement. An experienced Python developer with webserver and object oriented programming experience might be able to do it in one week full time. Too bad I don't have much time at the moment , but I can help with testing, bugfixing and framework design ideas, if someone wants to do it.