Skip to content
Snippets Groups Projects
Commit f771bea8 authored by Lennard's avatar Lennard
Browse files

Small updates

parent 431e9356
No related branches found
No related tags found
No related merge requests found
...@@ -7,13 +7,13 @@ DataLogger: ...@@ -7,13 +7,13 @@ DataLogger:
InfoLogger: InfoLogger:
backupCount: 10 # number of logs to keep backupCount: 10 # number of logs to keep
maxBytes: 1000000 # size of single log maxBytes: 1000000 # size of single log in bytes
filename: log # filename for logs filename: log # filename for logs
levels: # log level for outputting to file and to stdout respectivly levels: # log level for outputting to file and to stdout respectivly
- INFO - INFO
- WARNING - WARNING
Data: Data:
factors: [1, 1, 1, 0.9] # factors for the 4 dms factors: [1, 1, 1, 1] # factors for the 4 dms
delta_time: 30 # time between logging data delta_time: 30 # time between logging data
smoothing: false # wether to smoothe the logged data smoothing: false # whether to smoothe the logged data
...@@ -77,8 +77,8 @@ def get_offset() -> np.ndarray: ...@@ -77,8 +77,8 @@ def get_offset() -> np.ndarray:
f"Time difference between last logged value and current time is very large: {difference.total_seconds():.0f}s." f"Time difference between last logged value and current time is very large: {difference.total_seconds():.0f}s."
) )
return np.array([float(num) for num in lines[-1].split(",")[1:5]]) return np.array([float(num) for num in lines[-1].split(",")[1:5]])
# didnt find any old files, so no offset # didn't find any old files, so no offset
logger.warning(f"Didnt find any old offsets, so starting at 0.") logger.warning(f"Didn't find any old offsets, so starting at 0.")
return np.array([0, 0, 0, 0]) return np.array([0, 0, 0, 0])
......
...@@ -7,13 +7,18 @@ core=arduino:avr ...@@ -7,13 +7,18 @@ core=arduino:avr
id=$(python3 ../scripts/serial_id.py) id=$(python3 ../scripts/serial_id.py)
if [[ $id != "0" ]] if [[ $id == "1" ]]
then then
serial_dms=/dev/ttyACM0 serial_dms=/dev/ttyACM0
serial_temp=/dev/ttyACM1 serial_temp=/dev/ttyACM1
else elif [[ $id == "0" ]]
then
serial_temp=/dev/ttyACM0 serial_temp=/dev/ttyACM0
serial_dms=/dev/ttyACM1 serial_dms=/dev/ttyACM1
else
echo -e "\x1b[31mError: Something went wrong.\x1b[0m"
echo -e "Exiting"
exit 1
fi fi
echo -e "Info: DMS arduino: $serial_dms, Temp arduino: $serial_temp" echo -e "Info: DMS arduino: $serial_dms, Temp arduino: $serial_temp"
...@@ -25,7 +30,7 @@ connected_devices=$(echo -e $device_list | grep "^\(\($serial_dms\)\|\($serial_t ...@@ -25,7 +30,7 @@ connected_devices=$(echo -e $device_list | grep "^\(\($serial_dms\)\|\($serial_t
if [[ $connected_devices != "2" ]] if [[ $connected_devices != "2" ]]
then then
echo -e "\x1b[31mError: not all arduino devices are connected\x1b[0m" echo -e "\x1b[31mError: not all arduino devices are connected,\x1b[0m"
echo -e "Connected devices are:\n$device_list" echo -e "Connected devices are:\n$device_list"
echo -e "Exiting." echo -e "Exiting."
exit 1 exit 1
......
#include <HX711_ADC.h> #include <HX711_ADC.h>
#include "cstring"
HX711_ADC loadCells[] = {HX711_ADC(2, 3), HX711_ADC(6, 7), HX711_ADC(8, 9), HX711_ADC(12, 13)}; HX711_ADC loadCells[] = {HX711_ADC(2, 3), HX711_ADC(6, 7), HX711_ADC(8, 9), HX711_ADC(12, 13)};
float measurements[4]; float measurements[4];
float offsets[4]; float offsets[4];
int count = 1000; int count = 100;
long stabilization = 2000; long stabilization = 2000;
void readData() { void readData() {
// write the averaged data over 'count' measurements into 'measurements'.
std::memset(measurements, 0, sizeof measurements); // zero out measurements
for (int i = 0; i < count; i++) {
for (int j = 0; j < sizeof(loadCells) / sizeof(*loadCells); j++) {
loadCells[j].update();
measurements[j] += loadCells[j].getRareData() - offsets[j];
}
}
for (int i = 0; i < sizeof(loadCells) / sizeof(*loadCells); i++) { for (int i = 0; i < sizeof(loadCells) / sizeof(*loadCells); i++) {
loadCells[i].update(); measurements[i] /= count;
measurements[i] = loadCells[i].getRareData() - offsets[i];
} }
} }
...@@ -21,12 +32,11 @@ void setup() { ...@@ -21,12 +32,11 @@ void setup() {
loadCells[i].begin(); loadCells[i].begin();
loadCells[i].start(stabilization, true); loadCells[i].start(stabilization, true);
}
loadCells[i].update();
// zero out load cells // zero out load cells
offsets[i] = loadCells[i].getRareData(); readData();
} std::memcpy(offsets, measurements, sizeof offsets);
} }
void loop() { void loop() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment