From 4b2186aaf71ee96594eaf6f230e06adef8cc69ec Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Tue, 11 Jun 2019 13:08:29 -0700 Subject: [PATCH] changed adc calculations to use Vin reference --- firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_functions.cpp | 4 ++-- firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_functions.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_functions.cpp index 55b1ae9..b7c7038 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_functions.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_functions.cpp @@ -220,7 +220,7 @@ void updateGainFactor() { void updateVComp() { if (serialInt >= 0) { - compInt = (serialFloat / 5) * 1024; + compInt = (serialFloat * 1024) / Vin; //senseInt = compInt; // syncing these params til #24 is fixed } } @@ -228,7 +228,7 @@ void updateVComp() { void updateVAdj() { if (serialInt >= 0) { - senseInt = (serialFloat / 5) * 1024; + senseInt = (serialFloat * 1024) / Vin; //compInt = senseInt; // syncing these params til #24 is fixed } } diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h index 26dc20c..4600f0a 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h @@ -5,8 +5,8 @@ volatile int ADJ_COMP = 0; // Variable for Comparator adjustment volatile int ERR_STATE = 0; // Convert float to integer for adjustment functions -int senseInt = (senseThrs / 5) * 1024; // Voltage Follower upper converted to adg interger -int compInt = (compThrs / 5) * 1024; // Upper threshold of Comparator before adjustment +int senseInt = (senseThrs * 1024) / Vin; // Voltage Follower upper converted to adg interger +int compInt = (compThrs * 1024) / Vin; // Upper threshold of Comparator before adjustment // Voltage Comparator Adjustment parameters //float VCompRef = 0.00; // variable to store the float value read from the comparator reference