Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 93b2b78190 | |||
| 3385377041 | |||
| 15e00ff6e0 | |||
| 75286d499f | |||
| 4d4babc559 |
15 changed files with 48 additions and 48 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* PB7 PCINT7 (Gain Adjustment Resistor 1 'D21')
|
||||
* PD5 T1 (Gain Adjustment Resistor 2 'D5')
|
||||
* 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')
|
||||
* 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 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 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 sensor input pullup vRef low threshold: VFOL [integer in millivolts]
|
||||
To change comparator trigger high threshold: VCOMP [integer in millivolts]
|
||||
|
|
@ -126,9 +126,9 @@ void setup() {
|
|||
Serial.begin(9600);
|
||||
Serial.print("Pyr0-Piezo Z-Probe Firmware ");
|
||||
Serial.println(PP_VERSION);
|
||||
Serial.println("Info: https://docs.pyroballpcbs.com");
|
||||
Serial.println("Source: https://github.com/pyr0ball/pyr0piezo");
|
||||
Serial.println("Initializing Pyr0-Piezo Sensor...");
|
||||
//Serial.println("Info: https://docs.pyroballpcbs.com");
|
||||
//Serial.println("Source: https://github.com/pyr0ball/pyr0piezo");
|
||||
//Serial.println("Initializing Pyr0-Piezo Sensor...");
|
||||
|
||||
i2cInit();
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ void setup() {
|
|||
|
||||
adjustGain();
|
||||
|
||||
adjustVcc();
|
||||
adjustSigVol();
|
||||
|
||||
digitalWriteFast(TRG_OUT, !LOGIC);
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ void loop() {
|
|||
adjustGain();
|
||||
|
||||
// Set the VCC input switch
|
||||
adjustVcc();
|
||||
adjustSigVol();
|
||||
|
||||
// Check voltage of first and second stages and compare against thresholds
|
||||
readVin();
|
||||
|
|
|
|||
|
|
@ -81,10 +81,10 @@ void updatePzDet(int value) {
|
|||
|
||||
/*------------------------------------------------*/
|
||||
|
||||
void updateVccSwitch(int value) {
|
||||
void updateSigVoltage(int value) {
|
||||
if (value >= 0) {
|
||||
VCCSW = value;
|
||||
EEPROM.put(VCCSW_ADDRESS, VCCSW);
|
||||
SIGVOL = value;
|
||||
EEPROM.put(SIGVOL_ADDRESS, SIGVOL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ void updateTrigDuration(int value);
|
|||
void updateHysteresis(int value);
|
||||
void updateLogic(int value);
|
||||
void updatePzDet(int value);
|
||||
void updateVccSwitch(int value);
|
||||
void updateSigVoltage(int value);
|
||||
void updateConstant(long value);
|
||||
void adjustConstant(int value);
|
||||
void updateDebug(int value);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ int TRG_DUR = TRG_DUR_DEFAULT;
|
|||
int Hyst = HYST_DEFAULT;
|
||||
int LOGIC = LOGIC_DEFAULT;
|
||||
int PZDET = PZDET_DEFAULT;
|
||||
int VCCSW = VCCSW_DEFAULT;
|
||||
int SIGVOL = SIGVOL_DEFAULT;
|
||||
int Debug = 0;
|
||||
long voltMeterConstant = VM_CONST_DEFAULT;
|
||||
uint8_t pP_i2c_address = 0x10;
|
||||
|
|
@ -29,7 +29,7 @@ void eraseEEPROM() {
|
|||
EEPROM.put(HYST_ADDRESS, Hyst);
|
||||
EEPROM.put(PZDET_ADDRESS, PZDET);
|
||||
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
||||
EEPROM.put(VCCSW_ADDRESS, VCCSW);
|
||||
EEPROM.put(SIGVOL_ADDRESS, SIGVOL);
|
||||
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
||||
}
|
||||
|
||||
|
|
@ -97,11 +97,11 @@ void restoreConfig() {
|
|||
LOGIC = temp;
|
||||
}
|
||||
|
||||
EEPROM.get(VCCSW_ADDRESS, temp);
|
||||
EEPROM.get(SIGVOL_ADDRESS, temp);
|
||||
if (temp < 0 || temp > 1) {
|
||||
erase = true;
|
||||
} else {
|
||||
VCCSW = temp;
|
||||
SIGVOL = temp;
|
||||
}
|
||||
|
||||
long longTemp;
|
||||
|
|
@ -131,7 +131,7 @@ void setDefaultConfig() {
|
|||
Hyst = HYST_DEFAULT;
|
||||
PZDET = PZDET_DEFAULT;
|
||||
LOGIC = LOGIC_DEFAULT;
|
||||
VCCSW = VCCSW_DEFAULT;
|
||||
SIGVOL = SIGVOL_DEFAULT;
|
||||
voltMeterConstant = VM_CONST_DEFAULT;
|
||||
adjustFollow();
|
||||
adjustComp();
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ extern int LOGIC; // Trigger logic scheme, Active LOW is default
|
|||
#define PZDET_ADDRESS 26
|
||||
extern int PZDET; // Enable or disable piezo connection detection, default is off
|
||||
|
||||
#define VCCSW_DEFAULT 1
|
||||
#define VCCSW_ADDRESS 28
|
||||
extern int VCCSW; // Set the signal output to 3.3v [0] or 5v logic [1]
|
||||
#define SIGVOL_DEFAULT 1
|
||||
#define SIGVOL_ADDRESS 28
|
||||
extern int SIGVOL; // Set the signal output to 3.3v [0] or 5v logic [1]
|
||||
|
||||
extern int Debug;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ extern long voltMeterConstant; // For fine tuning input voltage sense
|
|||
extern uint8_t pP_i2c_address;
|
||||
|
||||
#ifndef PP_VERSION
|
||||
#define PP_VERSION "2.3.1"
|
||||
#define PP_VERSION "2.3.2"
|
||||
#endif // PP_VERSION fallback if python script fails
|
||||
|
||||
void eraseEEPROM();
|
||||
|
|
|
|||
|
|
@ -177,15 +177,15 @@ void adjustGain() {
|
|||
|
||||
/*------------------------------------------------*/
|
||||
|
||||
void adjustVcc() {
|
||||
switch (VCCSW) {
|
||||
void adjustSigVol() {
|
||||
switch (SIGVOL) {
|
||||
case 0:
|
||||
pinMode(VCCSW_PIN, OUTPUT);
|
||||
digitalWriteFast(VCCSW_PIN, LOW);
|
||||
pinMode(SIGVOL_PIN, OUTPUT);
|
||||
digitalWriteFast(SIGVOL_PIN, LOW);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
pinMode(VCCSW_PIN, INPUT);
|
||||
pinMode(SIGVOL_PIN, INPUT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ long readVcc();
|
|||
void readVin();
|
||||
void adjustFollow();
|
||||
void adjustComp();
|
||||
void adjustVcc();
|
||||
void adjustSigVol();
|
||||
void calibrateAlert();
|
||||
void adjustGain();
|
||||
void pzConCheck();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void i2cReportConfig() {
|
|||
i2cWrite(buffer, 10, Hyst);
|
||||
i2cWrite(buffer, 12, LOGIC);
|
||||
i2cWrite(buffer, 14, PZDET);
|
||||
i2cWrite(buffer, 16, VCCSW);
|
||||
i2cWrite(buffer, 16, SIGVOL);
|
||||
i2cWrite(buffer, 18, voltMeterConstant);
|
||||
memcpy(buffer + 22, PP_VERSION, length - 22);
|
||||
#ifdef __AVR_ATmega328P__
|
||||
|
|
@ -142,8 +142,8 @@ void i2cInput(int bytesReceived) {
|
|||
break;
|
||||
case CMD_STATE:
|
||||
break;
|
||||
case CMD_VCCSW:
|
||||
updateVccSwitch(value);
|
||||
case CMD_SIGVOL:
|
||||
updateSigVoltage(value);
|
||||
break;
|
||||
case CMD_VCCADJUST:
|
||||
adjustConstant(value);
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@
|
|||
#define CMD_CONFIG 0x09
|
||||
#define CMD_ERASE 0x0a
|
||||
#define CMD_STATE 0x0b
|
||||
#define CMD_VCCSW 0x0c
|
||||
#define CMD_SIGVOL 0x0c
|
||||
#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 VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
||||
#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__
|
||||
|
||||
|
|
@ -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 VCOMP_PWM 9 // PB1 PWM analog output pin for comparator adjustment
|
||||
#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__
|
||||
|
|
@ -81,9 +81,9 @@ void serialPrintConfig() {
|
|||
Serial.print("PZDET ");
|
||||
Serial.println(PZDET);
|
||||
|
||||
Serial.print("VCCSW ");
|
||||
Serial.print(VCCSW);
|
||||
switch (VCCSW) {
|
||||
Serial.print("SIGVOL ");
|
||||
Serial.print(SIGVOL);
|
||||
switch (SIGVOL) {
|
||||
case 0:
|
||||
Serial.println(" 3.3v");
|
||||
break;
|
||||
|
|
@ -146,8 +146,8 @@ void updateParams() {
|
|||
updateLogic(serialLong);
|
||||
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
||||
updatePzDet(serialLong);
|
||||
} else if (strcmp(serialMessageIn, "VCCSW") == 0) {
|
||||
updateVccSwitch(serialLong);
|
||||
} else if (strcmp(serialMessageIn, "SIGVOL") == 0) {
|
||||
updateSigVoltage(serialLong);
|
||||
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
||||
updateConstant(serialLong);
|
||||
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
||||
|
|
@ -172,7 +172,7 @@ void updateParams() {
|
|||
Serial.println(" (0 for active low, 1 for active high)");
|
||||
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
||||
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("To change ADC hysteresis value: HYST [integer in millivolts]");
|
||||
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
|
||||
major_version = "2.3.1"
|
||||
major_version = "2.3.2"
|
||||
|
||||
git_head = str(subprocess.check_output(["git", "rev-parse", "HEAD"])[0:6])
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ config_t requestConfig() {
|
|||
config.Hyst = read16();
|
||||
config.LOGIC = read16();
|
||||
config.PZDET = read16();
|
||||
config.VCCSW = read16();
|
||||
config.SIGVOL = read16();
|
||||
config.voltMeterConstant = read32();
|
||||
config.version = Wire.readString();
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#define CMD_CONFIG 0x09
|
||||
#define CMD_ERASE 0x0a
|
||||
#define CMD_STATE 0x0b
|
||||
#define CMD_VCCSW 0x0c
|
||||
#define CMD_SIGVOL 0x0c
|
||||
#define CMD_VCCADJUST 0x0d
|
||||
|
||||
#include "WString.h"
|
||||
|
|
@ -29,7 +29,7 @@ typedef struct {
|
|||
uint16_t Hyst;
|
||||
uint16_t LOGIC;
|
||||
uint16_t PZDET;
|
||||
uint16_t VCCSW;
|
||||
uint16_t SIGVOL;
|
||||
uint32_t voltMeterConstant;
|
||||
String version;
|
||||
} config_t;
|
||||
|
|
|
|||
|
|
@ -90,9 +90,9 @@ void serialPrintConfig() {
|
|||
Serial.print("PZDET ");
|
||||
Serial.println(config.PZDET);
|
||||
|
||||
Serial.print("VCCSW ");
|
||||
Serial.print(config.VCCSW);
|
||||
switch (config.VCCSW) {
|
||||
Serial.print("SIGVOL ");
|
||||
Serial.print(config.SIGVOL);
|
||||
switch (config.SIGVOL) {
|
||||
case 0:
|
||||
Serial.println(" 3.3v");
|
||||
break;
|
||||
|
|
@ -157,8 +157,8 @@ void updateParams() {
|
|||
write(CMD_LOGIC, (uint16_t)serialLong);
|
||||
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
||||
write(CMD_PZDET, (uint16_t)serialLong);
|
||||
} else if (strcmp(serialMessageIn, "VCCSW") == 0) {
|
||||
write(CMD_VCCSW, (uint16_t)serialLong);
|
||||
} else if (strcmp(serialMessageIn, "SIGVOL") == 0) {
|
||||
write(CMD_SIGVOL, (uint16_t)serialLong);
|
||||
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
||||
write(CMD_CONST, serialLong);
|
||||
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
||||
|
|
@ -181,7 +181,7 @@ void updateParams() {
|
|||
Serial.println(" (0 for active low, 1 for active high)");
|
||||
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
||||
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("To change ADC hysteresis value: HYST [integer in millivolts]");
|
||||
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
||||
|
|
|
|||
Loading…
Reference in a new issue