changed adc calculations to use Vin reference

This commit is contained in:
pyr0ball 2019-06-11 13:08:29 -07:00
parent 7f1985d0cd
commit 4b2186aaf7
2 changed files with 4 additions and 4 deletions

View file

@ -220,7 +220,7 @@ void updateGainFactor() {
void updateVComp() { void updateVComp() {
if (serialInt >= 0) { if (serialInt >= 0) {
compInt = (serialFloat / 5) * 1024; compInt = (serialFloat * 1024) / Vin;
//senseInt = compInt; // syncing these params til #24 is fixed //senseInt = compInt; // syncing these params til #24 is fixed
} }
} }
@ -228,7 +228,7 @@ void updateVComp() {
void updateVAdj() { void updateVAdj() {
if (serialInt >= 0) { if (serialInt >= 0) {
senseInt = (serialFloat / 5) * 1024; senseInt = (serialFloat * 1024) / Vin;
//compInt = senseInt; // syncing these params til #24 is fixed //compInt = senseInt; // syncing these params til #24 is fixed
} }
} }

View file

@ -5,8 +5,8 @@ volatile int ADJ_COMP = 0; // Variable for Comparator adjustment
volatile int ERR_STATE = 0; volatile int ERR_STATE = 0;
// Convert float to integer for adjustment functions // Convert float to integer for adjustment functions
int senseInt = (senseThrs / 5) * 1024; // Voltage Follower upper converted to adg interger int senseInt = (senseThrs * 1024) / Vin; // Voltage Follower upper converted to adg interger
int compInt = (compThrs / 5) * 1024; // Upper threshold of Comparator before adjustment int compInt = (compThrs * 1024) / Vin; // Upper threshold of Comparator before adjustment
// Voltage Comparator Adjustment parameters // Voltage Comparator Adjustment parameters
//float VCompRef = 0.00; // variable to store the float value read from the comparator reference //float VCompRef = 0.00; // variable to store the float value read from the comparator reference