Skip to content

allevitan/instruments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Instruments

Instruments is a (fairly) consistent python interface for the instruments in Wellesley's 310 physics lab.

Dependencies

  • python 2 or 3
  • numpy
  • A standard VISA library (NI-VISA, TEKVISA, etc.)
  • pyVISA
  • pySerial

Usage

Each instrument class is designed to be used in the following manner:

from instruments import Voltmeter
with Voltmeter('COM3') as instr:
	#your code goes here

This syntax ensures that the connection to the instrument will be safely closed, regardless of any exceptions thrown by your code.

Voltmeter, Ammeter, Encoder, SerialInstrument, and GPIBInstrument implement the instr.read(num) method, which reads num values from the instrument. If num is not provided, it will read a single value.

Oscilloscope is fundamentally different - calling scope.read(channels) will return current data from each channel in channels.

Heater, the heater for the heat capacity of copper lab, is also different. It has two methods, heater.on() and heater.off() which do exactly what you'd expect.

Examples

  • Print the next 100 readings from an ammeter:
from instruments import Ammeter

with Ammeter(6) as amp: #ammeter on GPIB bus 6
	print(amp.read(100))
  • Plot channels 1 and 3 from an oscilloscope:
from instruments import Oscilloscope
from matplotlib.pyplot import *

with Oscilloscope() as scope:
	data = scope.read([1,3])

plot(data['time'],data[1])
plot(data['time'],data[3])
show()

Installation of dependencies

  • Install anaconda python.
  • Install NI-VISA, TEKVISA, or some other VISA library. Note that while NI-VISA is the best, installing it is a huge pain in the butt.
  • Run pip install pyserial pyvisa from the terminal (OSX/Linux) or cmd.exe (Windows).

Questions

Email me at allevitan@gmail.com if something is unclear and fork the repo if you want to make it better!

About

A (fairly) consistent interface for the instruments in Wellesley's 310 lab.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages