parent
37f7d4d085
commit
4c35d52259
1 changed files with 79 additions and 94 deletions
|
|
@ -56,7 +56,16 @@ The gain STATE is representative of these values:
|
|||
4 = 11x
|
||||
*/
|
||||
|
||||
//#include <Wire.h>
|
||||
|
||||
|
||||
// Debug output toggle. Uncomment to enable
|
||||
//#define DEBUG true
|
||||
|
||||
// i2c input toggle. Uncomment to enable
|
||||
//#define I2C true
|
||||
#ifdef I2C
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
// Set variables for working parameters
|
||||
int GAIN_FACTOR = 2; // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
|
||||
|
|
@ -68,7 +77,6 @@ int TRG_DUR = 120; // duration of the Z-axis pulse sent, in ms
|
|||
int Hyst = 20; // Hysteresis value for ADC measurements
|
||||
#define Vin 5 // input reference voltage
|
||||
|
||||
|
||||
// Analog Pin Assignments
|
||||
#define V_FOLLOW_PIN A0 // Sense pin to check Voltage Follower stage
|
||||
#define VCOMP_SENSE_PIN A1 // Sense pin to check comparator stage voltage
|
||||
|
|
@ -259,7 +267,8 @@ void serialInput() {
|
|||
|
||||
/*------------------------------------------------*/
|
||||
|
||||
/* void i2cInput() {
|
||||
#ifdef I2C
|
||||
void i2cInput() {
|
||||
|
||||
// receive data from Serial and save it into inputBuffer
|
||||
|
||||
|
|
@ -269,7 +278,8 @@ void serialInput() {
|
|||
i2cReply();
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------*/
|
||||
|
||||
void identifyMarkers() {
|
||||
|
|
@ -296,8 +306,8 @@ void identifyMarkers() {
|
|||
bytesRecvd = 0;
|
||||
readInProgress = true;
|
||||
}
|
||||
|
||||
/* if (y == endMarker) {
|
||||
#ifdef I2C
|
||||
if (y == endMarker) {
|
||||
readInProgress = false;
|
||||
serialIncoming = true;
|
||||
inputBuffer[bytesRecvd] = 0;
|
||||
|
|
@ -316,7 +326,7 @@ void identifyMarkers() {
|
|||
bytesRecvd = 0;
|
||||
readInProgress = true;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
/*------------------------------------------------*/
|
||||
|
|
@ -373,44 +383,18 @@ void updateGainFactor() {
|
|||
void updateVComp() {
|
||||
if (serialInt >= 0) {
|
||||
compInt = (serialFloat / 5) * 1024;
|
||||
senseInt = compInt; // syncing these params til #24 is fixed
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------*
|
||||
|
||||
void updateVCompH() {
|
||||
if (serialInt >= 0) {
|
||||
compHighThrs = ((float)serialFloat);
|
||||
}
|
||||
}
|
||||
*------------------------------------------------*
|
||||
|
||||
void updateVCompL() {
|
||||
if (serialInt >= 0) {
|
||||
compLowThrs = ((float)serialFloat);
|
||||
}
|
||||
}
|
||||
*------------------------------------------------*/
|
||||
/*------------------------------------------------*/
|
||||
|
||||
void updateVAdj() {
|
||||
if (serialInt >= 0) {
|
||||
senseInt = (serialFloat / 5) * 1024;
|
||||
compInt = senseInt; // syncing these params til #24 is fixed
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------*
|
||||
|
||||
void updateVAdjH() {
|
||||
if (serialInt >= 0) {
|
||||
senseHighThrs = ((float)serialFloat);
|
||||
}
|
||||
}
|
||||
*------------------------------------------------*
|
||||
|
||||
void updateVAdjL() {
|
||||
if (serialInt >= 0) {
|
||||
senseLowThrs = ((float)serialFloat);
|
||||
}
|
||||
}
|
||||
*------------------------------------------------*/
|
||||
/*------------------------------------------------*/
|
||||
|
||||
void updateHysteresis() {
|
||||
if (serialInt >= 0) {
|
||||
|
|
@ -422,7 +406,7 @@ void updateHysteresis() {
|
|||
void serialReply() {
|
||||
if (serialIncoming) {
|
||||
serialIncoming = false;
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.print("Comp Reference:");
|
||||
Serial.print(VComp);
|
||||
Serial.print(" ");
|
||||
|
|
@ -450,6 +434,7 @@ void serialReply() {
|
|||
Serial.print(diffAdjL);
|
||||
Serial.print(" ");
|
||||
Serial.println(diffAdjH);
|
||||
#endif
|
||||
|
||||
Serial.print("Delay:");
|
||||
Serial.println(TRG_DUR);
|
||||
|
|
@ -459,13 +444,13 @@ void serialReply() {
|
|||
}
|
||||
}
|
||||
/*------------------------------------------------*/
|
||||
/*
|
||||
#ifdef I2C
|
||||
void i2cReply() {
|
||||
if (serialIncoming) {
|
||||
Wire.write("OK");
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
/*------------------------------------------------*/
|
||||
|
||||
void loop() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue