DEV2: Description of dead time heater
I think there is a copy/paste mistake in the description of the dynamic dead time control: https://docfirmwarev2.repetier.com/config/heater_and_cooler
Each of it has to be done for increasing and decreasing temperature. So you in the deacreasing curve you simply switch of the heater and the graph including its linear extrapolations is basivally flipped up/down. Is that right?
Could you please offer what the variables in
HEAT_MANAGER_DYN_DEAD_TIME(HeaterExtruder1, 'E', 0, TempExt1, PWMExtruder1, 260, 255, 50, 5, 2000, 150, 1, 1, 1, 1, 1, false)
HEAT_MANAGER_DYN_DEAD_TIME(name, tp, index, input, output, maxTemp, maxPwm, sampleTime, decVariance, decPeriod, time1, up1, down1, time2, up2, down2, hotPlugable)
are?
I do not understand these:
time1, up1, down1, time2, up2, down2
I found this description:
/*
Dynamic Dead Time
The normal dead time assumes same time for heating and cooling. Reality is that these
differ. They even differ over temperatures, especially cooling at high temperatures
is much faster then for lower temperatures. So what we really need are 2 sets - one for
the high temperatures and one for the lower ones, then we can interpolate timings.
deadUp is time to stop heating until the curve slows down.
deadDown is time to start heating until you will see a raise.
*/
From this I would have expected
temp1,uptime1,downtime1,temp2,uptime2,downtime2
Is it correct to determine
1. The deadtime at low temperatures using this: https://www.repetier.com/dead-time-control/ , for example at 180°C --> meaning I set a constant PWM and wait till stable temperature. Than I set PWM to 255 and watch the curve.
2. The deadtime at high temperatures in the same way, for example at 230°C
Comments
So to measure temperatures go to the temperature until it is stabalized and then go to pwm 255(up) or 0(down) depending on time you measure.
Problem is to get the stable temperature first. When you are on PID it would be easy though to do the measurements.
But somehow that controller is not really that convincing as I hoped. At least in my tests.
Maybe there should be better tests to calibrate that. But this system always needs an error to enable/disable heater so it is not possible to stabilize. It is more a bang-bang with improved timings to reduce the swing fast and as good as possible and then stay with some minimal swing.
One can find this calculation code in heatmanager.cpp:
scale = (targetTemperature - temp1) / (temp2 - temp1);
a=(deadUp2-deadUp1)/(temp2-temp1)
So I did useless work. Mathematically it is the same like the original code.
That means the two calibration points can be anywhere. It inter- and EXTRApolates the parameters. I was not sure if the values deadUp1/2 additionally give the maximum and minimum value of deadUp and DeadDown. So the calculated deadUp/Down can be larger/smaller than both values of calibration. But I see no limitation to valued between deadUp1 and deadUp2 and so on.
I will try to calibrate it and send my results later (maybe at the weekend). I think it should be faster than PID, but less stable, as described above.
I tried the following to manage to set the PWM of the heater without regulation:
M106 P0 S70 --> Wait for a stable temperature (don't look at it, it will take longer than)
M106 P0 S255 --> wait till it looks linear or becomes too hot
M106 P0 S0
But I see also how stable temperature stays with fixed pwm. So if we measure for 10%..20%..100% and store temperature we could have a base pwm for each temperature. Just like the I term in PID controller. Then we do the up/down swings just with using 120% or 80% of the base pwm to compensate filament speed and cooler fan. Also we could also add tests with fan on/off as well. Then we are more or less directly setting correct pwm and use only some control to react on the error. Maybe combining it with pid would also be good.
For users with heated chamber there might be another unknown. A hotter chamber will reduce required energy.
Also we might be able to compute the energy needed to heat up extruder to old temperature when we start extruding x mm/s. We know material added per second and can correlate this with extra energy in pwm pulses. Then we add that depending on E speed of current moves. Should also reduce swinging introduction.
When combining this with PID so we can really settle at a nearly perfect solution we need some delayed pid start. We must wait until temperature is nearly stable and then start with pid. Would then probably overswing but since we start with much smaller errors and have less influence the overswings will be much smaller. Same with combining it with dead time.
The best would be a combination. Full power until T-20 then using dead time for exact disable time. When we are close to target temperature or temps start to fall we set I to precomputed pwm and then switch to PID. So dead time prevents first overshoot and we start with theoretical ideal values. Then we also only need one dead time value for coming from top.
At least if we increase temperature. For lowering temperature it would be other way around. No power until we know we need power and then already set correct PWM. when starting to raise or cross set temp. we switch to PID.
Causes lots of variables to measure but would give a fast switching controller with fast pid converging. Already thinking when I get the time for this one:-)
A fast approximation for setting up dead time could be to measure after a delay of two times longer than roughly expected dead time. Than do a scond measurement after 5 additional seconds and extrapolate when the linear curve hits the start temperature.
A different heater will NOT change the curve. It will just change the value on the x-axis. Every PWM corresponds to a certain Power (in W). It will not change the curvature if you have to set PWM=200 or PWM=100 for a desired value. In fact in both cases you for example P=15W or so.
Mathematical description:
I would assume a behaviour like
T(x)=a x^b+c
where x is the PWM value. T is the Temperature; a,b,c consants which will be determined.
c is T(0), that's simply the offset to clarify, that we do not start at (0|0), but (0|21) for example.
T(x)=a x^b+T(0) | -T(0)
T(x)-T(0)= ax^b | define DT(x)=T(x)-T(0)
DT(x)=ax^b formula (I)
Measure two points:
In my case I use the following:
T(95)=244 --> DT(95)=223=DT(x2), with x2=95
T(40)=108 --> DT(40)=87 =DT(x1), with x1=40
To determine the exponent, one can use the slope in a log-log-plot, determined via the differential coefficient:
b= Slope=(y2-y2)/(x2-x1)
in log-log-Plot:
b=(log(T(x2)-log(T(x1) ) / (log (x2)-log(x1)) (this is the first thing which needs to be calculated during calibration)
= (log( 223)-log(87))/(log(95)-log(40))
= 0.8382
To determine a put in b and (x2|T(x2)) in formula (I):
DT(x2)= a x2^0.8382
223=a *95^0.8382 | : 95^0.8382
a=223/(95^0.8382)=4.90
or in general:
a=DT(x2)/x2^b (this is the second thing which needs to be calculated during calibration)
Put a and b in (I):
DT(x)=4.90 x^0.8382
You can find this now in the excel file: https://drive.google.com/file/d/13Wh_YBVejoOSkGHyXPewPyCnBJ3VnelZ/view?usp=sharing
The upper formula describes the temperature at a given PWM. Lets find x:
DT(x)=4.9 x^0.8382 | : 4.9
DT(x)/4.9 = x^0.8382 | ^1/0.8382
(DT(x)/4.9)^(1/0.8382) =x
edit:
x=((Tdesired-Troom)/4.9)^(1/0.8382) (this is the calucation of the PWM in dependence of room temperature and desired temperature)
So there we are. Measuring T(0PWM), T(40PWM) and T(95PWM) as calibration is fine. The deaviation is 4°C. Combined with a regulation dyndeadtime that could be fine.