Add isTipShorted() to warnings

This commit is contained in:
Ben V. Brown
2023-07-28 19:59:54 +10:00
parent 13e1c24152
commit 344068d480
7 changed files with 25 additions and 13 deletions

View File

@@ -101,6 +101,8 @@ void setBuzzer(bool on);
// For example, on the MHP30 this is used to figure out the resistance of the hotplate // For example, on the MHP30 this is used to figure out the resistance of the hotplate
uint8_t preStartChecks(); uint8_t preStartChecks();
uint8_t preStartChecksDone(); uint8_t preStartChecksDone();
bool isTipShorted();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -19,3 +19,4 @@ void power_check() {
bool getIsPoweredByDCIN() { return false; } bool getIsPoweredByDCIN() { return false; }
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
bool isTipShorted() { return false; }

View File

@@ -284,6 +284,7 @@ void performTipResistanceSampleReading() {
tipResistanceReadingSlot++; tipResistanceReadingSlot++;
} }
bool tipShorted = false;
void FinishMeasureTipResistance() { void FinishMeasureTipResistance() {
// Otherwise we now have the 4 samples; // Otherwise we now have the 4 samples;
@@ -303,6 +304,8 @@ void FinishMeasureTipResistance() {
// return; // Change nothing as probably disconnected tip // return; // Change nothing as probably disconnected tip
tipResistanceReadingSlot = lastTipResistance = 0; tipResistanceReadingSlot = lastTipResistance = 0;
return; return;
} else if (reading < 200) {
tipShorted = true;
} else if (reading < 800) { } else if (reading < 800) {
newRes = 62; newRes = 62;
} else { } else {
@@ -372,7 +375,7 @@ uint64_t getDeviceID() {
uint8_t preStartChecksDone() { uint8_t preStartChecksDone() {
#ifdef TIP_RESISTANCE_SENSE_Pin #ifdef TIP_RESISTANCE_SENSE_Pin
return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring) ? 0 : 1; return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring || tipShorted) ? 0 : 1;
#else #else
return 1; return 1;
#endif #endif
@@ -387,7 +390,11 @@ uint8_t getTipResistanceX10() {
return TIP_RESISTANCE; return TIP_RESISTANCE;
#endif #endif
} }
#ifdef TIP_RESISTANCE_SENSE_Pin
bool isTipShorted() { return tipShorted; }
#else
bool isTipShorted() { return false; }
#endif
uint8_t getTipThermalMass() { uint8_t getTipThermalMass() {
#ifdef TIP_RESISTANCE_SENSE_Pin #ifdef TIP_RESISTANCE_SENSE_Pin
if (lastTipResistance >= 80) { if (lastTipResistance >= 80) {

View File

@@ -93,7 +93,7 @@ uint8_t preStartChecks() { return 1; }
uint64_t getDeviceID() { return dbg_id_get(); } uint64_t getDeviceID() { return dbg_id_get(); }
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
bool isTipShorted() { return false; }
uint8_t preStartChecksDone() { return 1; } uint8_t preStartChecksDone() { return 1; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; } uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }

View File

@@ -187,7 +187,7 @@ void performTipResistanceSampleReading() {
gpio_write(TIP_RESISTANCE_SENSE, tipResistanceReadingSlot == 0); gpio_write(TIP_RESISTANCE_SENSE, tipResistanceReadingSlot == 0);
tipResistanceReadingSlot++; tipResistanceReadingSlot++;
} }
bool tipShorted = false;
void FinishMeasureTipResistance() { void FinishMeasureTipResistance() {
// Otherwise we now have the 4 samples; // Otherwise we now have the 4 samples;
@@ -207,10 +207,7 @@ void FinishMeasureTipResistance() {
if (reading > 8000) { if (reading > 8000) {
// return; // Change nothing as probably disconnected tip // return; // Change nothing as probably disconnected tip
} else if (reading < 500) { } else if (reading < 500) {
for (;;) /* Tip shorted, wait until reset */ tipShorted = true;
{
__NOP();
}
} else if (reading < 4000) { } else if (reading < 4000) {
newRes = 62; newRes = 62;
} else { } else {
@@ -220,8 +217,8 @@ void FinishMeasureTipResistance() {
} }
volatile bool tipMeasurementOccuring = true; volatile bool tipMeasurementOccuring = true;
volatile TickType_t nextTipMeasurement = 100; volatile TickType_t nextTipMeasurement = 100;
bool isTipShorted() { return tipShorted; }
void performTipMeasurementStep() { void performTipMeasurementStep() {
// Wait 100ms for settle time // Wait 100ms for settle time
if (xTaskGetTickCount() < (nextTipMeasurement)) { if (xTaskGetTickCount() < (nextTipMeasurement)) {
@@ -243,7 +240,8 @@ uint8_t preStartChecks() {
performTipMeasurementStep(); performTipMeasurementStep();
return preStartChecksDone(); return preStartChecksDone();
} }
uint8_t preStartChecksDone() { return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring) ? 0 : 1; } // If we are still measuring the tip; or tip is shorted; prevent heating
uint8_t preStartChecksDone() { return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring || tipShorted) ? 0 : 1; }
// Return hardware unique ID if possible // Return hardware unique ID if possible
uint64_t getDeviceID() { uint64_t getDeviceID() {

View File

@@ -230,7 +230,7 @@ uint64_t getDeviceID() {
} }
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
bool isTipShorted() { return false; }
uint8_t preStartChecksDone() { return 1; } uint8_t preStartChecksDone() { return 1; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; } uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }

View File

@@ -48,5 +48,9 @@ void showWarnings(void) {
} }
} }
#endif /*POW_PD_EXT==1*/ #endif /*POW_PD_EXT==1*/
// If tip looks to be shorted, yell at user and dont auto dismiss
if (isTipShorted()) {
warnUser(translatedString(Tr->WarningTipShorted), portMAX_DELAY);
}
#endif /*NO_WARN_MISSING*/ #endif /*NO_WARN_MISSING*/
} }