Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: describe OT2 architecture #6245

Merged
merged 15 commits into from
Aug 5, 2020
60 changes: 60 additions & 0 deletions OT2_ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

theosanderson marked this conversation as resolved.
Show resolved Hide resolved
# OT2 Architecture
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

## Hardware

### Raspberry Pi

Inside the OT2 is a small computer (a [Raspberry Pi 3 Model B](https://www.raspberrypi.org/products/raspberry-pi-3-model-b-plus/)), running Linux.
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

#### Data storage

Data on the Raspberry Pi is stored in two physical pieces of hardware. The main operating system of the robot is stored on an SD card in the Raspberry Pi. This SD card is read-only apart from when the robot is being updated. Customized user data is stored on a thumb-drive in one of the USB ports of the Raspberry Pi (normally the case covers this USB port so it is not visible). The OT2 camera (a webcam) is connected to another normally hidden USB port of the Raspberry Pi.
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

#### Networking

Other computers, like your laptop, communicate with the Raspberry Pi that controls the OT2 via a network. When you connect your robot via USB, you are in fact connecting to the Raspberry Pi's ethernet port. The USB port is connected to an internal USB-to-ethernet adapter, which is in turn connected to the Pi's ethernet port. When you connect a cable to the robot's USB port, your computer recognises the device as a new network interface, which establishes a local network with the OT2. (You can also connect the OT2 to a wireless network with WiFi, or connect to a wired network by placing a USB-ethernet adapter in one of the Pi's USB ports).

### Lights, switches

The Raspberry Pi controls the lights of the robot, and detects presses on the switch and opening of the door via its General Purpose Input-Output (GPIO) ports. The GPIO ports also allow the Raspberry Pi to reset the motor controller board (described below).

### Motor control

The robot has 6 axes of motion, each controlled by a stepper motor:


- X: left-right
- Y: forward-back
- Z: left pipette up-down
- A: right pipette up-down
theosanderson marked this conversation as resolved.
Show resolved Hide resolved
- B: left pipette plunger up-down
- C: right pipette plunger up-down


The motors of the robot, and the endstops and probing switches that help position them, are connected to the motor controller board, housed in the gantry, which is a [SmoothieBoard](http://smoothieware.org/smoothieboard) running [a custom fork of Smoothieware](https://github.com/Opentrons/SmoothiewareOT).
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

The SmoothieBoard is connected to the Raspberry Pi via a UART connection, with the Pi sending commands in [GCODE](https://en.wikipedia.org/wiki/G-code).
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

# Software
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

The main operating system of the robot is a minimal version of Linux built using [a custom fork of buildroot](https://github.com/Opentrons/buildroot).

The buildroot [configuration](https://github.com/Opentrons/buildroot/blob/opentrons-develop/configs/ot2_defconfig) includes a number of standard packages, and also some specific to the OT2. Those specific to the OT2 are: the API, the robot server, the 'shared data', and the update server.

## API
theosanderson marked this conversation as resolved.
Show resolved Hide resolved
The [Opentrons API](https://github.com/Opentrons/opentrons/tree/edge/api) is a Python package which provides an interface to control the OT robot. Protocols are written in the protocol API, which is a part of the API package.
theosanderson marked this conversation as resolved.
Show resolved Hide resolved

With the API alone, a Python script or Jupyter notebook running on the OT2 is able to control the robot to perform liquid-handling operations.

## Robot server
theosanderson marked this conversation as resolved.
Show resolved Hide resolved
The main such Python programme is the [robot server](https://github.com/Opentrons/opentrons/tree/edge/robot-server), which provides the interface to the robot that the Opentrons app on a user's computer can access to do routine robot work. It provides endpoints that allow performing calibration and running protocols uploaded from the app.

Note that only one process can have access to the robot's GPIO ports at a time. By default the robot server connects to these ports on start-up, which prevents a copy of the API running in Jupyter or imported from a Python script from using GPIO functionality. To gain access to the GPIO's in these custom scripts, one can disable the robot server with `systemctl stop opentrons-robot-server`, before importing the Opentrons API into the other Python script. However this will prevent the Opentrons app from connecting to the robot until the robot server is restarted with `systemctl start opentrons-robot-server`, or the robot is rebooted.

## Shared data
theosanderson marked this conversation as resolved.
Show resolved Hide resolved
Some information, such as labware geometry data, needs to be used in multiple locations in the Opentrons codebase (e.g. in the protocol designer as well as on the robot itself). This data is kept in a special [shared data](https://github.com/Opentrons/opentrons/tree/edge/shared-data) repository so that it can be easily included in all these locations.
theosanderson marked this conversation as resolved.
Show resolved Hide resolved


## Update server
The [update server](https://github.com/Opentrons/opentrons/tree/edge/update-server) is a separate server designed simply to allow updating the robot's software with a new system image built using buildroot.
theosanderson marked this conversation as resolved.
Show resolved Hide resolved