Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ijager committed Jan 28, 2020
1 parent b48681d commit da8435f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 32 deletions.
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```

16 changes: 2 additions & 14 deletions app/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,28 +72,18 @@ 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()
average_acceleration = np.mean(accel_polyfit)

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()
Expand Down
4 changes: 2 additions & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions app/settings.py
Original file line number Diff line number Diff line change
@@ -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/"

Expand Down
10 changes: 1 addition & 9 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit da8435f

Please sign in to comment.