Table of Contents
- Confirm that the most recent versions of the following Python software packages are available on your computer.
If not, then log in and download the newest versions by clicking on View Files and following the Python path
to the zip files:
- Measure the transmission function A(ω) of a circuit using scan_2.py.
- Simulate the response A(ω) of a circuit using simulatem.py.
- Plot the simulations, data and both together using response_plot.py.
- This task will introduce programming with Python, communicating with USB-based instruments and simple signal processing.
- The experiments are the following: I(V) response of a purely resistive object; complex impedance spectrum of an object.
Basic Python Programming
- Open a DOS session and run the command "python". Follow the programming instructions.
- From start menu -> python, run Idle, a simple IDE, and follow the programming instructions.
- From the start menu, run geany, a real IDE for several programming languages and even LaTeX. Compose and
execute simple programs outlined by the instructor.
- On the Python Wiki site, go to the
"Basics" page and experiment with the programs.
- Copy and execute the simple plotting program
provided by the instructor to generate a data set using the numpy module and plot it
using the pylab module. The pylab module is part of the matplotlib package which provides Matlab style graphing
functionality. Read the Python page for more information.
Instrumentation Communication Resources
- On the PH415 Spring 2012 site, the instrumention page
has a wealth of information.
- The VISA protocol is important and will be the basis for controlling high-level instrumentation. There is, of course,
a Python module to facilitate this. Visit the PyVisa site and read the
Viewing USB Device Parameters
- Use control panel -> system -> hardware -> device manager to get some information about USB controllers and
connected devices. Pay particular attention to device information, such as vid and pid, and the service or driver
used, such as usbstor for flash drives, usbhib for a mouse, and niusbtmc (niusbtmc.sys in c:\windows\system32\drivers) for an oscilloscope.
- Unzip and execute usbview, a utility from M$ to see
some detailed information about the USB configuration for the scope.
- Unzip and execute SniffUSB to see the transactions with
USB devices on your machine. The documentation is
helpful. Hit the view log button to see some USB transactions. Be thankful than you do not have
to deal with communications at this level.
Recognizing VISA Compatible Instruments
Syntax For Instrumental Communication
- The Tektronix and Rigol instruments used in PH415 have communication syntaxes which conform to the
Standard Commands for Programmable Instruments (SCPI).
Peruse this document before digesting the programming manuals for the instruments you will use.
- In general, a programmable instrument might conform to the
Instruments - Scope Class specifications which are controlled by the
IVI Foundation, a Microsoft/National Instuments (LabView)/MathWorks (Matlab) syndicate.
SCPI has been consumed by this organization and remains unchanged, if not orphaned, since 1999.
- Establish basic communications with the instruments by reading the
PyVisa documentation. Even just the first example in this document is sufficient. Open an IDLE session and converse
with an instrument. Using Geany, write a very short Python program to both set and read one parameter for each instrument.
- Familiarize yourself with the printed operation manuals for the TDS1012B oscilloscope and the AFG3021B function
generator. On the oscilloscope page, read about the programming
syntax. On the waveform generator page,
read about the syntax.
Creating Instrument Objects in Python
- Go to the Marina site and follow the
path "Site Map" --> "Introduction" --> "API". View all of the classes used in Marina and examine
the classes for the oscilloscopes and arbitrary waveform generators (awgs). These are too complicated to work
with in the limited time at hand, but the concept of building a system of modules and an explanatory API is central
to constructing experimental control, data acquisition and data analysis programs.
- Write a module called tek_instruments.py containing a Python class for each instrument with simple read and write functions. Then write a test routine which
will query each instrument for some parameter settings and set some parameters. You will need to import
supported_instruments.py and include a routine to create instances of the instrument classes as instruments are
recognized. Compare your program to the instructor's version
instrument_classes.py. Use this program as
a module to be imported into a program at the next level.
Documenting Programs and Creating an API
- Documenting a program must be an integral part of the development process. The Doxygen
program documentation system package has been installed on the computers. Read the doxygen manual-220.127.116.11
and incorporate the correct type of comment lines into instrument_classes.py so that Doxygen can interpret them properly.
Doxygen will generate a set of htmls that can be opened with a browser.
- In order to use Doxygen or any similar documentation system, organize your Python modules in a logical directory
structure. Suggested structure: directory tree.
- Run the Doxygen GUI and set the working directory to c:\documents and settings\ph411\ph415_s13\doxygen.
Then, choose the "wizard" and set the project name to "Instrument Classes". Sequentially select the topics
on the "Topics" panel and set several parameter as given below:
Choose as the source code directory c:\documents and settings\ph411\ph415_s13\code\instrument_classes;
Choose as the destination directory c:\documents and settings\ph411\ph415_s13\documentation\instrument_classes.
- Mode: Check the "All entities","Include cross-referenced source code in the output" and "Optimize for Java ...".
- Output: html, with navigation panel, with search function, LaTeX, as intermediate format for pdf.
- Diagrams: Use built-in class diagram generator.
Configuring Instruments for Experimental Measurements
- To send multiple commands to and read multiple parameter values from an instrument in a way that can be easily
changed, it is logical to create a text file of commands, such as
This file can then be parsed and used with a program such as
This older program is not compatible with your module of instrument classes, so write a new program called
configure_instruments.py which will parse a new file configure_instruments.txt, recognize instruments, create
instrument objects and execute the commands in configure_instruments.txt.
- Instructor's version (place these files together in a "configure_instruments" directory) :
visa_fake.py. To run configure_instruments.py
without PyVisa or a real scope and wg, rename visa_fake.py as visa.py. The program visa_fake.py simulates a
scope and a wg to a limited extent.
Conduct an Experiment Using a Waveform Generator and an Oscilloscope