Skip to content

Commit

Permalink
Refactor PinecilV2 Tuning
Browse files Browse the repository at this point in the history
Closes #1688
  • Loading branch information
Ralim committed Jun 4, 2023
1 parent 286afad commit e7bcf92
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
2 changes: 2 additions & 0 deletions source/Core/BSP/BSP_Power.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void power_check();
uint8_t getTipResistanceX10();

uint8_t getTipThermalMass();
uint8_t getTipInertia();


#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion source/Core/BSP/MHP30/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,5 @@ uint64_t getDeviceID() {

uint8_t preStartChecksDone() { return 1; }

uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_MASS; }
4 changes: 3 additions & 1 deletion source/Core/BSP/Miniware/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,6 @@ uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }

uint8_t preStartChecksDone() { return 1; }

uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }

uint8_t getTipInertia() { return TIP_THERMAL_MASS; }
3 changes: 2 additions & 1 deletion source/Core/BSP/Pinecil/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }

uint8_t preStartChecksDone() { return 1; }

uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_MASS; }
14 changes: 9 additions & 5 deletions source/Core/BSP/Pinecilv2/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const uint8_t tempMeasureTicks = 25;
uint16_t totalPWM = 255; // Total length of the cycle's ticks

void resetWatchdog() {
//#TODO
// #TODO
}

#ifdef TEMP_NTC
Expand Down Expand Up @@ -125,9 +125,7 @@ uint8_t getButtonB() {
return val;
}

void reboot() {
hal_system_reset();
}
void reboot() { hal_system_reset(); }

void delay_ms(uint16_t count) {
// delay_1ms(count);
Expand Down Expand Up @@ -164,7 +162,13 @@ uint8_t getTipThermalMass() {
if (lastTipResistance >= 80) {
return TIP_THERMAL_MASS;
}
return (TIP_THERMAL_MASS * 25) / 10;
return 45;
}
uint8_t getTipInertia() {
if (lastTipResistance >= 80) {
return TIP_THERMAL_MASS;
}
return 10;
}
// We want to calculate lastTipResistance
// If tip is connected, and the tip is cold and the tip is not being heated
Expand Down
3 changes: 2 additions & 1 deletion source/Core/BSP/Sequre_S60/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }

uint8_t preStartChecksDone() { return 1; }

uint8_t getTipThermalMass() { return TIP_THERMAL_INERTIA; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_INERTIA; }

void setBuzzer(bool on) {}
8 changes: 4 additions & 4 deletions source/Core/Threads/PIDThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ int32_t getPIDResultX10Watts(int32_t setpointDelta) {
// power CMOS is controlled by TIM3->CTR1 (that is software modulated - on/off - by TIM2-CTR4 interrupts). However,
// TIM3->CTR1 is configured with a duty cycle of 50% so, in real, we get only 50% of the presumed power output
// so we basically double the need (gain = 2) to get what we want.
return powerStore.update(TIP_THERMAL_MASS * setpointDelta, // the required power
getTipThermalMass(), // Inertia, smaller numbers increase dominance of the previous value
2, // gain
rate, // PID cycle frequency
return powerStore.update(getTipThermalMass() * setpointDelta, // the required power
getTipInertia(), // Inertia, smaller numbers increase dominance of the previous value
2, // gain
rate, // PID cycle frequency
getX10WattageLimits());
}

Expand Down

0 comments on commit e7bcf92

Please sign in to comment.