Added better pin debouncing, voltage references, python parsing, groundtruth measurements

This commit is contained in:
Nathan 2022-04-21 20:38:09 -07:00
parent 29451ad11f
commit 8649afd315
6 changed files with 13981 additions and 43 deletions

3
.gitignore vendored
View File

@ -24,3 +24,6 @@ fp-info-cache
# Exported BOM files
*.xml
*.csv
# ipynb checkpoints
.ipynb_checkpoints

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -68,7 +68,6 @@ volatile single_button_state_t dn_button_state = BUTTON_NO_ACTION;
volatile unsigned long up_state_change_time = 0;
volatile unsigned long down_state_change_time = 0;
// Temperature Info
byte max_temp_array[] = {140, 150, 160, 170, 180};
byte max_temp_index = 0;
@ -197,7 +196,6 @@ void upsw_change_isr() {
up_state_change_time = millis();
}
void setup() {
// Pin Direction control
@ -286,13 +284,9 @@ inline void setupSensors() {
}
}
inline void setFastPwm() {
analogWriteFrequency(64);
}
inline void setFastPwm() { analogWriteFrequency(64); }
inline void setVREF() {
analogReference(INTERNAL1V5);
}
inline void setVREF() { analogReference(INTERNAL1V5); }
inline bool isFirstBoot() {
uint8_t first_boot = EEPROM.read(FIRSTTIME_BOOT_ADDR);
@ -467,8 +461,10 @@ buttons_state_t getButtonsState() {
unsigned long cur_time = millis();
buttons_state_t state = BUTTONS_NO_PRESS;
if(button_dn == BUTTON_PRESSED && button_up == BUTTON_PRESSED && abs(button_dn_time - button_up_time) < BUTTON_PRESS_TIME) {
if(cur_time - button_dn_time > BUTTON_PRESS_TIME && cur_time - button_up_time > BUTTON_PRESS_TIME) {
if (button_dn == BUTTON_PRESSED && button_up == BUTTON_PRESSED &&
abs(button_dn_time - button_up_time) < BUTTON_PRESS_TIME) {
if (cur_time - button_dn_time > BUTTON_PRESS_TIME &&
cur_time - button_up_time > BUTTON_PRESS_TIME) {
state = BUTTONS_BOTH_PRESS;
noInterrupts();
dn_button_state = BUTTON_NO_ACTION;
@ -621,8 +617,8 @@ bool heat(byte max_temp, int profile_index) {
}
// Measure Values
// TODO(HEIDT) getting the temperature from the digital sensors is by far the slowest part of this loop.
// figure out an approach that allows control faster than sensing
// TODO(HEIDT) getting the temperature from the digital sensors is by far the slowest part
// of this loop. figure out an approach that allows control faster than sensing
t = getTemp();
v = getVolts();
float max_possible_amperage = v / bed_resistance;

View File

@ -0,0 +1,57 @@
#include <Adafruit_MAX31865.h>
// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(3, 4, 5, 6);
// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF 430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL 100.0
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
thermo.begin(MAX31865_3WIRE); // set to 2WIRE or 4WIRE as necessary
}
void loop() {
uint8_t fault = thermo.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (fault & MAX31865_FAULT_HIGHTHRESH) {
Serial.println("RTD High Threshold");
}
if (fault & MAX31865_FAULT_LOWTHRESH) {
Serial.println("RTD Low Threshold");
}
if (fault & MAX31865_FAULT_REFINLOW) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (fault & MAX31865_FAULT_REFINHIGH) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_RTDINLOW) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_OVUV) {
Serial.println("Under/Over voltage");
}
thermo.clearFault();
}
String s;
if (Serial1.available()) {
s = Serial1.readStringUntil('\n');
Serial.println(s);
}
if (s.indexOf("Temps") >= 0) {
Serial.print("Groundtruth ");
Serial.println(thermo.temperature(RNOMINAL, RREF));
}
}