PID works with max PWM of 255
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
#ifndef POWER_HPP_
|
||||
#define POWER_HPP_
|
||||
|
||||
extern history<uint16_t, 75> milliWattHistory;
|
||||
const uint8_t hz = 32;
|
||||
const uint8_t oscillationPeriod = 3.5 * hz;
|
||||
extern history<uint16_t, oscillationPeriod> milliWattHistory;
|
||||
|
||||
int32_t tempToMilliWatts(int32_t rawTemp, uint16_t mass, uint8_t rawC);
|
||||
void setTipMilliWatts(int32_t mw);
|
||||
|
||||
@@ -929,6 +929,7 @@ void startPIDTask(void const *argument __unused) {
|
||||
int32_t rawC = ctoTipMeasurement(100) - ctoTipMeasurement(101); // 1*C change in raw.
|
||||
currentlyActiveTemperatureTarget = 0; // Force start with no output (off). If in sleep / soldering this will
|
||||
// be over-ridden rapidly
|
||||
|
||||
history<int16_t> tempError = {{0}, 0, 0};
|
||||
|
||||
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
||||
@@ -955,8 +956,8 @@ void startPIDTask(void const *argument __unused) {
|
||||
// P term - total power needed to hit target temp next cycle.
|
||||
// thermal mass = 1690 milliJ/*C for my tip.
|
||||
// = Watts*Seconds to raise Temp from room temp to +100*C, divided by 100*C.
|
||||
// divided by 4 to let I term dominate near set point.
|
||||
const uint16_t mass = 1690 / 4;
|
||||
// divided by 8 to let I term dominate near set point.
|
||||
const uint16_t mass = 1690 / 8;
|
||||
int32_t milliWattsNeeded = tempToMilliWatts(tempError.average(), mass, rawC);
|
||||
milliWattsOut += milliWattsNeeded;
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include <Settings.h>
|
||||
#include <hardware.h>
|
||||
|
||||
history<uint16_t, 75> milliWattHistory = {{0}, 0, 0};
|
||||
|
||||
const uint8_t tipResistance = 87;
|
||||
const uint8_t hz = 33;
|
||||
const uint8_t maxPWM = 100;
|
||||
const uint8_t maxPWM = 255;
|
||||
|
||||
history<uint16_t, oscillationPeriod> milliWattHistory = {{0}, 0, 0};
|
||||
|
||||
|
||||
int32_t tempToMilliWatts(int32_t rawTemp, uint16_t mass, uint8_t rawC) {
|
||||
// mass is in milliJ/*C, rawC is raw per degree C
|
||||
|
||||
Reference in New Issue
Block a user