Read-Sensor-Resistances/README.md

86 lines
5.9 KiB
Markdown
Raw Normal View History

2022-05-19 06:19:37 +00:00
# Read Resistances
2023-03-04 05:37:01 +00:00
2023-02-07 06:57:05 +00:00
Read the resistance of a voltage divider using Arduino boards
2022-05-19 06:19:37 +00:00
2023-04-07 03:05:38 +00:00
## TL:DR - Use [this tutorial video](https://www.dropbox.com/s/4md0r53srni589v/tut0.mp4?dl=0) to get yourself setup for development.
2022-05-19 06:19:37 +00:00
## Required & Dependencies
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
### Required
2023-03-04 05:37:01 +00:00
- Python 3 (but below 3.10). And the following packages using `pip`. Alternatively, you can just switch the file source of the Command line Prompt by using 'cd <Project_File_Directory>' and after that, run `pip install -r requirements.txt` in to have all packages installed automatically
2022-05-19 06:19:37 +00:00
- matplotlib
- pyserial
2023-03-04 05:37:01 +00:00
- wxPython
- [Arduino ](https://github.com/microsoft/vscode-arduino)extension, if you use VSCode for embedded programmings
2023-02-07 06:57:05 +00:00
- An Arduino-based microcontroller
- ADS1115 16-bit ADC chip
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
### Recommended
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
- Code Runner (for VSCode only)
2023-03-04 05:37:01 +00:00
- [vscode-arduino](https://github.com/microsoft/vscode-arduino) (for VSCode only)
2022-05-19 06:19:37 +00:00
- wxFormBuilder
2022-05-20 20:22:43 +00:00
- [Arduino IDE](https://makeabilitylab.github.io/physcomp/arduino/arduino-ide.html)
2022-05-19 06:19:37 +00:00
## How to use
2023-03-04 05:37:01 +00:00
2023-02-07 06:57:05 +00:00
To get a general idea of this project as well as hardware setup, please refer to [this video demo](https://youtu.be/vbVPXj8gbmI)
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
### Direct use
2023-03-04 05:37:01 +00:00
First open the `.ino` file from `nano_c_mk1` directory using Arduino IDE and download it onto an Arduino board. Alternatively, you can use the arduino extension on VSCode to download it into your boards and run the interface python code. ~~Or if you are using Arduino Mega 2560 you can
use the code in `ReadAnalog` folder by open the folder in VSCode and run with PlatformIO, or just run `flash.py` in a terminal~~
2023-02-07 06:57:05 +00:00
~~(Arduino Mega and Uno boards are no longer supported. Please use [this link](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html) to
2023-03-04 05:37:01 +00:00
use on Arduino IDE or PlatformIO for VSCode)~~ (There's a hardware upgrade so that the firmware has been re-written for the new hardware. You can checkout the 'esp32' branch or the old stuff)
2023-02-07 07:11:10 +00:00
For Windows you can just [download the released executable](https://github.com/Seal-Ammonia/Read-Sensor-Resistances/releases/download/beta1_1_1/SeeDatResistance.exe) from the release section to use. Make sure to disable any virus-scanning software when download as Microsoft incorrectly recognized PyInstaller as virus. For non-Windows systems you can just run `python test.py` and start from the UI. Enter the relevant information and start collect and measuring data. If you do not have a board avaliable, leave the dropdown menu in the UI as "no device" and it will run a simulation.
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
### develop & build
2023-03-04 05:37:01 +00:00
2023-03-04 20:53:23 +00:00
For windows, assuming you are not using Anaconda's python (cuz pyinstaller will not include some of the DLL's for conda with this method), you may use the pseudo Makefile `make.bat` to build a python environment for the front end codes. Call `make run` to run the program. And `make clean` to delet all local temporary files and environment files before you make any commit. We recomment to use VSCode to do both interface and firmware development.
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
Beside the c-based code for the Arduino board to read raw data from the board, everything has now been done in the python
files. The main program is `test.py`, which calls `UI.py` to prompt for input. It is NOT recommended modifying the `ui.py`
2022-05-19 06:19:37 +00:00
as it is generated from wxFormBuilder from `sealammonia.fbp`, which could be modified if any frontend feature need to change.
the main program will generate `settings.json` which saves all required parameters needed to calculate and graph and save the
2023-03-04 05:37:01 +00:00
sensor's values. It also creates a .csv file under `RecordedData` directory to save all recorded+calculated data.
`read_arduino.py` read raw data from Arduino board and convert it to the correct resistance, which could be plotted out
2023-02-07 06:57:05 +00:00
using `serial_plotter.py`. To make your own executable, use `PyInstaller` using this command in your python environment:
`pyinstaller build.spec`.
2023-03-04 05:37:01 +00:00
2022-10-31 08:22:56 +00:00
ATTENTION MAC USER: currently the software cannot correctly functional on mac (especially arm-based ones). You might need to consider to use it on a windows VM or using parallel desktop
2022-05-19 06:19:37 +00:00
## Issues
2023-03-04 05:37:01 +00:00
- Newer hardware will require 3.3V. ~~Currently can only use 5V as input voltage.~~ May need to change the algorithm in `read_arduino.py`.
2022-08-08 22:51:36 +00:00
- axis window size is not correct
2023-02-07 06:57:05 +00:00
- on PyInstaller, windows misdetected our executable as a virus (seems resolved)
2022-10-16 19:14:23 +00:00
- change the scale on Y-axis so that graph looks smoother
2023-02-07 06:57:05 +00:00
- ~~Errors thrown when >1 reference resistances entered~~
2022-05-19 06:19:37 +00:00
2023-02-07 06:57:05 +00:00
## Todos:
2023-03-04 05:37:01 +00:00
2022-05-19 06:19:37 +00:00
- [ ] Fix Issues
2023-03-04 05:37:01 +00:00
- [ ] Add an option to change the font size of the graph
2023-02-15 23:20:56 +00:00
- [ ] Add different shapes to different lines one the graph in addition to differen colors
2022-10-31 08:19:38 +00:00
- [ ] programically to stablize the graph (change the y-scale of the graph to make the less dramatic)
2023-02-07 06:57:05 +00:00
- [ ] (not urgent) make it runnable on Mac
2023-03-04 05:37:01 +00:00
- [X] display sensor value in either the UI or on the plot
- [X] Reopen plot window from the UI when closed
- [X] Need to continue writing to file when graphing window is closed
- [X] Make it so the time stamp is the actual time
- [X] No blank line in between lines of csv file (new line may be added when file is closed)
2022-05-19 06:19:37 +00:00
- [ ] Make it so we have the option to run multiple graphs at the same time, setting window size in UI
2023-03-04 05:37:01 +00:00
- [X] Inputting value of 0 for window size should have an infinite window size
- [X] Accept any inputs (such as resistor values, plot window size, base voltage etc.) as either command line argument or as input at beginning of program
- [X] Write random values to simulate a sensor if no sensor available (this feature might be removed in the future)
- [X] Advanced option menu in the UI to allow user to make more adjustments
2023-02-07 06:57:05 +00:00
- [X] Add resolution option in the UI to allow interchange between arduino (10bit) and esp32 (12 bits) (Not Applicable in new hardware)
2023-03-04 05:37:01 +00:00
- ~~ Possibly adding new module to support ESP32~~
- [ ] Support for non-Windows platforms (and maybe mobile)
2022-06-26 19:55:40 +00:00
- [ ] Make it into one executable
2023-02-07 06:57:05 +00:00
- [ ] Possibly adding new module to support Arduino MEGA and older firmwares (Need testing)
2023-02-15 23:25:55 +00:00
- [ ] (optional for now) make the hardware connection to the interface wireless