Przeglądaj źródła

Limit PID autotune PWM to PID_MAX

Erik van der Zalm 13 lat temu
rodzic
commit
e31bef31ad
1 zmienionych plików z 5 dodań i 5 usunięć
  1. 5
    5
      Marlin/temperature.cpp

+ 5
- 5
Marlin/temperature.cpp Wyświetl plik

134
   long t_high;
134
   long t_high;
135
   long t_low;
135
   long t_low;
136
 
136
 
137
-  long bias=127;
138
-  long d = 127;
137
+  long bias=PID_MAX/2;
138
+  long d = PID_MAX/2;
139
   float Ku, Tu;
139
   float Ku, Tu;
140
   float Kp, Ki, Kd;
140
   float Kp, Ki, Kd;
141
   float max, min;
141
   float max, min;
144
   
144
   
145
   disable_heater(); // switch off all heaters.
145
   disable_heater(); // switch off all heaters.
146
   
146
   
147
-  soft_pwm[0] = 255>>1;
147
+  soft_pwm[0] = PID_MAX/2;
148
     
148
     
149
   for(;;) {
149
   for(;;) {
150
 
150
 
172
           t_low=t2 - t1;
172
           t_low=t2 - t1;
173
           if(cycles > 0) {
173
           if(cycles > 0) {
174
             bias += (d*(t_high - t_low))/(t_low + t_high);
174
             bias += (d*(t_high - t_low))/(t_low + t_high);
175
-            bias = constrain(bias, 20 ,235);
176
-            if(bias > 127) d = 254 - bias;
175
+            bias = constrain(bias, 20 ,PID_MAX-20);
176
+            if(bias > PID_MAX/2) d = PID_MAX - 1 - bias;
177
             else d = bias;
177
             else d = bias;
178
 
178
 
179
             SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
179
             SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);

Ładowanie…
Anuluj
Zapisz