1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-07-23 14:41:25 +00:00

Added Struct for load cells

This commit is contained in:
Matthew Robinaugh
2021-11-08 15:37:56 -07:00
parent 3eb9369371
commit 541d7f4281
5 changed files with 67 additions and 17 deletions

43
include/LoadCells.h Normal file
View File

@@ -0,0 +1,43 @@
struct LoadCells {
HX711 loadcell_0;
HX711 loadcell_1;
HX711 loadcell_2;
HX711 loadcell_3;
double lc0Value;
double lc1Value;
double lc2Value;
double lc3Value;
double lc0Calibration;
double lc1Calibration;
double lc2Calibration;
double lc3Calibration;
};
void init_LoadCells(LoadCells &loadCells) {
const int lc_clock = 23;
const int lc_data_0 = 0;
const int lc_data_1 = 1;
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
// Configure clock pin with high impedance to protect pin (if this doesn't
// work, change to OUTPUT)
pinMode(lc_clock, INPUT);
// Configure load cell data pins as inputs
pinMode(lc_data_0, INPUT);
pinMode(lc_data_1, INPUT);
pinMode(lc_data_2, INPUT);
pinMode(lc_data_3, INPUT);
loadCells.lc0Calibration = loadCellCalibrate(loadcell_0);
loadCells.lc1Calibration = loadCellCalibrate(loadcell_1);
loadCells.lc2Calibration = loadCellCalibrate(loadcell_2);
loadCells.lc3Calibration = loadCellCalibrate(loadcell_3);
}

View File

@@ -1,22 +1,20 @@
#include "Vehicle.h"
#include <Arduino.h>
void thrustInfo(struct Vehicle &);
void processTVC(struct Vehicle &);
void write2CSV(struct outVector &, struct Vehicle &);
void printSimResults(struct Vehicle &);
double loadCellCalibrate();
double loadCellCalibrate(struct LoadCells &);
double loadCellCalibrate() {
double loadCellCalibrate(LoadCells &loadCells) {
// place code to calibrate load cells in here
double loadTotal;
double loadTotal = 0.0;
for (double t = 0; t == 10; ++t) {
loadTotal += 1;
loadTotal += loadCell.read();
delay(15);
}
return loadTotal / 10;
return loadTotal / 10.0;
}
void thrustInfo(Vehicle &State) {