Skip to content

Commit 62b7d01

Browse files
Updated main and library list to run on Mac OS (#128)
* Run on developer's Ubuntu computer and updated README (#1) * Start of running TankController on Ubuntu * Update run_gui.sh * Fixing gui to run on mac os * Fixing a few issues
1 parent cd38c9d commit 62b7d01

8 files changed

Lines changed: 460 additions & 475 deletions

File tree

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ adafruit-circuitpython-lis3dh = "*"
1919
adafruit-circuitpython-max31865 = "*"
2020
gpiozero = "*"
2121
pandas = "*"
22-
"rpi.gpio" = "*"
2322
click = "*"
2423
adafruit-ads1x15 = "*"
2524
exceptiongroup = "*"
2625
numpy = "*"
26+
adafruit-blinka = "*"

Pipfile.lock

Lines changed: 424 additions & 384 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 17 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,40 @@
1-
# Alkalinity Titrator Project
1+
# Tank Controller in Python
22

33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
44
[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
55
<!-- ALL-CONTRIBUTORS-BADGE:END -->
66

7-
## Project motivations
87

9-
As CO2 levels increase, the ocean absorbs more CO2 and becomes more acidic. There currently exists a large deficit of data on how this affects wildlife. Alkalinity Titrators are needed for ocean acidification research​. Currently, available models are expensive ($10,000-$25,000)​. Models on the lower end of the price range are not automated and are therefore time intensive.
8+
## Project Motivations
109

11-
This project aims to make ocean acidification research more widely available by lowering the cost of alkalinity titrators.
10+
Update the `TankController` code from C++ to Python and run on a Raspberry Pico.
1211

13-
The problems that the alkalinity-titrator seek to fix are as follows:
1412

15-
- Lower the cost of ocean science equipment by using inexpensive, widely-available parts
16-
- To automate the titration process, saving time and effort when determining total alkalinity
13+
## Requirements
1714

18-
The titration process used in this project is based on SOP 3b from
15+
The system should have Python and pipenv.
16+
The development version also needs Tkinter which can be found in python3-tk for Ubuntu.
1917

20-
```Christian, James Robert, Andrew G. Dickson, and Christopher L. Sabine. Guide to Best Practices for Ocean CO2 Measurements. Sidney, B.C.: North Pacific Marine Science Organization, 2007.```
18+
## Developer Instructions
2119

22-
## Current Development Note
23-
24-
The most recent development in this project is the implementation of a UI State Machine framework (see the titration/utils/UIState folder for UI states implemented). While the UI State Machine framework has been fully implemented, the actual titration processes and routines have not been integrated with the UI State Machine (see GitHub Issues for further specifications).
25-
26-
## Setup and Installation
27-
28-
### Setting up the Raspberry Pi
29-
30-
Refer to <https://desertbot.io/blog/headless-raspberry-pi-3-bplus-ssh-wifi-setup> for instructions on setting up the raspberry pi (note: headless setup is not required if a keyboard and monitor are available). Raspbian lite has everything needed, but the desktop version can be downloaded if working with a GUI is preferable.
31-
32-
### Installing software
33-
34-
Run standard updates on the pi:
35-
36-
``` sh
37-
sudo apt-get update
38-
sudo apt-get upgrade
39-
```
40-
41-
This project utilizes SPI and I2C protocols, both of which often come disabled on the pi. To enable them, run:
42-
43-
``` sh
44-
sudo raspi-config
45-
```
46-
47-
and navigate to "Interfacing Options"; enable both SPI and I2C.
48-
49-
Install git:
50-
51-
``` sh
52-
sudo apt-get install git
53-
```
54-
55-
Clone alkalinity titrator repository to the pi
56-
57-
``` sh
58-
git clone https://github.com/Open-Acidification/alkalinity-titrator.git
59-
```
20+
### Run in Local Environment
6021

61-
Run installation script
22+
To run in a local environment with mocked devices (with the UI State Machine integrated)
6223

6324
``` sh
64-
sudo ./install.sh
25+
./run_gui.sh
6526
```
66-
## User Instructions
6727

68-
### Run on Device
69-
70-
To run (with the UI State Machine integrated)
71-
72-
``` sh
73-
./run.sh
74-
```
28+
### Update Python Virtual Environment
7529

76-
### Run in Local Environment
30+
Run `pipenv install` in the terminal to get the latest dependencies and update the lockfile.
7731

78-
To run in a local environment with mocked devices (with the UI State Machine integrated)
32+
### Virtual Environment
7933

80-
``` sh
81-
./run_mocked.sh
34+
```sh
35+
python3 -m venv .venv
36+
source .venv/bin/activate
37+
pip3 install --user pipenv
8238
```
8339

8440
## Testing
@@ -89,29 +45,6 @@ To perform Pytest tests for the devices and UI states.
8945
./test.sh
9046
```
9147

92-
## Pins
93-
94-
### Temperature probe ([MAX31865 breakout board](https://learn.adafruit.com/adafruit-max31865-rtd-pt100-amplifier/python-circuitpython))
95-
96-
- PIN 1 (3.3v) to sensor VIN
97-
- PIN 9 to sensor GND
98-
- PIN 19/BCM 10 to sensor SDI
99-
- PIN 21/BCM 21 to sensor SDO
100-
- PIN 23/BCM 23 to sensor CLK
101-
- PIN 29/BCM 5 to sensor CS (or use any other free GPIO pin)
102-
103-
### pH probe ([ADS1115 analog converter](https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/python-circuitpython))
104-
105-
- PIN 17 (3.3v) to ADS1115 VDD - Remember the maximum input voltage to any ADC channel cannot exceed this VDD 3V value!
106-
- PIN 6 to ADS1115 GND
107-
- PIN 5/BCM 3 SCL to ADS1115 SCL
108-
- PIN 3/BCM 2 to ADS1115 SDA
109-
110-
## Libraries
111-
112-
1. Circuit Python - <https://github.com/adafruit/Adafruit_CircuitPython_MAX31865>
113-
<br>
114-
Used for communicating with the PT1000
11548

11649
## Contributors ✨
11750

install.sh renamed to device_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ apt-get update # To get the latest package lists
33
apt-get upgrade
44
apt install pipenv -y # pipenv virtual environment
55
apt-get install rpi.gpio
6-
pipenv install
6+
pipenv sync

run.sh

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2+
pipenv sync
23
pipenv run python main.py

run_gui.sh

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2-
pipenv run python main.py -gui
2+
pipenv sync -d
3+
pipenv run python main.py -gui

test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2+
pipenv sync -d
23
pipenv run pytest -vv

titration/titrator_driver.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,24 @@ def run():
1515
titrator = Titrator()
1616

1717
if mock_config.MOCK_ENABLED:
18-
thread = threading.Thread(target=run_gui, args=[titrator], daemon=True)
18+
# Run titrator loop in a background thread, GUI on main thread
19+
thread = threading.Thread(target=run_loop(titrator), daemon=True)
1920
thread.start()
20-
21-
while True:
22-
titrator.loop()
21+
run_gui(titrator)
22+
else:
23+
run_loop(titrator)
2324

2425

2526
def run_gui(titrator):
2627
"""
2728
The function that drives the Alkalinity Titrator's GUI
2829
"""
2930
GUI(titrator)
31+
32+
33+
def run_loop(titrator):
34+
"""
35+
The function that drives the Alkalinity Titrator's loop
36+
"""
37+
while True:
38+
titrator.loop()

0 commit comments

Comments
 (0)