Browse Source

cleanup for pull

Mark Finn 13 years ago
parent
commit
04631d2250
3 changed files with 50 additions and 21 deletions
  1. 34
    7
      Marlin/Configuration.h
  2. 1
    4
      Marlin/Configuration_adv.h
  3. 15
    10
      Marlin/temperature.cpp

+ 34
- 7
Marlin/Configuration.h View File

95
 // PID settings:
95
 // PID settings:
96
 // Comment the following line to disable PID and enable bang-bang.
96
 // Comment the following line to disable PID and enable bang-bang.
97
 #define PIDTEMP
97
 #define PIDTEMP
98
-#define PIDTEMPBED
99
 #define PID_MAX 255 // limits current to nozzle; 255=full current
98
 #define PID_MAX 255 // limits current to nozzle; 255=full current
100
 #ifdef PIDTEMP
99
 #ifdef PIDTEMP
101
   //#define PID_DEBUG // Sends debug data to the serial port. 
100
   //#define PID_DEBUG // Sends debug data to the serial port. 
115
 //    #define  DEFAULT_Ki 0.1  
114
 //    #define  DEFAULT_Ki 0.1  
116
 //    #define  DEFAULT_Kd 12  
115
 //    #define  DEFAULT_Kd 12  
117
 
116
 
117
+// Mendel Parts V9 on 12V    
118
+//    #define  DEFAULT_Kp 63.0
119
+//    #define  DEFAULT_Ki 2.25
120
+//    #define  DEFAULT_Kd 440
121
+#endif // PIDTEMP
122
+
123
+// Bed Temperature Control
124
+// Select PID or bang-bang with PIDTEMPBED.  If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
125
+//
126
+// uncomment this to enable PID on the bed.   It uses the same ferquency PWM as the extruder. 
127
+// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
128
+// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
129
+// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. 
130
+// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly 
131
+// shouldn't use bed PID until someone else verifies your hardware works.
132
+// If this is enabled, find your own PID constants below.
133
+//#define PIDTEMPBED
134
+//
135
+//#define BED_LIMIT_SWITCHING
136
+
137
+// This sets the max power delived to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
138
+// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
139
+// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
140
+// so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
141
+#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
142
+
143
+#ifdef PIDTEMPBED
144
+//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
118
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, argressive factor of .15 (vs .1, 1, 10)
145
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, argressive factor of .15 (vs .1, 1, 10)
119
     #define  DEFAULT_bedKp 10.00
146
     #define  DEFAULT_bedKp 10.00
120
     #define  DEFAULT_bedKi .023
147
     #define  DEFAULT_bedKi .023
121
     #define  DEFAULT_bedKd 305.4
148
     #define  DEFAULT_bedKd 305.4
122
 
149
 
123
-//mark from pidautotune
150
+//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
151
+//from pidautotune
124
 //    #define  DEFAULT_bedKp 97.1
152
 //    #define  DEFAULT_bedKp 97.1
125
 //    #define  DEFAULT_bedKi 1.41
153
 //    #define  DEFAULT_bedKi 1.41
126
 //    #define  DEFAULT_bedKd 1675.16
154
 //    #define  DEFAULT_bedKd 1675.16
127
 
155
 
128
-// Mendel Parts V9 on 12V    
129
-//    #define  DEFAULT_Kp 63.0
130
-//    #define  DEFAULT_Ki 2.25
131
-//    #define  DEFAULT_Kd 440
132
-#endif // PIDTEMP
156
+// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
157
+#endif // PIDTEMPBED
158
+
159
+
133
 
160
 
134
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
161
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
135
 //can be software-disabled for whatever purposes by
162
 //can be software-disabled for whatever purposes by

+ 1
- 4
Marlin/Configuration_adv.h View File

5
 //=============================Thermal Settings  ============================
5
 //=============================Thermal Settings  ============================
6
 //===========================================================================
6
 //===========================================================================
7
 
7
 
8
-// Select one of these only to define how the bed temp is read.
9
-//
10
-//#define BED_LIMIT_SWITCHING
11
 #ifdef BED_LIMIT_SWITCHING
8
 #ifdef BED_LIMIT_SWITCHING
12
   #define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
9
   #define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
13
 #endif
10
 #endif
14
-#define BED_CHECK_INTERVAL 5000 //ms
11
+#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
15
 
12
 
16
 //// Heating sanity check:
13
 //// Heating sanity check:
17
 // This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
14
 // This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature

+ 15
- 10
Marlin/temperature.cpp View File

153
   long t_high;
153
   long t_high;
154
   long t_low;
154
   long t_low;
155
 
155
 
156
-  long bias=PID_MAX/2;
157
-  long d = PID_MAX/2;
156
+  long bias, d;
158
   float Ku, Tu;
157
   float Ku, Tu;
159
   float Kp, Ki, Kd;
158
   float Kp, Ki, Kd;
160
   float max, min;
159
   float max, min;
173
   disable_heater(); // switch off all heaters.
172
   disable_heater(); // switch off all heaters.
174
 
173
 
175
 	if (extruder<0)
174
 	if (extruder<0)
176
-	  soft_pwm_bed = PID_MAX/2;
175
+	{
176
+	 	soft_pwm_bed = (PID_MAX_BED)/2;
177
+		bias = d = (PID_MAX_BED)/2;
178
+  }
177
 	else
179
 	else
178
-	  soft_pwm[extruder] = PID_MAX/2;
180
+	{
181
+	  soft_pwm[extruder] = (PID_MAX)/2;
182
+		bias = d = (PID_MAX)/2;
183
+  }
179
 
184
 
180
 
185
 
181
 
186
 
209
           t_low=t2 - t1;
214
           t_low=t2 - t1;
210
           if(cycles > 0) {
215
           if(cycles > 0) {
211
             bias += (d*(t_high - t_low))/(t_low + t_high);
216
             bias += (d*(t_high - t_low))/(t_low + t_high);
212
-            bias = constrain(bias, 20 ,PID_MAX-20);
213
-            if(bias > PID_MAX/2) d = PID_MAX - 1 - bias;
217
+            bias = constrain(bias, 20 ,(extruder<0?(PID_MAX_BED):(PID_MAX))-20);
218
+            if(bias > (extruder<0?(PID_MAX_BED):(PID_MAX))/2) d = (extruder<0?(PID_MAX_BED):(PID_MAX)) - 1 - bias;
214
             else d = bias;
219
             else d = bias;
215
 
220
 
216
             SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
221
             SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
414
 		  dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
419
 		  dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
415
 		  temp_dState_bed = pid_input;
420
 		  temp_dState_bed = pid_input;
416
 
421
 
417
-		  pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, PID_MAX);
422
+		  pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, PID_MAX_BED);
418
 
423
 
419
     #else 
424
     #else 
420
-      pid_output = constrain(pid_setpoint_bed, 0, PID_MAX);
425
+      pid_output = constrain(pid_setpoint_bed, 0, PID_MAX_BED);
421
     #endif //PID_OPENLOOP
426
     #endif //PID_OPENLOOP
422
 
427
 
423
 	  if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) 
428
 	  if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) 
437
         }
442
         }
438
         else 
443
         else 
439
         {
444
         {
440
-					soft_pwm_bed = 100;
445
+					soft_pwm_bed = PID_MAX_BED>>1;
441
         }
446
         }
442
       }
447
       }
443
       else {
448
       else {
454
         else 
459
         else 
455
           if(current_raw_bed <= target_bed_low_temp)
460
           if(current_raw_bed <= target_bed_low_temp)
456
         {
461
         {
457
-					soft_pwm_bed = 100;
462
+					soft_pwm_bed = PID_MAX_BED>>1;
458
         }
463
         }
459
       }
464
       }
460
       else {
465
       else {

Loading…
Cancel
Save