diff --git a/README.md b/README.md index 11fbbda..b5396c8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,39 @@ -# Piano Force Sensor Project +# Piano Sensor Project -- electronic design -- firmware +- Electronic design +- Firmware written in Rust for stm32f103 +- Python app for data visualization + + +## Electronic Design + +This repo contains the following KiCad projects + +* encoder-breakout is the breakout pcb for the AEDR-8300 optical encoder IC +* main-board is a daisychainable board that connects to five encoder-breakouts +* uart-adapter connects to the main-board and delivers power. + + +## Firmware + +There are two firmware projects + +* `firmware` was the first try. It works and decodes the encoder signals but does not have all functionality such as daisychaining. +* `firmware-rftm` is firmware based on the [`cortex-m-rtfm`](https://rtfm.rs) framework. This has all functionality and is compatible with the python app. + + +## App + +The python app lives in a Pipenv virtual environment. First time you need to run the following command to install: + +```bash +pipenv install +``` + +Then to run: + +``` +pipenv shell +python app.py +``` + diff --git a/app/analysis.py b/app/analysis.py index 9640323..1483176 100644 --- a/app/analysis.py +++ b/app/analysis.py @@ -5,8 +5,6 @@ from PySide2 import QtCore -from settings import DOWNWEIGHTS_g, INERTIA_g - TICKS_PER_MM = 75/25.4 * 4 record_threshold_min_mm = 3 @@ -74,11 +72,10 @@ def valid(self): def metrics(self): """ - returns rise_time, average_acceleration, force_N + returns rise_time, average_acceleration rise_time in milliseconds average_acceleration in mm/s^2 based no fitted speed - force_N in Newton based no configured downweight for the pressed key """ t, accel, accel_polyfit = self.accel_data() @@ -86,16 +83,7 @@ def metrics(self): rise_time = self.t[-1] - self.t[0] - # downweight and inertia in kg - DW = DOWNWEIGHTS_g[self.encoder - 1] / 1000 - I = INERTIA_g[self.encoder - 1] / 1000 - - # acceleration in m/s^2 - a = average_acceleration / 1000 - - force_N = (DW + (I * a)) - - return rise_time, average_acceleration, force_N + return rise_time, average_acceleration def average_fitted_acceleration(self): t, accel, accel_polyfit = self.accel_data() diff --git a/app/app.py b/app/app.py index 37113bd..4f44a06 100644 --- a/app/app.py +++ b/app/app.py @@ -26,7 +26,7 @@ def __init__(self): self.window = MainWindow() - self.window.setWindowTitle("Piano Force Sensor") + self.window.setWindowTitle("Piano Sensor") self.window.show() signal.signal(signal.SIGINT, self.window.quit) @@ -54,7 +54,7 @@ def __init__(self): self.parser.newDataSet.connect(lambda i, t, p: self.mainView.textOutputView.new_results(KeyPress(i, t,p))) status.set_status_logger(self.set_status_message) - status.set_status('Force Sensor Ready..') + status.set_status('Piano Sensor Ready..') def quit(self): self.mainView.textOutputView.quit() diff --git a/app/settings.py b/app/settings.py index 70f63bf..97062c0 100644 --- a/app/settings.py +++ b/app/settings.py @@ -1,8 +1,4 @@ -# settings per key 1 - 10 -INERTIA_g = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250] -DOWNWEIGHTS_g = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40] - # The default location the log files will be stored in LOG_DIR = "logs/" diff --git a/app/views.py b/app/views.py index 6a0edd8..d3aba51 100644 --- a/app/views.py +++ b/app/views.py @@ -75,7 +75,6 @@ def __init__(self): # self.plot.update_plot(range(5)) # self.setStyleSheet("font-weight: bold; font-size: {}px".format(24)) - self.forceResult = QtWidgets.QLabel('- N') self.accelResult = QtWidgets.QLabel('- mm/s^2') self.encoder = QtWidgets.QLabel('-') self.risetimeResult = QtWidgets.QLabel('- s') @@ -86,12 +85,6 @@ def __init__(self): valueLayout.addWidget(self.encoder) self.layout.addLayout(valueLayout) - valueLayout = QtWidgets.QHBoxLayout() - valueLayout.addWidget(QtWidgets.QLabel('Force')) - valueLayout.addWidget(self.forceResult) - - self.layout.addLayout(valueLayout) - valueLayout = QtWidgets.QHBoxLayout() valueLayout.addWidget(QtWidgets.QLabel('Acceleration')) valueLayout.addWidget(self.accelResult) @@ -111,11 +104,10 @@ def new_results(self, k: KeyPress): if k.valid(): self.encoder.setText(str(k.encoder)) self.current_keypress = k - rise_time, avg_accel, force = self.current_keypress.metrics() + rise_time, avg_accel = self.current_keypress.metrics() self.plot.show_position(self.current_keypress) self.accelResult.setText('{0:.2f} mm/s^2'.format(avg_accel)) self.risetimeResult.setText('{0:.1f} ms'.format(rise_time)) - self.forceResult.setText('{0:.2f} N'.format(force)) class MatplotlibWidget(QtWidgets.QWidget):