aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2019-11-16 03:24:16 -0500
committerFranklin Wei <franklin@rockbox.org>2019-11-16 03:24:16 -0500
commit83bb4e1f2ac84ebf81d10a40fe51a336c345312b (patch)
treeab573b2a3f23a18296f42e0e72396539bdab2ec1
parent3760535d8b9e842ca46e3e1a53b0953032f741b1 (diff)
downloadregentester-83bb4e1f2ac84ebf81d10a40fe51a336c345312b.zip
regentester-83bb4e1f2ac84ebf81d10a40fe51a336c345312b.tar.gz
regentester-83bb4e1f2ac84ebf81d10a40fe51a336c345312b.tar.bz2
regentester-83bb4e1f2ac84ebf81d10a40fe51a336c345312b.tar.xz
Some work on tachometer and current input
-rw-r--r--main/main.ino7
-rwxr-xr-xtools/controller.py18
-rwxr-xr-xtools/tachometer.py17
3 files changed, 32 insertions, 10 deletions
diff --git a/main/main.ino b/main/main.ino
index 57ba737..2bf87a2 100644
--- a/main/main.ino
+++ b/main/main.ino
@@ -2,7 +2,7 @@
void setup() {
// put your setup code here, to run once:
- Serial.begin(9600);
+ Serial.begin(19200);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
@@ -20,7 +20,7 @@ void setup() {
#define LAST_STATE 4
int state = LAST_STATE - 1; // begin with acceleration
-int state_times[] = { 4000, 100, 2000, 500 };
+int state_times[] = { 20000, 250, 5000, 250 };
unsigned long next_state_time = 0;
const int CURRENT_OUT_SENSOR = A0;
@@ -35,8 +35,11 @@ void loop() {
float current = (mV - OFFSET) / mVPerAmp;
Serial.println(current, 3);
+ //if(Serial.available() > 0)
if(time > next_state_time)
{
+ // while(Serial.available() > 0)
+ // Serial.read();
// advance state
state++;
state %= LAST_STATE;
diff --git a/tools/controller.py b/tools/controller.py
new file mode 100755
index 0000000..0bc1f73
--- /dev/null
+++ b/tools/controller.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+"""
+All-in-one controller program for regen test stand.
+
+Handles motor control, tachometer, and current integration.
+"""
+
+import serial
+import time
+
+PORT='/dev/ttyACM0'
+BAUD=19200
+
+ard = serial.Serial(PORT, BAUD, timeout=5)
+
+while True:
+ current = ard.readline()
+ print(current.decode('UTF-8'))
diff --git a/tools/tachometer.py b/tools/tachometer.py
index 84a5878..5010b94 100755
--- a/tools/tachometer.py
+++ b/tools/tachometer.py
@@ -51,14 +51,14 @@ WIDTH=640
HEIGHT=480
# number of stripes on wheel
-TICS_PER_REV = 2
+TICS_PER_REV = 1
# desired RPM range
-RPM_LOW = 12
+RPM_LOW = 25
RPM_HIGH = 180
# RPMs below this get mapped to zero
-ZERO_RPM_THRES = 10
+ZERO_RPM_THRES = 15
def update_plot(ax, fig, x, y):
@@ -111,10 +111,10 @@ def getRPM(x_data, y_data, ax, fig):
hi = get_first_higher(freq, RPM_HIGH / 60 * TICS_PER_REV)
actual_rate = nsamples / delta_t
- #print("Actual FPS: ", actual_rate, "Nyquist max RPM: ", actual_rate / TICS_PER_REV / 2 * 60)
- #print("Window length: ", delta_t)
- #print("Filtered RPM range:", freq[lo]*60 / TICS_PER_REV, freq[hi - 1]*60 / TICS_PER_REV)
- #print("Maximum RPM range:", freq[0] * 60 / TICS_PER_REV, freq[-1] * 60 / TICS_PER_REV)
+ print("Actual FPS: ", actual_rate, "Nyquist max RPM: ", actual_rate / TICS_PER_REV / 2 * 60)
+ print("Window length: ", delta_t)
+ print("Filtered RPM range:", freq[lo]*60 / TICS_PER_REV, freq[hi - 1]*60 / TICS_PER_REV)
+ print("Maximum RPM range:", freq[0] * 60 / TICS_PER_REV, freq[-1] * 60 / TICS_PER_REV)
# bandpass filter
freq = freq[lo:hi]
@@ -195,7 +195,8 @@ def main():
x_data.pop(0)
y_data.pop(0)
- update_plot(ax_brt, fig_brt, x_data, y_data)
+
+ #update_plot(ax_brt, fig_brt, x_data, y_data)
if len(x_data) >= WINDOW:
rpm = getRPM(x_data, y_data, ax_fft, fig_fft)