Skip to content

Commit

Permalink
changed adc calculations to use Vin reference
Browse files Browse the repository at this point in the history
  • Loading branch information
pyr0ball committed Jun 11, 2019
1 parent 7f1985d commit 4b2186a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_functions.cpp
Expand Up @@ -220,15 +220,15 @@ void updateGainFactor() {

void updateVComp() {
if (serialInt >= 0) {
compInt = (serialFloat / 5) * 1024;
compInt = (serialFloat * 1024) / Vin;
//senseInt = compInt; // syncing these params til #24 is fixed
}
}
/*------------------------------------------------*/

void updateVAdj() {
if (serialInt >= 0) {
senseInt = (serialFloat / 5) * 1024;
senseInt = (serialFloat * 1024) / Vin;
//compInt = senseInt; // syncing these params til #24 is fixed
}
}
Expand Down
4 changes: 2 additions & 2 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h
Expand Up @@ -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
Expand Down

0 comments on commit 4b2186a

Please sign in to comment.