Skip to content

Commit

Permalink
Merge pull request #101 from AccelerationConsortium/update-robotics-c…
Browse files Browse the repository at this point in the history
…ourse

Update robotics course tutorials
  • Loading branch information
sgbaird authored Oct 26, 2024
2 parents 9b7e323 + cd6bb67 commit a01706a
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/rocker-org/devcontainer-features/miniforge:2": {}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cover/*
MANIFEST

# Per-project virtualenvs
venv*/
.venv*/
.conda*/
.python-version
Expand Down
103 changes: 88 additions & 15 deletions docs/courses/robotics/3.1-pumps-and-pipettes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
## 🔰 Tutorial

In this module, you will develop software to:
1. manage a peristaltic pump’s operations using a microcontroller and motor driver
2. manipulate the linear actuator of the Digital Pipette
1. Manage a peristaltic pump's operations using a microcontroller and motor driver
2. Manipulate the linear actuator of the Digital Pipette
3. Control a stepper motor for precise positioning
4. Manage fan speed for temperature control in laboratory equipment

These skills are fundamental in creating automated liquid handling systems for various scientific applications.

### Peristaltic Pump

Expand All @@ -32,16 +36,33 @@ First, you will manage a peristaltic pump’s operations using a microcontroller
- [OPTIONAL] [Blue food coloring](https://www.amazon.ca/Club-House-Food-Colour-Preparation/dp/B00HVVNFPI/)
<!-- - [OPTIONAL] [Glycerin](https://www.amazon.ca/NOW-Vegetable-Glycerine-Liquid-118ml/dp/B00PUX5SF4/) (low vapor pressure for longer-running setups, alternative: water) -->

Peristaltic pumps are the workhorses of many laboratories! 🏋️‍♀️ They're used for precise liquid handling in various applications:

- 🧪 Transferring chemicals in analytical chemistry
- 🦠 Moving culture media in microbiology
- 💊 Dispensing precise volumes in pharmaceutical research
- 🌱 Delivering nutrients in hydroponics systems

Fun fact: The pump's mechanism mimics the peristalsis of your digestive system! 😮

#### Demo

✅ Read the [MDD3A DC Motor Driver datasheet](https://docs.google.com/document/d/1ax3gSo0srTzoSr2bo8ETLym0OqrYjlk_JCZK4kxtfXg/edit?usp=sharing)

Understanding the motor driver is crucial for controlling the pump effectively.

✅ Read [PWM](https://en.wikipedia.org/wiki/Pulse-width_modulation)

Pulse-Width Modulation (PWM) is a key technique for controlling motor speed in many applications.

✅ Read [Control LED brightness with PWM](https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/7)

This tutorial provides a practical introduction to PWM control.

✅ Read [machine.PWM](https://docs.micropython.org/en/latest/rp2/quickref.html#pwm-pulse-width-modulation)

Understanding the MicroPython PWM API is essential for implementing motor control.

Use your knowledge, the documentation above, and any relevant datasheets to set up the circuit to control the peristaltic pump. After setting up the hardware, run the following code on the microcontroller (ensure you select the appropriate PWM Pin):

```python
Expand All @@ -62,6 +83,12 @@ You should observe the peristaltic pump turn on for five seconds.

https://github.com/sparks-baird/self-driving-lab-demo/blob/main/src/public_mqtt_sdl_demo/scripts/pump.py

#### Expanded Applications 🚀

- 🍺 Craft breweries use peristaltic pumps for precise ingredient dosing
- 🏥 In hospitals, they're crucial for IV drug delivery systems
- 🌈 They're even used in fountain displays for creating colorful water shows!

### Digital Pipette

Next, you will control the linear actuator of the "Digital Pipette" to carry out precise dispensing.
Expand All @@ -87,12 +114,23 @@ Based on https://github.com/ac-rad/digital-pipette
- [Wire cutter/stripper combo](https://www.amazon.ca/Professional-crimping-Multi-Tool-Stripper-Multi-Function/dp/B073YG65N2)
- [Mini flathead screwdriver set](https://www.amazon.ca/dp/B08QCT9NHY/) (one for regulators and a smaller one for PiCowbell terminals)

Digital pipettes are the unsung heroes of precise liquid handling! 🦸‍♀️ They're essential in:

- 🧬 Molecular biology for DNA/RNA work
- 🔬 Preparing samples for microscopy
- 🧫 Setting up PCR reactions
- 📊 Preparing standard solutions for calibration curves

Did you know? Digital pipettes can be more accurate than traditional glass pipettes, especially for very small volumes! 🎯

#### Demo

✅ Read [Digital pipette: open hardware for liquid transfer in self-driving laboratories](https://doi.org/10.1039/D3DD00115F)

✅ Read the [Digital Pipette GitHub README](https://github.com/ac-rad/digital-pipette)

Understanding the open-source implementation is crucial for customization and troubleshooting.

https://github.com/AccelerationConsortium/ac-training-lab/blob/main/src/ac_training_lab/picow/digital-pipette/scripts/digital_pipette_picow_basic.py

Run the following code on your microcontroller:
Expand All @@ -119,6 +157,12 @@ set_position(1.9) # Almost full extension
pwm.deinit() # Deinitialize PWM
```

#### Cool Uses 😎

- 🍫 Chocolatiers use them for adding precise amounts of flavoring
- 🎨 Artists employ them for mixing exact paint colors
- 🧁 Bakers use them for adding food coloring or extracts in precise amounts

### Stepper Motor

You will use a stepper motor driver to control the position of a stepper motor.
Expand All @@ -137,6 +181,15 @@ You will use a stepper motor driver to control the position of a stepper motor.
- [Electrical wire (3 feet, white)](https://www.digikey.ca/en/products/detail/cnc-tech/10981-18-1-2000-002-1-TD/17799244)
- [Mini flathead screwdriver set](https://www.amazon.ca/dp/B08QCT9NHY/) (one for Tic500 and a smaller one for PiCowbell terminals)

Stepper motors are the precision dancers of the motor world! 💃 They're used in:

- 🖨️ 3D printers for precise nozzle movement
- 🔭 Telescope mounts for tracking celestial objects
- 🤖 Robotic arms for accurate positioning
- 📷 Camera systems for smooth panning and tilting

Cool fact: Some high-end watches use stepper motors for moving the hands! ⌚

#### Demo

✅ Read specs for [Tic500 Stepper Motor Driver](https://www.pololu.com/product/3134)
Expand Down Expand Up @@ -177,8 +230,29 @@ tic.deenergize()
tic.enter_safe_start()
```

#### Unexpected Applications 🎭

- 🎰 Slot machines use them for spinning reels
- 🎹 Electronic musical instruments for key action
- 🚗 Some car headlights use them for adaptive lighting systems

### Fan Control

Temperature control is crucial in many lab setups! 🌡️ Fan controllers help in:

- 🧊 Maintaining precise temperatures in incubators
- 💻 Cooling sensitive electronic equipment
- 🔥 Managing heat in chemical reactions
- 🌿 Controlling airflow in plant growth chambers

Did you know? Some advanced fan controllers can adjust fan speed based on multiple temperature sensors, creating temperature zones! 🌡️🌡️🌡️

#### Creative Uses 🎨

- 🍷 Wine cellars use them for maintaining optimal storage conditions
- 🎸 Musicians use them in amplifiers to prevent overheating during performances
- 🏎️ Racing simulators use them to create realistic airflow sensations!

#### Bill of Materials
- [Adafruit EMC2101 I2C PC Fan Controller and Temperature Sensor](https://www.adafruit.com/product/4808)
- [Raspberry Pi Pico WH](https://www.raspberrypi.com/products/raspberry-pi-pico/?variant=raspberry-pi-pico-wh)
Expand Down Expand Up @@ -253,34 +327,33 @@ while True:
::::{tab-set}
:sync-group: category

:::{tab-item} W 2024
:sync: w2024

:::

:::{tab-item} Sp/Su 2024
:sync: sp2024

https://q.utoronto.ca/courses/370069/assignments/1393644
https://q.utoronto.ca/courses/370069/assignments/1393644?display=full_width
:::

::::


## 📄 Assignment

Create a script that allows you to set peristaltic pump power as a fraction and then perform a calibration to determine a power to flow rate conversion for the peristaltic pump.

✅ See an example calibration procedure in [Peristaltic Pump Calibration](https://docs.google.com/spreadsheets/d/18t2_kxa8xe1a8FoVrQRKD_lHAqVDYKhnHKoxriJCWNc/edit?usp=sharing).

Create a script that allows you to set Digital Pipette actuator position as a fraction from 0 to 1 and then perform a calibration to determine a pulse length to volume ratio. Note also the calibration procedure from the manuscript linked above.

Create a script that allows you to make four 90 degree rotations each spaced by 5 seconds.

Create a script that controls the fan to keep the temperature below a certain threshold.

::::{tab-set}
:sync-group: category

:::{tab-item} W 2024
:sync: w2024

:::

:::{tab-item} Sp/Su 2024
:sync: sp2024

[URL]
https://q.utoronto.ca/courses/370069/assignments/1397938?display=full_width
:::

::::
76 changes: 71 additions & 5 deletions docs/courses/robotics/3.2-serial-communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ Design and execute software to read data from a mass balance using serial commun

## 🔰 Tutorial

Serial communication is a method of transmitting data between devices one bit at a time. It's widely used in scientific instruments, industrial equipment, and embedded systems due to its simplicity and reliability. In this tutorial, we'll focus on RS232, a common serial communication standard, and how to interface it with modern microcontrollers.

### The Stars of Our Show 🌟

Let's meet the key players in our serial communication setup:

1. **Raspberry Pi Pico WH** 🥧
This little powerhouse is our brain! It's a versatile microcontroller with built-in UART capabilities, making it perfect for serial communication projects.

Fun fact: The 'WH' stands for 'with headers' - it comes pre-soldered for easy use! 🔌

2. **Analytical Balance** ⚖️
We're using the A&D HR-100A, a high-precision scale that can measure up to 102g with an accuracy of 0.0001g!

Did you know? This balance is so sensitive it can detect the weight of a fingerprint! 👆💨

3. **RS232 to TTL Converter** 🔄
This is our translator! It converts the RS232 signals from the balance to the 3.3V logic that our Pico understands.

Imagine it as a language interpreter between the balance and the Pico! 🗣️🔊

### Bill of Materials
- [Raspberry Pi Pico WH](https://www.raspberrypi.com/products/raspberry-pi-pico/?variant=raspberry-pi-pico-wh)
- [USB-A to micro USB-B cable](https://www.digikey.ca/en/products/detail/stewart-connector/SC-2AMK003F/8544577)
Expand All @@ -20,17 +41,44 @@ Design and execute software to read data from a mass balance using serial commun
- [Electrical wire (3 feet, black)](https://www.digikey.ca/en/products/detail/cnc-tech/10981-18-1-2000-001-1-TD/17799168)
- [Mini flathead screwdriver set](https://www.amazon.ca/dp/B08QCT9NHY/) (one for DC Motor driver terminals and a smaller one for PiCowbell terminals)

The Raspberry Pi Pico WH is a versatile microcontroller that's ideal for this project due to its built-in UART (Universal Asynchronous Receiver/Transmitter) capabilities. The RS232 to TTL converter is crucial as it translates the voltage levels between the RS232 standard (used by many scientific instruments) and the 3.3V logic used by the Pico.

### Why This Matters 🤔

Understanding serial communication opens up a world of possibilities:

- 🔬 In labs, it allows precise data collection from various instruments.
- 🏭 In industry, it enables monitoring and control of complex machinery.
- 🤖 In robotics, it facilitates communication between different parts of a system.

### Real-World Applications 🌍

1. **Pharmaceutical Research** 💊
Serial communication is crucial in drug development for precise measurement and data logging.

2. **Environmental Monitoring** 🌱
Weather stations use serial communication to collect and transmit data from various sensors.

3. **Manufacturing Quality Control** 🏭
Production lines use serial communication for real-time monitoring of product weights and dimensions.

### Demo

✅ Read [HR Analytical Balance Literature](https://weighing.andonline.com/sites/default/files/documents/HR-A_HR-AZ%20Lit_web.pdf)

This document provides an overview of the analytical balance we'll be interfacing with. Understanding the capabilities and specifications of the instrument is crucial for effective integration.

✅ Skim [HR Analytical Balance Manual](https://weighing.andonline.com/sites/default/files/documents/HR-A_HR-AZ_Manual.pdf). Read Sections 15 and 17 closely.

Sections 15 and 17 detail the RS232C interface and the commands used to communicate with the balance. This information is essential for programming our microcontroller to interact with the balance correctly.

✅ Read [this RS232 ChatGPT transcript](https://chatgpt.com/share/eb858762-b80f-4a4d-bd12-0a4a47f116f9)

This transcript provides additional context and explanations about RS232 communication, helping to reinforce your understanding of the concepts.

✅ Read about [code for Adafruit RS232 Pal](https://learn.adafruit.com/adafruit-rs232-pal/circuitpython-and-python) (note, this is for CircuitPython and Python, not MicroPython, so it's informative only)

While not directly applicable to our MicroPython setup, this resource provides valuable insights into how serial communication is implemented in Python environments.

Run the following code on your microcontroller:

Expand All @@ -54,31 +102,49 @@ while True:
utime.sleep(1)
```

This code demonstrates how to initialize the UART, send a command to the balance, and continuously read data. The "Q" command typically requests the current weight reading from the balance. The continuous loop allows for real-time monitoring of the balance's output.

Understanding this code is crucial as it forms the foundation for more complex data acquisition and control systems in laboratory automation. You might extend this code to log data over time, trigger actions based on weight thresholds, or integrate with other instruments in a larger experimental setup.

### Expanding Horizons 🚀

Once you master this, you can:
- 📊 Create data logging systems for long-term experiments.
- 🚨 Set up alert systems for when weights go above or below certain thresholds.
- 🤖 Integrate weight data into larger automated systems, like robotic material handlers.

## 🚀 Quiz

::::{tab-set}
:sync-group: category

:::{tab-item} W 2024
:sync: w2024

:::

:::{tab-item} Sp/Su 2024
:sync: sp2024

https://q.utoronto.ca/courses/370069/assignments/1393645
https://q.utoronto.ca/courses/370069/assignments/1393645?display=full_width
:::

::::


## 📄 Assignment

Create a script that requests the weight data continuously for 5 seconds, requests the stabilized weight, and then re-zeros the scale (i.e., similar to what might happen if it were to be synchronized with a peristaltic pump calibration).

::::{tab-set}
:sync-group: category

:::{tab-item} W 2024
:sync: w2024

:::

:::{tab-item} Sp/Su 2024
:sync: sp2024

[URL]
https://q.utoronto.ca/courses/370069/assignments/1397943?display=full_width
:::

::::
Loading

0 comments on commit a01706a

Please sign in to comment.