Software Instructions for Spring 2021

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

We had hoped that it would be possible for 6.302 students to be in a "pod" with a partner, so you would naturally have two laptops. It is pretty clear that was very wishful thinking on our part. If you have two laptops, the software below is easier to use if one laptop is to "monitor" and one is used to update the sketch. But, even though I have two laptops, I always use one laptop with two usb ports when developing software for the class. I sometimes have to unplug the Teensy 3.2 when Teensyduino gets confused during uploading a sketch, then I re-upload to the 3.6, and then reconnect the 3.2. If that fails, I also stop the python server, then upload to the 3.6, then plug in the 3.2 and then restart the server - Jacob

PLEASE NOTE: WE SUGGEST USING TWO LAPTOP COMPUTERS IN LAB, ONE FOR UPDATING THE THE CONTROL SOFTWARE (AND THEREFORE CONNECTED TO THE LONGER TEENSY 3.6 MICROCONTROLLER), AND A SECOND LAPTOP FOR MONITORING IN REAL TIME (AND THEREFORE CONNECTED TO THE SHORTER TEENSY 3.2 WHICH HANDLES COMMUNICATION). YOU CAN USE ONE COMPUTER FOR BOTH, AS LONG AS YOU CAREFULLY FOLLOW THE INSTRUCTIONS AT THE BOTTOM OF THIS PAGE!!

MAKE SURE YOU FOLLOW THE INSTALLATION INSTRUCTIONS FOR BOTH COMPUTERS.

Creating a directory with 6.302 software (BOTH LAPTOPS)
  1. Download 6302_21_software.zip (here ) to your Desktop.
  2. Open a shell window (a "terminal" window for linux or OSX, a powershell window on microsoft), change to the Desktop directory or folder, find the downloaded zip file, and extract its contents to the subdirectory 6302_21_software.
  3. Change to the 6302_21_software subdirectory, and type "ls" followed by a return to list the files. You should see three files and four folders: lib6302.zip, gui.html, server.py, 6302_PD_control, 6302_P_OPTO_control, 6302_USB_Repeater, and src.
  4. You will be adding the zipped library file, lib6302.zip, to the Teensyduino library after you install the Teensyduino software below.
Installing the Arduino and Teensyduino software (BOTH LAPTOPS)

Please follow the instructions at https://www.pjrc.com/teensy/td_download.html to download and install the latest version of the Teensyduino software. Depending on your computer and operating system, that may mean first installing the Ardunio software, and then downloading and installing the Teensyduino software. There are versions of both packages for linux, macosx and microsoft windows. Please DO NOT TRY TO USE AN earlier version of either software package!!!! Older versions have issues that interact with the tools we use in ways that are very hard to debug.

A guide to installing the Arduino software is here: https://www.arduino.cc/en/software (DO NOT USE THE PORTABLE OR APP OR ON-LINE VERSIONS of ARDUINO!).

If your system requires that you first install the Arduino IDE, DO NOT TRY TO INSTALL THE TEENSYDUINO SOFTWARE UNTIL YOU RUN THE ARDUINO IDE AT LEAST ONCE!!! There are some file permissions that will not be set correctly otherwise.

Installing the lib6302 library

You can use the Teensyduino IDE to install the lib6302.zip library, follow the instructions given for the Arduino IDE here https://www.arduino.cc/en/guide/libraries#toc4 . Roughly, you open the Teensyduino IDE, go to the "Sketch" pulldown menu, hover over "include library", and click on "add ZIP library" when it appears. Then you navigate to the directory with the lib6302.zip, and click on it. Done.

We recommend you use the library manager to install the our library, but if that fails, there are also manual instructions. If you decide to install the library manually, you will have have to find the directory where the IDE keeps its library files. If you open the preferences page for the IDE, it should show you a sketchbook directory. The libraries directory is usually a subdirectory of that, and you can install the library by moving the lib6302.zip file to the libraries subdirectory and unzip it.

Connecting the monitor laptop.
  1. Connect the Teensy 3.2 on your controller PC board (the smaller microcontroller) to the monitor laptop with a USB-to-MicroUSB cable. Then, start the arduino IDE on the monitor laptop, click the IDE's "tools" tab, and examine the tools tab's associated dropdown list. Make sure that next to the dropdown tag "board", the Teensy 3.2/1 is indicated, and that next to the tag labeled "port", the text "Teensy 3.2" appears. If not, click on either board or port, and select the Teensy 3.2 related option.
  2. If it is not already open, then open the "6302_USB_Repeater" sketch in the Teensyduino IDE, and try to download it on to the Teensy 3.2 (by clicking the click-circle with the right-pointing arrow on the top left of the Teensyduino IDE). If there are no errors, and the IDE reports a successful upload, then the installation is correct.
Connecting the control laptop.
  1. Connect a control laptop to the control Teensy (the larger microcontroller on your PC board, a Teensy 3.6). Open the Teensyduino IDE on the control laptop, and make sure the dropdown tags "board" and "port" both indicate the Teensy 3.6 (or click on the board or port and select the Teensy 3.6 related option). Then open the 6302_P_OPTO_control sketch, and try to compile and download it on to the Teensy 3.6. If the compile completes with no errors, and the IDE reports a successful upload, you have installed the control software correctly.
  2. If you get an error message indicating the arduino application is damaged, and a recommending that you delete it, please do so. Then try the above instructions again, but this time REALLY open a sketch with the Teensyduino IDE before installing the Teensy duino.
  3. IF YOU HAVE A PROBLEM WITH UPLOADS OR DOWNLOADS, TRY DISABLING ANY BLUETOOTH DEVICES, SUCH A BLUETOOTH MICE OR KEYBOARDS.
Verifying and possibly updating python (monitor laptop only)
  1. On the monitor laptop, open a shell window (terminal on Linux or Mac, powershell on microsoft).
  2. Change to the subdirectory with the unzipped 6302_21_software files.
  3. In the shell window, type "python" followed by return, then you should see a line of output indicating the python version. If you are using a version of python that is 3.7 or higher, you do not need to update python. If you are running python 2.7, or if the python command is not recognized at all, or you'd just prefer the newest python, see the instructions at the bottom of this page.
  4. In the shell window, type "python -m pip install pyserial" followed by a return. If you already have an up-to-date pyserial, the message "Requirement already satisfied...." will appear. Otherwise, pip will start downloading and installing.
  5. Then type "python -m pip install websockets" followed by a return. If you already have an up-to-date websockets, the message "Requirement already satisfied...." will appear. Otherwise, pip will start downloading and installing.
Running the monitor.

If you have not already done so, on the monitor laptop, download the serial repeater sketch to the Teensy 3.2, and on the control laptop, download the 6302_P_OPTO_control sketch to the Teensy 3.6.

On the monitor laptop (connected to the Teensy 3.2), use Chrome or Firefox to open the gui.html file in the 6302_21_software directory (Safari and Explorer browsers might work, but have not been tested). Then open a shell window on the monitor laptop (a terminal on Linux or Mac, powershell on microsoft), change to the 6302_21_software directory, and type "python server.py" followed a return. Finally, click the "reconnect" button in the browser window. You should see sliders and plots!

Installing Python if you need to.

You can install anaconda (which has python 3.7). If you decide to use Anaconda, be sure you are installing the 64-bit version, and if you are on Windows, be sure that you click on the "Add Python to the PATH" box even though Anaconda recommends against it.

Or you can install python 3.8 from python.org. If you are installing on Windows, be sure to download the ***x84-64 executable installer***. Execute the installer, AND ON THE VERY NEXT POP-UP BOX CLICK ON "Add Python 3.8 to the PATH". Then click on CUSTOM installation. In the next "Optional Features" POP-UP Box, click on EVERY feature in (particularly pip!!!). Click on Next, and in the next "Advanced Options" POP-UP Box, be sure that the "Install for all users" and "Add Python to environment variables" boxes are checked. Then click NEXT and then click YES.

If you are trying to use only one laptop (NOT RECOMMENDED)

If you are trying to use one laptop to do both the control and the monitoring, which we DO NOT RECOMMEND, and you have followed all the above steps (that is, you have installed all the software for both monitor and control), then try the following sequence of steps.

  1. Plug in ONLY the Teensy 3.2 (the smaller microcontroller) in to a usb point on your laptop. Be sure to UNPLUG the 3.6.
  2. Open 6302_USB_Repeater.ino with Teensyduino (the version with the Teensyduino addon installed).
  3. Use the Teensyduino tools menu to set the board and the port to Teensy 3.2.
  4. Upload 6302_USB_Repeater.ino on to the 3.2.
  5. QUIT ARDUINO!!!!!!!
  6. UNPLUG THE Teensy 3.2 and PLUG IN ONLY ONLY ONLY the 3.6 into a usb port.
  7. Open the 6302_P_OPTO_control.ino file with Teensyduino.
  8. Use the tools menu to set the board and the port to Teensy 3.6.
  9. Upload 6302_P_OPTO_control.ino onto the Teensy 3.6.
  10. Plug in the Teensy 3.2 into a second usb port.
  11. Open gui.html in Chrome.
  12. In the directory with server.py, open a shell window (a terminal on nix or MAC, powershell on microsoft), and use it to run the server software with python 3.8 (make sure updated pySerial and websockets have been installed, i.e. using pip). That is, at the powershell command prompt type "python server.py"
  13. Wait a few seconds and the plots should show up in the browser window.