1
0
forked from me/IronOS

Fix calibration, move to exp moving average

This commit is contained in:
Ben V. Brown
2019-10-08 21:50:50 +11:00
parent 6a39e4bcc8
commit 3fea95c6b1
10 changed files with 61 additions and 33 deletions

View File

@@ -502,9 +502,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (systemSettings.detailedSoldering) {
OLED::setFont(1);
OLED::print(SolderingAdvancedPowerPrompt); // Power:
OLED::printNumber(x10WattHistory[0] / 10, 2);
OLED::printNumber(x10WattHistory.average() / 10, 2);
OLED::print(SymbolDot);
OLED::printNumber(x10WattHistory[0] % 10, 1);
OLED::printNumber(x10WattHistory.average()% 10, 1);
OLED::print(SymbolWatts);
if (systemSettings.sensitivity && systemSettings.SleepTime) {
@@ -538,10 +538,10 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::print(SymbolSpace);
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory[0]));
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
} else {
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory[0]));
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
// We draw boost arrow if boosting, or else gap temp <-> heat
// indicator
if (boostModeOn)

View File

@@ -106,7 +106,7 @@ void resetSettings() {
systemSettings.descriptionScrollSpeed = 0; // default to slow
#ifdef MODEL_TS100
systemSettings.CalibrationOffset = 300; // the adc offset in uV
systemSettings.CalibrationOffset = 850; // the adc offset in uV
systemSettings.pidPowerLimit=70; // Sets the max pwm power limit
#endif

View File

@@ -50,7 +50,7 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC) {
//Now to divide this down by the gain
valueuV = (valueuV) / op_amp_gain_stage;
//Remove uV tipOffset
if (valueuV > systemSettings.CalibrationOffset)
if (valueuV >= systemSettings.CalibrationOffset)
valueuV -= systemSettings.CalibrationOffset;
else
valueuV = 0;

View File

@@ -563,25 +563,26 @@ static void setTipOffset() {
// If the thermo-couple at the end of the tip, and the handle are at
// equilibrium, then the output should be zero, as there is no temperature
// differential.
uint32_t offset = 0;
for (uint8_t i = 0; i < 15; i++) {
offset += getTipRawTemp(0);
// cycle through the filter a fair bit to ensure we're stable.
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(SymbolDot);
for (uint8_t x = 0; x < i / 4; x++)
while (systemSettings.CalibrationOffset == 0) {
uint32_t offset = 0;
for (uint8_t i = 0; i < 16; i++) {
offset += getTipRawTemp(1);
// cycle through the filter a fair bit to ensure we're stable.
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(SymbolDot);
OLED::refresh();
osDelay(100);
for (uint8_t x = 0; x < (i / 4); x++)
OLED::print(SymbolDot);
OLED::refresh();
osDelay(100);
}
systemSettings.CalibrationOffset = TipThermoModel::convertTipRawADCTouV(
offset / 16);
}
systemSettings.CalibrationOffset = TipThermoModel::convertTipRawADCTouV(
offset / 15);
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::drawCheckbox(true);
OLED::printNumber(systemSettings.CalibrationOffset,4);
OLED::printNumber(systemSettings.CalibrationOffset, 4);
OLED::refresh();
osDelay(1200);
}

View File

@@ -118,7 +118,7 @@ void startPIDTask(void const *argument __unused) {
#else
#endif
history<int32_t, PID_TIM_HZ > tempError = { { 0 }, 0, 0 };
history<int32_t, PID_TIM_HZ> tempError = { { 0 }, 0, 0 };
currentTempTargetDegC = 0; // Force start with no output (off). If in sleep / soldering this will
// be over-ridden rapidly
pidTaskNotification = xTaskGetCurrentTaskHandle();
@@ -126,6 +126,9 @@ void startPIDTask(void const *argument __unused) {
if (ulTaskNotifyTake(pdTRUE, 2000)) {
// This is a call to block this thread until the ADC does its samples
// Do the reading here to keep the temp calculations churning along
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
if (currentTempTargetDegC) {
// Cap the max set point to 450C
if (currentTempTargetDegC > (450)) {
@@ -133,7 +136,6 @@ void startPIDTask(void const *argument __unused) {
currentTempTargetDegC = (450);
}
// Convert the current tip to degree's C
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.

View File

@@ -12,7 +12,7 @@
const uint16_t powerPWM = 255;
const uint16_t totalPWM = 255 + 17; //htim2.Init.Period, the full PWM cycle
history<uint32_t, oscillationPeriod> x10WattHistory = { { 0 }, 0, 0 };
expMovingAverage<uint32_t, wattHistoryFilter> x10WattHistory = { 0 };
int32_t tempToX10Watts(int32_t rawTemp) {
// mass is in milliJ/*C, rawC is raw per degree C