From 1ec624cc55abbb4911800c658af855827bcb4f22 Mon Sep 17 00:00:00 2001 From: Matthew Robinaugh Date: Wed, 10 Nov 2021 14:36:31 -0700 Subject: [PATCH] Update to load cell calibration and initialize lc --- include/LoadCells.h | 8 ++++++-- include/teensy.h | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/LoadCells.h b/include/LoadCells.h index 5150db6..abcaf2d 100644 --- a/include/LoadCells.h +++ b/include/LoadCells.h @@ -25,8 +25,7 @@ void init_LoadCells(LoadCells &loadCells) { const int lc_data_2 = 2; const int lc_data_3 = 3; - Serial.begin(9600); // Begin serial connection - pinMode(LED_BUILTIN, OUTPUT); // Configure LED pin + Serial.begin(9600); // Configure clock pin with high impedance to protect pin (if this doesn't // work, change to OUTPUT) pinMode(lc_clock, INPUT); @@ -36,6 +35,11 @@ void init_LoadCells(LoadCells &loadCells) { pinMode(lc_data_2, INPUT); pinMode(lc_data_3, INPUT); + loadcell_0.begin(lc_data_0, lc_clock); + loadcell_1.begin(lc_data_1, lc_clock); + loadcell_2.begin(lc_data_2, lc_clock); + loadcell_3.begin(lc_data_3, lc_clock); + loadCells.lc0Calibration = loadCellCalibrate(loadcell_0); loadCells.lc1Calibration = loadCellCalibrate(loadcell_1); loadCells.lc2Calibration = loadCellCalibrate(loadcell_2); diff --git a/include/teensy.h b/include/teensy.h index 4f6f64e..489c375 100644 --- a/include/teensy.h +++ b/include/teensy.h @@ -1,13 +1,14 @@ #include "Vehicle.h" +#include "LoadCells.h" void thrustInfo(struct Vehicle &); -void processTVC(struct Vehicle &); +void processTVC(struct LoadCells &); void write2CSV(struct outVector &, struct Vehicle &); void printSimResults(struct Vehicle &); -double loadCellCalibrate(struct LoadCells &); +double loadCellCalibrate(HX711 loadCell); -double loadCellCalibrate(LoadCells &loadCells) { +double loadCellCalibrate(HX711 loadCell) { // place code to calibrate load cells in here double loadTotal = 0.0; for (double t = 0; t == 10; ++t) { @@ -59,7 +60,7 @@ void thrustInfo(Vehicle &State) { } } -void processTVC(Vehicle &State) { +void processTVC(LoadCells &loadCells) { if (State.time == 0) { Serial.println("WARNING: processTVC not implemented for TEENSY"); }