Refactored VCCSW to SIGVOL to better reflect the function's action #featureadd
This commit is contained in:
parent
f70b698f0d
commit
4d4babc559
13 changed files with 40 additions and 40 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
* PB7 PCINT7 (Gain Adjustment Resistor 1 'D21')
|
* PB7 PCINT7 (Gain Adjustment Resistor 1 'D21')
|
||||||
* PD5 T1 (Gain Adjustment Resistor 2 'D5')
|
* PD5 T1 (Gain Adjustment Resistor 2 'D5')
|
||||||
* PD6 PCINT22 (Gain Adjustment Resistor 3 'D6')
|
* PD6 PCINT22 (Gain Adjustment Resistor 3 'D6')
|
||||||
* PB0 PCINT0 (VCC Adjustment Resistors 'D8')
|
* PB0 PCINT0 (Signal voltage Adjustment Resistors 'D8')
|
||||||
* PB1 OC1A (Comparator VRef PWM Out 'D9')
|
* PB1 OC1A (Comparator VRef PWM Out 'D9')
|
||||||
* PD3 OC2B (Voltage Follower VRef PWM Out 'D3')
|
* PD3 OC2B (Voltage Follower VRef PWM Out 'D3')
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ To change trigger active duration: TRG_D [integer for milliseconds]
|
||||||
To change gain factor: GAIN_F [integer for gain state - see note*]
|
To change gain factor: GAIN_F [integer for gain state - see note*]
|
||||||
To change the output logic: LOGIC [0|1] (0 for active low, 1 for active high)
|
To change the output logic: LOGIC [0|1] (0 for active low, 1 for active high)
|
||||||
To enable piezo plugged detection: PZDET [0|1] (0 for disabled, 1 for enabled)
|
To enable piezo plugged detection: PZDET [0|1] (0 for disabled, 1 for enabled)
|
||||||
To set the sensor's output voltage: VCCSW [0|1] (0 for 3.3v, 1 for 5v)
|
To set the sensor's output voltage: SIGVOL [0|1] (0 for 3.3v, 1 for 5v)
|
||||||
To change ADC hysteresis value: HYST [integer in millivolts]
|
To change ADC hysteresis value: HYST [integer in millivolts]
|
||||||
To change sensor input pullup vRef low threshold: VFOL [integer in millivolts]
|
To change sensor input pullup vRef low threshold: VFOL [integer in millivolts]
|
||||||
To change comparator trigger high threshold: VCOMP [integer in millivolts]
|
To change comparator trigger high threshold: VCOMP [integer in millivolts]
|
||||||
|
|
|
||||||
|
|
@ -81,10 +81,10 @@ void updatePzDet(int value) {
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
void updateVccSwitch(int value) {
|
void updateSigVoltage(int value) {
|
||||||
if (value >= 0) {
|
if (value >= 0) {
|
||||||
VCCSW = value;
|
SIGVOL = value;
|
||||||
EEPROM.put(VCCSW_ADDRESS, VCCSW);
|
EEPROM.put(SIGVOL_ADDRESS, SIGVOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ void updateTrigDuration(int value);
|
||||||
void updateHysteresis(int value);
|
void updateHysteresis(int value);
|
||||||
void updateLogic(int value);
|
void updateLogic(int value);
|
||||||
void updatePzDet(int value);
|
void updatePzDet(int value);
|
||||||
void updateVccSwitch(int value);
|
void updateSigVoltage(int value);
|
||||||
void updateConstant(long value);
|
void updateConstant(long value);
|
||||||
void adjustConstant(int value);
|
void adjustConstant(int value);
|
||||||
void updateDebug(int value);
|
void updateDebug(int value);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ int TRG_DUR = TRG_DUR_DEFAULT;
|
||||||
int Hyst = HYST_DEFAULT;
|
int Hyst = HYST_DEFAULT;
|
||||||
int LOGIC = LOGIC_DEFAULT;
|
int LOGIC = LOGIC_DEFAULT;
|
||||||
int PZDET = PZDET_DEFAULT;
|
int PZDET = PZDET_DEFAULT;
|
||||||
int VCCSW = VCCSW_DEFAULT;
|
int SIGVOL = SIGVOL_DEFAULT;
|
||||||
int Debug = 0;
|
int Debug = 0;
|
||||||
long voltMeterConstant = VM_CONST_DEFAULT;
|
long voltMeterConstant = VM_CONST_DEFAULT;
|
||||||
uint8_t pP_i2c_address = 0x10;
|
uint8_t pP_i2c_address = 0x10;
|
||||||
|
|
@ -29,7 +29,7 @@ void eraseEEPROM() {
|
||||||
EEPROM.put(HYST_ADDRESS, Hyst);
|
EEPROM.put(HYST_ADDRESS, Hyst);
|
||||||
EEPROM.put(PZDET_ADDRESS, PZDET);
|
EEPROM.put(PZDET_ADDRESS, PZDET);
|
||||||
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
||||||
EEPROM.put(VCCSW_ADDRESS, VCCSW);
|
EEPROM.put(SIGVOL_ADDRESS, SIGVOL);
|
||||||
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,11 +97,11 @@ void restoreConfig() {
|
||||||
LOGIC = temp;
|
LOGIC = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.get(VCCSW_ADDRESS, temp);
|
EEPROM.get(SIGVOL_ADDRESS, temp);
|
||||||
if (temp < 0 || temp > 1) {
|
if (temp < 0 || temp > 1) {
|
||||||
erase = true;
|
erase = true;
|
||||||
} else {
|
} else {
|
||||||
VCCSW = temp;
|
SIGVOL = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
long longTemp;
|
long longTemp;
|
||||||
|
|
@ -131,7 +131,7 @@ void setDefaultConfig() {
|
||||||
Hyst = HYST_DEFAULT;
|
Hyst = HYST_DEFAULT;
|
||||||
PZDET = PZDET_DEFAULT;
|
PZDET = PZDET_DEFAULT;
|
||||||
LOGIC = LOGIC_DEFAULT;
|
LOGIC = LOGIC_DEFAULT;
|
||||||
VCCSW = VCCSW_DEFAULT;
|
SIGVOL = SIGVOL_DEFAULT;
|
||||||
voltMeterConstant = VM_CONST_DEFAULT;
|
voltMeterConstant = VM_CONST_DEFAULT;
|
||||||
adjustFollow();
|
adjustFollow();
|
||||||
adjustComp();
|
adjustComp();
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ extern int LOGIC; // Trigger logic scheme, Active LOW is default
|
||||||
#define PZDET_ADDRESS 26
|
#define PZDET_ADDRESS 26
|
||||||
extern int PZDET; // Enable or disable piezo connection detection, default is off
|
extern int PZDET; // Enable or disable piezo connection detection, default is off
|
||||||
|
|
||||||
#define VCCSW_DEFAULT 0
|
#define SIGVOL_DEFAULT 1
|
||||||
#define VCCSW_ADDRESS 28
|
#define SIGVOL_ADDRESS 28
|
||||||
extern int VCCSW; // Set the signal output to 3.3v [0] or 5v logic [1]
|
extern int SIGVOL; // Set the signal output to 3.3v [0] or 5v logic [1]
|
||||||
|
|
||||||
extern int Debug;
|
extern int Debug;
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ extern long voltMeterConstant; // For fine tuning input voltage sense
|
||||||
extern uint8_t pP_i2c_address;
|
extern uint8_t pP_i2c_address;
|
||||||
|
|
||||||
#ifndef PP_VERSION
|
#ifndef PP_VERSION
|
||||||
#define PP_VERSION "2.3.1"
|
#define PP_VERSION "2.3.2"
|
||||||
#endif // PP_VERSION fallback if python script fails
|
#endif // PP_VERSION fallback if python script fails
|
||||||
|
|
||||||
void eraseEEPROM();
|
void eraseEEPROM();
|
||||||
|
|
|
||||||
|
|
@ -178,14 +178,14 @@ void adjustGain() {
|
||||||
/*------------------------------------------------*/
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
void adjustVcc() {
|
void adjustVcc() {
|
||||||
switch (VCCSW) {
|
switch (SIGVOL) {
|
||||||
case 0:
|
case 0:
|
||||||
pinMode(VCCSW_PIN, OUTPUT);
|
pinMode(SIGVOL_PIN, OUTPUT);
|
||||||
digitalWriteFast(VCCSW_PIN, LOW);
|
digitalWriteFast(SIGVOL_PIN, LOW);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
default:
|
default:
|
||||||
pinMode(VCCSW_PIN, INPUT);
|
pinMode(SIGVOL_PIN, INPUT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ void i2cReportConfig() {
|
||||||
i2cWrite(buffer, 10, Hyst);
|
i2cWrite(buffer, 10, Hyst);
|
||||||
i2cWrite(buffer, 12, LOGIC);
|
i2cWrite(buffer, 12, LOGIC);
|
||||||
i2cWrite(buffer, 14, PZDET);
|
i2cWrite(buffer, 14, PZDET);
|
||||||
i2cWrite(buffer, 16, VCCSW);
|
i2cWrite(buffer, 16, SIGVOL);
|
||||||
i2cWrite(buffer, 18, voltMeterConstant);
|
i2cWrite(buffer, 18, voltMeterConstant);
|
||||||
memcpy(buffer + 22, PP_VERSION, length - 22);
|
memcpy(buffer + 22, PP_VERSION, length - 22);
|
||||||
#ifdef __AVR_ATmega328P__
|
#ifdef __AVR_ATmega328P__
|
||||||
|
|
@ -142,8 +142,8 @@ void i2cInput(int bytesReceived) {
|
||||||
break;
|
break;
|
||||||
case CMD_STATE:
|
case CMD_STATE:
|
||||||
break;
|
break;
|
||||||
case CMD_VCCSW:
|
case CMD_SIGVOL:
|
||||||
updateVccSwitch(value);
|
updateSigVoltage(value);
|
||||||
break;
|
break;
|
||||||
case CMD_VCCADJUST:
|
case CMD_VCCADJUST:
|
||||||
adjustConstant(value);
|
adjustConstant(value);
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,5 @@
|
||||||
#define CMD_CONFIG 0x09
|
#define CMD_CONFIG 0x09
|
||||||
#define CMD_ERASE 0x0a
|
#define CMD_ERASE 0x0a
|
||||||
#define CMD_STATE 0x0b
|
#define CMD_STATE 0x0b
|
||||||
#define CMD_VCCSW 0x0c
|
#define CMD_SIGVOL 0x0c
|
||||||
#define CMD_VCCADJUST 0x0d
|
#define CMD_VCCADJUST 0x0d
|
||||||
|
|
@ -33,7 +33,7 @@ Default pins (based on Rev.2.x.xPCB layout)
|
||||||
#define V_FOL_PWM 3 // PWM analog output pin for voltage follower adjustment
|
#define V_FOL_PWM 3 // PWM analog output pin for voltage follower adjustment
|
||||||
#define VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
#define VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
||||||
#define PZDET_PIN 16 // Digital input pin for detecting piezo connection
|
#define PZDET_PIN 16 // Digital input pin for detecting piezo connection
|
||||||
#define VCCSW_PIN 8 // VCC variable regulator switch pin
|
#define SIGVOL_PIN 8 // VCC variable regulator switch pin
|
||||||
|
|
||||||
#endif //__AVR_ATmega328PB__
|
#endif //__AVR_ATmega328PB__
|
||||||
|
|
||||||
|
|
@ -55,6 +55,6 @@ Default pins (based on Rev.2.x.xPCB layout)
|
||||||
#define V_FOL_PWM 3 // PD3 PWM analog output pin for voltage follower adjustment
|
#define V_FOL_PWM 3 // PD3 PWM analog output pin for voltage follower adjustment
|
||||||
#define VCOMP_PWM 9 // PB1 PWM analog output pin for comparator adjustment
|
#define VCOMP_PWM 9 // PB1 PWM analog output pin for comparator adjustment
|
||||||
#define PZDET_PIN 16 // PC2 Digital input pin for detecting piezo connection
|
#define PZDET_PIN 16 // PC2 Digital input pin for detecting piezo connection
|
||||||
#define VCCSW_PIN 8 // PB0 VCC variable regulator switch pin
|
#define SIGVOL_PIN 8 // PB0 VCC variable regulator switch pin
|
||||||
|
|
||||||
#endif //__AVR_ATmega328P__
|
#endif //__AVR_ATmega328P__
|
||||||
|
|
@ -81,9 +81,9 @@ void serialPrintConfig() {
|
||||||
Serial.print("PZDET ");
|
Serial.print("PZDET ");
|
||||||
Serial.println(PZDET);
|
Serial.println(PZDET);
|
||||||
|
|
||||||
Serial.print("VCCSW ");
|
Serial.print("SIGVOL ");
|
||||||
Serial.print(VCCSW);
|
Serial.print(SIGVOL);
|
||||||
switch (VCCSW) {
|
switch (SIGVOL) {
|
||||||
case 0:
|
case 0:
|
||||||
Serial.println(" 3.3v");
|
Serial.println(" 3.3v");
|
||||||
break;
|
break;
|
||||||
|
|
@ -146,8 +146,8 @@ void updateParams() {
|
||||||
updateLogic(serialLong);
|
updateLogic(serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
||||||
updatePzDet(serialLong);
|
updatePzDet(serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "VCCSW") == 0) {
|
} else if (strcmp(serialMessageIn, "SIGVOL") == 0) {
|
||||||
updateVccSwitch(serialLong);
|
updateSigVoltage(serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
||||||
updateConstant(serialLong);
|
updateConstant(serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
||||||
|
|
@ -172,7 +172,7 @@ void updateParams() {
|
||||||
Serial.println(" (0 for active low, 1 for active high)");
|
Serial.println(" (0 for active low, 1 for active high)");
|
||||||
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
||||||
Serial.println(" (0 for disabled, 1 for enabled)");
|
Serial.println(" (0 for disabled, 1 for enabled)");
|
||||||
Serial.println("To change the main voltage of the circuit: VCCSW [0|1]");
|
Serial.println("To change the main voltage of the circuit: SIGVOL [0|1]");
|
||||||
Serial.println(" (0 for 3.3v, 1 for 5v)");
|
Serial.println(" (0 for 3.3v, 1 for 5v)");
|
||||||
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
||||||
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ config_t requestConfig() {
|
||||||
config.Hyst = read16();
|
config.Hyst = read16();
|
||||||
config.LOGIC = read16();
|
config.LOGIC = read16();
|
||||||
config.PZDET = read16();
|
config.PZDET = read16();
|
||||||
config.VCCSW = read16();
|
config.SIGVOL = read16();
|
||||||
config.voltMeterConstant = read32();
|
config.voltMeterConstant = read32();
|
||||||
config.version = Wire.readString();
|
config.version = Wire.readString();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#define CMD_CONFIG 0x09
|
#define CMD_CONFIG 0x09
|
||||||
#define CMD_ERASE 0x0a
|
#define CMD_ERASE 0x0a
|
||||||
#define CMD_STATE 0x0b
|
#define CMD_STATE 0x0b
|
||||||
#define CMD_VCCSW 0x0c
|
#define CMD_SIGVOL 0x0c
|
||||||
#define CMD_VCCADJUST 0x0d
|
#define CMD_VCCADJUST 0x0d
|
||||||
|
|
||||||
#include "WString.h"
|
#include "WString.h"
|
||||||
|
|
@ -29,7 +29,7 @@ typedef struct {
|
||||||
uint16_t Hyst;
|
uint16_t Hyst;
|
||||||
uint16_t LOGIC;
|
uint16_t LOGIC;
|
||||||
uint16_t PZDET;
|
uint16_t PZDET;
|
||||||
uint16_t VCCSW;
|
uint16_t SIGVOL;
|
||||||
uint32_t voltMeterConstant;
|
uint32_t voltMeterConstant;
|
||||||
String version;
|
String version;
|
||||||
} config_t;
|
} config_t;
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,9 @@ void serialPrintConfig() {
|
||||||
Serial.print("PZDET ");
|
Serial.print("PZDET ");
|
||||||
Serial.println(config.PZDET);
|
Serial.println(config.PZDET);
|
||||||
|
|
||||||
Serial.print("VCCSW ");
|
Serial.print("SIGVOL ");
|
||||||
Serial.print(config.VCCSW);
|
Serial.print(config.SIGVOL);
|
||||||
switch (config.VCCSW) {
|
switch (config.SIGVOL) {
|
||||||
case 0:
|
case 0:
|
||||||
Serial.println(" 3.3v");
|
Serial.println(" 3.3v");
|
||||||
break;
|
break;
|
||||||
|
|
@ -157,8 +157,8 @@ void updateParams() {
|
||||||
write(CMD_LOGIC, (uint16_t)serialLong);
|
write(CMD_LOGIC, (uint16_t)serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
||||||
write(CMD_PZDET, (uint16_t)serialLong);
|
write(CMD_PZDET, (uint16_t)serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "VCCSW") == 0) {
|
} else if (strcmp(serialMessageIn, "SIGVOL") == 0) {
|
||||||
write(CMD_VCCSW, (uint16_t)serialLong);
|
write(CMD_SIGVOL, (uint16_t)serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
||||||
write(CMD_CONST, serialLong);
|
write(CMD_CONST, serialLong);
|
||||||
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
||||||
|
|
@ -181,7 +181,7 @@ void updateParams() {
|
||||||
Serial.println(" (0 for active low, 1 for active high)");
|
Serial.println(" (0 for active low, 1 for active high)");
|
||||||
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
||||||
Serial.println(" (0 for disabled, 1 for enabled)");
|
Serial.println(" (0 for disabled, 1 for enabled)");
|
||||||
Serial.println("To change the main voltage of the circuit: VCCSW [0|1]");
|
Serial.println("To change the main voltage of the circuit: SIGVOL [0|1]");
|
||||||
Serial.println(" (0 for 3.3v, 1 for 5v)");
|
Serial.println(" (0 for 3.3v, 1 for 5v)");
|
||||||
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
||||||
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue