Merge branch 'master' of https://github.com/Ralim/ts100
This commit is contained in:
@@ -263,36 +263,36 @@ static void gui_drawBatteryIcon() {
|
|||||||
// we need to calculate which of the 10 levels they are on
|
// we need to calculate which of the 10 levels they are on
|
||||||
uint8_t cellCount = systemSettings.cutoutSetting + 2;
|
uint8_t cellCount = systemSettings.cutoutSetting + 2;
|
||||||
uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv)
|
uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv)
|
||||||
/ cellCount;
|
/ cellCount;
|
||||||
// Should give us approx cell voltage X10
|
// Should give us approx cell voltage X10
|
||||||
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
|
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
|
||||||
if (cellV < 33)
|
if (cellV < 33)
|
||||||
cellV = 33;
|
cellV = 33;
|
||||||
cellV -= 33; // Should leave us a number of 0-9
|
cellV -= 33;// Should leave us a number of 0-9
|
||||||
if (cellV > 9)
|
if (cellV > 9)
|
||||||
cellV = 9;
|
cellV = 9;
|
||||||
OLED::drawBattery(cellV + 1);
|
OLED::drawBattery(cellV + 1);
|
||||||
} else
|
} else
|
||||||
OLED::drawSymbol(15); // Draw the DC Logo
|
OLED::drawSymbol(15); // Draw the DC Logo
|
||||||
#else
|
#else
|
||||||
// On TS80 we replace this symbol with the voltage we are operating on
|
// On TS80 we replace this symbol with the voltage we are operating on
|
||||||
// If <9V then show single digit, if not show duals
|
// If <9V then show single digit, if not show duals
|
||||||
uint8_t V = getInputVoltageX10(systemSettings.voltageDiv);
|
uint8_t V = getInputVoltageX10(systemSettings.voltageDiv);
|
||||||
if (V % 10 >= 5)
|
if (V % 10 >= 5)
|
||||||
V = V / 10 + 1;// round up
|
V = V / 10 + 1; // round up
|
||||||
else
|
else
|
||||||
V = V / 10;
|
V = V / 10;
|
||||||
if (V >= 10) {
|
if (V >= 10) {
|
||||||
int16_t xPos = OLED::getCursorX();
|
int16_t xPos = OLED::getCursorX();
|
||||||
OLED::setFont(1);
|
OLED::setFont(1);
|
||||||
OLED::printNumber(1, 1);
|
OLED::printNumber(1, 1);
|
||||||
OLED::setCursor(xPos, 8);
|
OLED::setCursor(xPos, 8);
|
||||||
OLED::printNumber(V % 10, 1);
|
OLED::printNumber(V % 10, 1);
|
||||||
OLED::setFont(0);
|
OLED::setFont(0);
|
||||||
OLED::setCursor(xPos+12,0); // need to reset this as if we drew a wide char
|
OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
|
||||||
} else {
|
} else {
|
||||||
OLED::printNumber(V, 1);
|
OLED::printNumber(V, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
static void gui_solderingTempAdjust() {
|
static void gui_solderingTempAdjust() {
|
||||||
@@ -364,7 +364,7 @@ static void gui_solderingTempAdjust() {
|
|||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
if (!OLED::getRotation())
|
if (!OLED::getRotation())
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation())
|
if (OLED::getRotation())
|
||||||
#endif
|
#endif
|
||||||
OLED::drawChar('-');
|
OLED::drawChar('-');
|
||||||
else
|
else
|
||||||
@@ -380,7 +380,7 @@ static void gui_solderingTempAdjust() {
|
|||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
if (!OLED::getRotation())
|
if (!OLED::getRotation())
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation())
|
if (OLED::getRotation())
|
||||||
#endif
|
#endif
|
||||||
OLED::drawChar('+');
|
OLED::drawChar('+');
|
||||||
else
|
else
|
||||||
@@ -407,7 +407,7 @@ static int gui_SolderingSleepingMode() {
|
|||||||
|| (xTaskGetTickCount() - lastButtonTime < 100))
|
|| (xTaskGetTickCount() - lastButtonTime < 100))
|
||||||
return 0; // user moved or pressed a button, go back to soldering
|
return 0; // user moved or pressed a button, go back to soldering
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
if (checkVoltageForExit())
|
if (checkVoltageForExit())
|
||||||
return 1; // return non-zero on error
|
return 1; // return non-zero on error
|
||||||
#endif
|
#endif
|
||||||
if (systemSettings.temperatureInF) {
|
if (systemSettings.temperatureInF) {
|
||||||
@@ -661,7 +661,7 @@ __DATE__, "Heap: ", "HWMG: ", "HWMP: ", "HWMM: ", "Time: ", "Move: ", "RTip: ",
|
|||||||
#else
|
#else
|
||||||
"Ralim-",
|
"Ralim-",
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void showVersion(void) {
|
void showVersion(void) {
|
||||||
uint8_t screen = 0;
|
uint8_t screen = 0;
|
||||||
@@ -671,9 +671,9 @@ void showVersion(void) {
|
|||||||
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
||||||
OLED::setFont(1); // small font
|
OLED::setFont(1); // small font
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
OLED::print((char *) "V2.06 TS100"); // Print version number
|
OLED::print((char *) "V2.06 TS100"); // Print version number
|
||||||
#else
|
#else
|
||||||
OLED::print((char *) "V2.06 TS80"); // Print version number
|
OLED::print((char *) "V2.06 TS80"); // Print version number
|
||||||
#endif
|
#endif
|
||||||
OLED::setCursor(0, 8); // second line
|
OLED::setCursor(0, 8); // second line
|
||||||
OLED::print(HEADERS[screen]);
|
OLED::print(HEADERS[screen]);
|
||||||
@@ -713,7 +713,7 @@ void showVersion(void) {
|
|||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
OLED::printNumber(idealQCVoltage,3);
|
OLED::printNumber(idealQCVoltage, 3);
|
||||||
#else
|
#else
|
||||||
OLED::print("Tek.com");
|
OLED::print("Tek.com");
|
||||||
#endif
|
#endif
|
||||||
@@ -803,8 +803,9 @@ void startGUITask(void const *argument __unused) {
|
|||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
//Here we re-check for tip presence
|
//Here we re-check for tip presence
|
||||||
if (idealQCVoltage < 90)
|
if (idealQCVoltage < 90)
|
||||||
idealQCVoltage = calculateMaxVoltage(systemSettings.cutoutSetting);
|
idealQCVoltage = calculateMaxVoltage(
|
||||||
seekQC(idealQCVoltage,systemSettings.voltageDiv);
|
systemSettings.cutoutSetting);
|
||||||
|
seekQC(idealQCVoltage, systemSettings.voltageDiv);
|
||||||
#endif
|
#endif
|
||||||
gui_solderingMode(0); // enter soldering mode
|
gui_solderingMode(0); // enter soldering mode
|
||||||
buttonLockout = true;
|
buttonLockout = true;
|
||||||
@@ -866,7 +867,7 @@ void startGUITask(void const *argument __unused) {
|
|||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
if (!OLED::getRotation()) {
|
if (!OLED::getRotation()) {
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
#endif
|
#endif
|
||||||
OLED::drawArea(12, 0, 84, 16, idleScreenBG);
|
OLED::drawArea(12, 0, 84, 16, idleScreenBG);
|
||||||
OLED::setCursor(0, 0);
|
OLED::setCursor(0, 0);
|
||||||
@@ -887,7 +888,7 @@ void startGUITask(void const *argument __unused) {
|
|||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
if (!OLED::getRotation()) {
|
if (!OLED::getRotation()) {
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
#endif
|
#endif
|
||||||
// in right handed mode we want to draw over the first part
|
// in right handed mode we want to draw over the first part
|
||||||
OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp
|
OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp
|
||||||
@@ -916,15 +917,15 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
* We take the current tip temperature & evaluate the next step for the tip
|
* We take the current tip temperature & evaluate the next step for the tip
|
||||||
* control PWM.
|
* control PWM.
|
||||||
*/
|
*/
|
||||||
setTipMilliWatts(0); // disable the output driver if the output is set to be off
|
setTipMilliWatts(0); // disable the output driver if the output is set to be off
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
idealQCVoltage = calculateMaxVoltage(systemSettings.cutoutSetting);
|
idealQCVoltage = calculateMaxVoltage(systemSettings.cutoutSetting);
|
||||||
#endif
|
#endif
|
||||||
uint8_t rawC = ctoTipMeasurement(101) - ctoTipMeasurement(100); // 1*C change in raw.
|
uint8_t rawC = ctoTipMeasurement(101) - ctoTipMeasurement(100); // 1*C change in raw.
|
||||||
currentlyActiveTemperatureTarget = 0; // Force start with no output (off). If in sleep / soldering this will
|
currentlyActiveTemperatureTarget = 0; // Force start with no output (off). If in sleep / soldering this will
|
||||||
// be over-ridden rapidly
|
// be over-ridden rapidly
|
||||||
|
|
||||||
history<int16_t> tempError = {{0}, 0, 0};
|
history<int16_t> tempError = { { 0 }, 0, 0 };
|
||||||
|
|
||||||
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -943,7 +944,8 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
// to be unstable. Use a rolling average to dampen it.
|
// to be unstable. Use a rolling average to dampen it.
|
||||||
// We overshoot by roughly 1/2 of 1 degree Fahrenheit.
|
// We overshoot by roughly 1/2 of 1 degree Fahrenheit.
|
||||||
// This helps stabilize the display.
|
// This helps stabilize the display.
|
||||||
int32_t tError = currentlyActiveTemperatureTarget - rawTemp + rawC/4;
|
int32_t tError = currentlyActiveTemperatureTarget - rawTemp
|
||||||
|
+ rawC / 4;
|
||||||
tError = tError > INT16_MAX ? INT16_MAX : tError;
|
tError = tError > INT16_MAX ? INT16_MAX : tError;
|
||||||
tError = tError < INT16_MIN ? INT16_MIN : tError;
|
tError = tError < INT16_MIN ? INT16_MIN : tError;
|
||||||
tempError.update(tError);
|
tempError.update(tError);
|
||||||
@@ -954,17 +956,21 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
// P term - total power needed to hit target temp next cycle.
|
// P term - total power needed to hit target temp next cycle.
|
||||||
// thermal mass = 1690 milliJ/*C for my tip.
|
// thermal mass = 1690 milliJ/*C for my tip.
|
||||||
// = Watts*Seconds to raise Temp from room temp to +100*C, divided by 100*C.
|
// = Watts*Seconds to raise Temp from room temp to +100*C, divided by 100*C.
|
||||||
// divided by 20 to let I term dominate near set point.
|
// we divide milliWattsNeeded by 20 to let the I term dominate near the set point.
|
||||||
// I should retune this, but don't want to do it until
|
// This is necessary because of the temp noise and thermal lag in the system.
|
||||||
// the feed-forward temp adjustment is in place.
|
// Once we have feed-forward temp estimation we should be able to better tune this.
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
const uint16_t mass = 1690 / 20;
|
const uint16_t mass = 1690 / 20; // divide here so division is compile-time.
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
const uint16_t mass = 1690 / 50;
|
const uint16_t mass = 1690 / 50;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t milliWattsNeeded = tempToMilliWatts(tempError.average(), mass, rawC);
|
int32_t milliWattsNeeded = tempToMilliWatts(tempError.average(),
|
||||||
|
mass, rawC);
|
||||||
|
// note that milliWattsNeeded is sometimes negative, this counters overshoot
|
||||||
|
// from I term's inertia.
|
||||||
milliWattsOut += milliWattsNeeded;
|
milliWattsOut += milliWattsNeeded;
|
||||||
|
|
||||||
// I term - energy needed to compensate for heat loss.
|
// I term - energy needed to compensate for heat loss.
|
||||||
@@ -1000,9 +1006,9 @@ void startMOVTask(void const *argument __unused) {
|
|||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
startQC(systemSettings.voltageDiv);
|
startQC(systemSettings.voltageDiv);
|
||||||
while (idealQCVoltage == 0)
|
while (idealQCVoltage == 0)
|
||||||
osDelay(20); // To ensure we return after idealQCVoltage is setup
|
osDelay(20); // To ensure we return after idealQCVoltage is setup
|
||||||
|
|
||||||
seekQC(idealQCVoltage,systemSettings.voltageDiv);// this will move the QC output to the preferred voltage to start with
|
seekQC(idealQCVoltage, systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
|
||||||
|
|
||||||
#else
|
#else
|
||||||
osDelay(250); // wait for accelerometer to stabilize
|
osDelay(250); // wait for accelerometer to stabilize
|
||||||
@@ -1088,9 +1094,9 @@ void startMOVTask(void const *argument __unused) {
|
|||||||
|
|
||||||
osDelay(100); // Slow down update rate
|
osDelay(100); // Slow down update rate
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
if (currentlyActiveTemperatureTarget) {
|
if (currentlyActiveTemperatureTarget) {
|
||||||
seekQC(idealQCVoltage,systemSettings.voltageDiv); // Run the QC seek again to try and compensate for cable V drop
|
seekQC(idealQCVoltage, systemSettings.voltageDiv); // Run the QC seek again to try and compensate for cable V drop
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ history<uint16_t, oscillationPeriod> milliWattHistory = {{0}, 0, 0};
|
|||||||
|
|
||||||
|
|
||||||
int32_t tempToMilliWatts(int32_t rawTemp, uint16_t mass, uint8_t rawC) {
|
int32_t tempToMilliWatts(int32_t rawTemp, uint16_t mass, uint8_t rawC) {
|
||||||
// mass is in milliJ/*C, rawC is raw per degree C
|
// mass is in milliJ/*C, rawC is raw per degree C
|
||||||
|
// returns milliWatts needed to raise/lower a mass by rawTemp
|
||||||
|
// degrees in one cycle.
|
||||||
int32_t milliJoules = mass * rawTemp / rawC;
|
int32_t milliJoules = mass * rawTemp / rawC;
|
||||||
return milliJoules * hz;
|
return milliJoules * hz;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user