Prepared for 2017 AAPT Summer Meeting

@matsselen matsselen released this Jul 20, 2017 · 1 commit to master since this release

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.

Updates & Bug Fixes

@matsselen matsselen released this May 12, 2017 · 3 commits to master since this release

  • Fixed bug that dumped too much info to the log file.
  • Changed remaining "print" statements in library routines to "write" statements directed at log file.
  • Added example code that reads analog inputs and controls DAC output.

Fixed Bugs and added "Getting Started" info

@matsselen matsselen released this Apr 1, 2017 · 9 commits to master since this release

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.

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 to implement 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.

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.


License

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

Bug Fix

@matsselen matsselen released this Apr 1, 2017 · 13 commits to master since this release

Fixed a bug preventing the Dongle from being recognized on Windows machines. This is a quick patch that has only been tested in a few machines - it will be tested and (if needed) updated in the next day or two.

Added GUI example (Mac Only)

@matsselen matsselen released this Mar 16, 2017 · 14 commits to master since this release

Bug being resolved

Com port is not found on Windows machines. This will be addressed by April 3.
Sorry folks - Mats

Features of this release:

Added example user code that implements a GUI (using Tkinter) to send and receive IOLab records. Lots of small changes to the basic pyolab code - mostly cleaning up and adding comments.

Make sure you read the Inital Release notes provided with version 0.1.0 (below).

Initial Release (Mac Only)

@matsselen matsselen released this Mar 5, 2017 · 36 commits to master since this release

PyOLab

Bug being resolved

Com port is not found on Windows machines. This will be addressed by April 3.
Sorry folks - Mats

Overview

This is a Python 2.7 library that enables primitive stand-alone communication with IOLab. It is NOT designed to replace the highly capable application you can download for Windows and Mac at www.iolab.science, but rather to enable interested people to tinker with the guts of the IOLab system at a programming level.

The release consists of a README file; a folder containing the PyOLab library code (PyOLabCode); two folders containing example user code (HelloWorld and DaqExample); and a folder containing Documentation referred to in the code (Documentation).

If you are new to Python you can get a great free release from Anaconda. You should install Python 2.7 (not 3.6). You will also need to get PySerial (more info below). There is plenty of on-line support and documentation for learning Python.

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

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, prints it, and quits.

DaqExample

This folder contains a slightly more sophisticated user code example that uses the PyOLab library to implement 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 (may not be needed by your code).

pyserial

PyOLab requires the pyserial module to handle com port communication. You can find more information at https://github.com/pyserial/pyserial/.

Basic installation of pyserial is straightforward: pip install pyserial should work for most users.