Functioning MVP tester

This commit is contained in:
Ben V. Brown
2019-10-07 19:09:21 +11:00
parent 1cf88b2cd6
commit 64f8ca5c53
5 changed files with 27 additions and 12 deletions

View File

@@ -54,12 +54,12 @@ void GUIDelay() {
}
void gui_drawTipTemp(bool symbol) {
// Draw tip temp handling unit conversion & tolerance near setpoint
uint16_t Temp = getTipRawTemp(0);
uint16_t Temp = 0;
if (systemSettings.temperatureInF)
Temp = TipThermoModel::convertTipRawADCToDegF(Temp);
Temp = TipThermoModel::getTipInF();
else
Temp = TipThermoModel::convertTipRawADCToDegC(Temp);
Temp = TipThermoModel::getTipInC();
OLED::printNumber(Temp, 3); // Draw the tip temp out finally
if (symbol) {
@@ -368,9 +368,9 @@ static int gui_SolderingSleepingMode() {
// draw the lcd
uint16_t tipTemp;
if (systemSettings.temperatureInF)
tipTemp = TipThermoModel::convertTipRawADCToDegF(getTipRawTemp(0));
tipTemp = TipThermoModel::getTipInF();
else
tipTemp = TipThermoModel::convertTipRawADCToDegC(getTipRawTemp(0));
tipTemp = TipThermoModel::getTipInC();
OLED::clearScreen();
OLED::setCursor(0, 0);
@@ -762,7 +762,7 @@ void startGUITask(void const *argument __unused) {
currentTempTargetDegC = 0; // ensure tip is off
getInputVoltageX10(systemSettings.voltageDiv, 0);
uint16_t tipTemp = TipThermoModel::convertTipRawADCToDegC(getTipRawTemp(0));
uint16_t tipTemp = TipThermoModel::getTipInC();
// Preemptively turn the display on. Turn it off if and only if
// the tip temperature is below 50 degrees C *and* motion sleep

View File

@@ -110,12 +110,12 @@ void resetSettings() {
#ifdef MODEL_TS100
systemSettings.CalibrationOffset = 700; // the adc offset in uV
systemSettings.CalibrationOffset = 800; // the adc offset in uV
#endif
#ifdef MODEL_TS80
systemSettings.pidPowerLimit=24; // Sets the max pwm power limit
systemSettings.CalibrationOffset = 700; // the adc offset in uV
systemSettings.CalibrationOffset = 800; // the adc offset in uV
#endif
saveSettings(); // Save defaults
}

View File

@@ -7,6 +7,7 @@
#include "TipThermoModel.h"
#include "Settings.h"
#include "hardware.h"
/*
* The hardware is laid out as a non-inverting op-amp
@@ -245,3 +246,16 @@ uint32_t TipThermoModel::convertFtoC(uint32_t degF) {
return ((degF - 32) * 5) / 9;
}
uint32_t TipThermoModel::getTipInC(bool sampleNow) {
uint32_t currentTipTempInC = TipThermoModel::convertTipRawADCToDegC(
getTipRawTemp(sampleNow));
currentTipTempInC += getHandleTemperature() / 10; //Add handle offset
return currentTipTempInC;
}
uint32_t TipThermoModel::getTipInF(bool sampleNow) {
uint32_t currentTipTempInF = TipThermoModel::convertTipRawADCToDegF(
getTipRawTemp(sampleNow));
currentTipTempInF += convertCtoF(getHandleTemperature() / 10); //Add handle offset
return currentTipTempInF;
}

View File

@@ -12,6 +12,10 @@
class TipThermoModel {
public:
//These are the main two functions
static uint32_t getTipInC(bool sampleNow=false);
static uint32_t getTipInF(bool sampleNow=false);
static uint32_t convertTipRawADCToDegC(uint16_t rawADC);
static uint32_t convertTipRawADCToDegF(uint16_t rawADC);
//Returns the uV of the tip reading before the op-amp compensating for pullups

View File

@@ -126,7 +126,6 @@ void startPIDTask(void const *argument __unused) {
if (ulTaskNotifyTake(pdTRUE, 2000)) {
// This is a call to block this thread until the ADC does its samples
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
if (currentTempTargetDegC) {
// Cap the max set point to 450C
if (currentTempTargetDegC > (450)) {
@@ -134,9 +133,7 @@ void startPIDTask(void const *argument __unused) {
currentTempTargetDegC = (450);
}
// Convert the current tip to degree's C
uint32_t currentTipTempInC =
TipThermoModel::convertTipRawADCToDegC(rawTemp);
currentTipTempInC += getHandleTemperature() / 10; //Add handle offset
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
// As we get close to our target, temp noise causes the system
// to be unstable. Use a rolling average to dampen it.