A python library for IOLab
Python
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
AnalogExample Many small fixes May 12, 2017
DaqExample Ready for release Mar 16, 2017
Documentation Version ready for release Mar 5, 2017
HelloWorld minor changes Jul 20, 2017
PyOLabCode minor changes Jul 20, 2017
guiExample Analog I/O May 11, 2017
.gitignore ready to merge Mar 16, 2017
LICENSE Create LICENSE Mar 6, 2017
README.md Update README.md Aug 15, 2017

README.md

Release Overview

PyOLab is a suite of Python (2.7) routines that gives users complete control of an IOLab system. The archive contains a folder containing the PyOLab library code (PyOLabCode), three folders containing example user code (HelloWorld, DaqExample, and guiExample), and a folder containing Documentation referred to in the code (Documentation).

There are detailed instructions for Getting Started at the bottom of this page, and also in the README.md file that is part of the release download.

Note: The Library has been tested on OSX and Windows. I have not tested it on Linux. Please let me know if you do so.

PyOLabCode

This folder contains a collection of methods to allow the user to open a serial port, send commands to the IOLab hardware, and receive both status information and asynchronous data from the hardware:

  • commMethods.py Communication with the IOLab hardware via the USB virtual com port.
  • setupMethods.py Focused on setting up the IOLab system, initializing the anynchronous threads that fetch and unpack and decode data, calling user code to analyze these data, and shutting things down when finished.
  • dataMethods.py Focused on decoding, organizing, and analyzing the data received from the IOLab system.
  • iolabInfo.py Code to provide callable information about the IOLab hardware & firmware (basically documentation).
  • pyolabGlobals.py Global structures and variables used to expose IOLab data and controls to the user.
  • analClass.py Used to separate the user code from the analysis code (basically a naive callback structure).

HelloWorld

This folder contains the simplest possible user code example to talk to the system using the PyOLab library:

  • userExample.py Very simple main() code that opens the serial port, asks the dongle what its status is, receives the answer, and quits.

DaqExample

This folder contains a slightly more sophisticated user code example that uses the PyOLab library tomimplement a multi-threaded data acquisition system:

  • userExample.py Example of some main() code that opens the serial port, launches data fetching and data analysis threads, and then waits for user input.
  • userMethods.py Examples of user routines that are called by the system during data analysis to expose the user to the acquired data. In this example the user code prints out any accelerometer data that is received from the remote, and at the end of the job it prints a summary of the records and data that were received from the system.
  • userGlobals.py Example of some global user variables used by the user methods.

guiExample

This folder contains example user code that implements a GUI (using Tkinter) to send and receive IOLab records and implements a multi-threaded data acquisition system similar to the one in DaqExample:

  • userExample.py Example of some main() code that sets up a GUI, opens the serial port, launches data fetching and data analysis threads, and then waits for user input.
  • userMethods.py Examples of user routines that are called by the system during data analysis to expose the user to the acquired data. In this example the user code displays records exchanged with the IOLab system using Listboxes on the GUI.
  • userGlobals.py Example of some global user variables used by the user methods.

AnalogExample

This folder contains example user code that implements a GUI interface to display the values (in Volts) of analog inputs A7, A8, A9, and provides a slider control to set the DAC output voltage:

  • userExample.py Example of some main() code that sets up a GUI, opens the serial port, launches data fetching and data analysis threads, and then waits for user input.
  • userMethods.py Examples of user routines that are called by the system during data analysis to expose the user to the acquired data. In this example the user code displays the voltages read from A7, A8, A9.
  • userGlobals.py Example of some global user variables used by the user methods.

Getting Started

Getting up and running with IOLab using Python should be straightforward. In this section I will assume you just removed your IOLab from the box and have done nothing else. I have tested the following procedure on Mac and Windows and I assume the Linux installation will be very similar to the Mac procedure, so if you are trying this on Linux please let me know how it goes.

1. Setting up the driver (Windows only): Your computer communicates with the IOLab Remote via the thumb-drive sized Dongle that is initially stored in a recess on the back of the Remote. When the Dongle is plugged into a USB port on your computer, the operating system recognizes it as a regular serial port. This is called a virtual com port, and the driver needed to do this is already part of your computer's OS. For Mac and Linux you don't need to do anything to use this driver - it just happens - but for Windows there is a step that you will need to do once per computer. Instructions for doing this can be found at the IOLab.science, and are to save you time this is a direct link to what you need. Just follow the instructions.

FYI: This is the same step required if you are using the IOLab application that you can download from IOLab.science, so if you are already using the application on this computer you don't need to repeat this step now.

2. Getting Python 2.7: Go to Anaconda and follow the directions to get a free installation of Python 2.7 on your computer (do not install Python 3.6, this is slightly different and will not work).

A nice bonus of this installation for Windows users is that it also installs an application called Anaconda Prompt, which provides a command-line interface that will be very useful. Mac and Linux users can just use the native terminal window whenever you need a command-line interface.

3. Installing PySerial: Open up a command-line interface (Anaconda Prompt a terminal window), and type pip install pyserial. The PySerial module will be added to your Python configuration.

4. Run the example code: You are now ready to try it out. Plug in your Dongle and turn on your Remote. If you are running from a command line, cd to one of the example folders and then type python userExample.py to run it. If you are using Anaconda's Spyder application, open one of the userExample.py files using the GUI and click the Run button.

5. Note for Linux users: I am a Linux novice (using Ubuntu) so any advice is appreciated. I have found the following: (a) In order to get access to the serial port I needed to issue the command sudo usermod -a -G dialout username. (b) The code in guiExample has issues writing to a listBox widget under Linux, though it works fine under Windows and Mac OS.


License

Use this code at your own risk in accordance with the Open Source BSD-3-Clause license.