1
0
forked from me/IronOS

Better limiter in the PID

This commit is contained in:
Ben V. Brown
2021-09-15 19:05:11 +10:00
parent a213f4bd97
commit bfca4c9336
3 changed files with 6 additions and 8 deletions

View File

@@ -22,7 +22,8 @@
const uint8_t wattHistoryFilter = 24; // I term look back weighting
extern expMovingAverage<uint32_t, wattHistoryFilter> x10WattHistory;
int32_t tempToX10Watts(int32_t rawTemp);
void setTipX10Watts(int32_t mw);
uint8_t X10WattsToPWM(int32_t milliWatts, uint8_t sample = 0);
uint32_t availableW10(uint8_t sample);
int32_t tempToX10Watts(int32_t rawTemp);
void setTipX10Watts(int32_t mw);
uint8_t X10WattsToPWM(int32_t milliWatts, uint8_t sample = 0);
#endif /* POWER_HPP_ */

View File

@@ -44,7 +44,7 @@ void setTipX10Watts(int32_t mw) {
x10WattHistory.update(actualMilliWatts);
}
static uint32_t availableW10(uint8_t sample) {
uint32_t availableW10(uint8_t sample) {
// P = V^2 / R, v*v = v^2 * 100
// R = R*10
// P therefore is in V^2*100/R*10 = W*10.

View File

@@ -171,10 +171,7 @@ void detectThermalRunaway(const int16_t currentTipTempInC, const int tError) {
}
int32_t getX10WattageLimits() {
const auto vin = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
int32_t limit = ((vin * vin) * tipResistance);
limit *= 12; // Default to 20% over
limit /= 100;
int32_t limit = availableW10(0);
if (getSettingValue(SettingsOptions::PowerLimit) && limit > (getSettingValue(SettingsOptions::PowerLimit) * 10)) {
limit = getSettingValue(SettingsOptions::PowerLimit) * 10;