Browse Source

Merged multiple extruder support.

Soft PWM. (Sanguinololu can also have PID temperature control)
Interrupt save WRITE for addresses > 0x0FF
Erik van der Zalm 12 years ago
parent
commit
e017228569
11 changed files with 5525 additions and 5413 deletions
  1. 49
    46
      Marlin/Configuration.h
  2. 0
    2
      Marlin/Marlin.h
  3. 27
    19
      Marlin/Marlin.pde
  4. 2581
    2572
      Marlin/fastio.h
  5. 736
    737
      Marlin/pins.h
  6. 2
    2
      Marlin/planner.cpp
  7. 56
    24
      Marlin/stepper.cpp
  8. 15
    0
      Marlin/stepper.h
  9. 74
    31
      Marlin/temperature.cpp
  10. 143
    142
      Marlin/temperature.h
  11. 1842
    1838
      Marlin/ultralcd.pde

+ 49
- 46
Marlin/Configuration.h View File

@@ -4,11 +4,11 @@
4 4
 
5 5
 
6 6
 // This determines the communication speed of the printer
7
-//#define BAUDRATE 250000
8
-#define BAUDRATE 115200
7
+#define BAUDRATE 250000
8
+//#define BAUDRATE 115200
9 9
 //#define BAUDRATE 230400
10 10
 
11
-#define EXTRUDERS 2
11
+#define EXTRUDERS 1
12 12
 
13 13
 // Frequency limit
14 14
 // See nophead's blog for more info
@@ -32,7 +32,7 @@
32 32
 // Sanguinololu 1.2 and above = 62
33 33
 // Ultimaker = 7,
34 34
 // Teensylu = 8
35
-#define MOTHERBOARD 33
35
+#define MOTHERBOARD 7
36 36
 
37 37
 //===========================================================================
38 38
 //=============================Thermal Settings  ============================
@@ -46,16 +46,21 @@
46 46
 // 5 is ParCan supplied 104GT-2 100K
47 47
 // 6 is EPCOS 100k
48 48
 // 7 is 100k Honeywell thermistor 135-104LAG-J01
49
-#define THERMISTORHEATER_0 1
50
-#define THERMISTORHEATER_1 1
51
-#define HEATER_0_USES_THERMISTOR
52
-#define HEATER_1_USES_THERMISTOR
53
-//#define HEATER_0_USES_AD595
49
+
50
+//#define THERMISTORHEATER_0 3
51
+//#define THERMISTORHEATER_1 1
52
+//#define THERMISTORHEATER_2 1
53
+
54
+//#define HEATER_0_USES_THERMISTOR
55
+//#define HEATER_1_USES_THERMISTOR
56
+//#define HEATER_2_USES_THERMISTOR
57
+#define HEATER_0_USES_AD595
54 58
 //#define HEATER_1_USES_AD595
59
+//#define HEATER_2_USES_AD595
55 60
 
56 61
 // Select one of these only to define how the bed temp is read.
57
-#define THERMISTORBED 1
58
-#define BED_USES_THERMISTOR
62
+//#define THERMISTORBED 1
63
+//#define BED_USES_THERMISTOR
59 64
 //#define BED_USES_AD595
60 65
 
61 66
 #define BED_CHECK_INTERVAL 5000 //ms
@@ -73,7 +78,8 @@
73 78
 //// The minimal temperature defines the temperature below which the heater will not be enabled
74 79
 #define HEATER_0_MINTEMP 5
75 80
 //#define HEATER_1_MINTEMP 5
76
-#define BED_MINTEMP 5
81
+//#define HEATER_2_MINTEMP 5
82
+//#define BED_MINTEMP 5
77 83
 
78 84
 
79 85
 // When temperature exceeds max temp, your heater will be switched off.
@@ -81,7 +87,8 @@
81 87
 // You should use MINTEMP for thermistor short/failure protection.
82 88
 #define HEATER_0_MAXTEMP 275
83 89
 //#define HEATER_1_MAXTEMP 275
84
-#define BED_MAXTEMP 150
90
+//#define HEATER_2_MAXTEMP 275
91
+//#define BED_MAXTEMP 150
85 92
 
86 93
 
87 94
 // Wait for Cooldown
@@ -92,21 +99,17 @@
92 99
 
93 100
 // Heating is finished if a temperature close to this degree shift is reached
94 101
 #define HEATING_EARLY_FINISH_DEG_OFFSET 1 //Degree
102
+
95 103
 // PID settings:
96 104
 // Uncomment the following line to enable PID support.
97
-  
98 105
 #define PIDTEMP
106
+#define PID_MAX 255 // limits current to nozzle; 255=full current
99 107
 #ifdef PIDTEMP
100
-  #if MOTHERBOARD == 62
101
-    #error Sanguinololu does not support PID, sorry. Please disable it.
102
-  #endif
103 108
   //#define PID_DEBUG // Sends debug data to the serial port. 
104 109
   //#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
105
-  
106
-  #define PID_MAX 255 // limits current to nozzle; 255=full current
107 110
   #define PID_INTEGRAL_DRIVE_MAX 255  //limit for the integral term
108 111
   #define K1 0.95 //smoothing factor withing the PID
109
-  #define PID_dT 0.1 //sampling period of the PID
112
+  #define PID_dT 0.128 //sampling period of the PID
110 113
 
111 114
   //To develop some PID settings for your machine, you can initiall follow 
112 115
   // the Ziegler-Nichols method.
@@ -130,14 +133,14 @@
130 133
 //    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
131 134
 
132 135
 // Ultitmaker
133
-//    #define  DEFAULT_Kp  22.2
134
-//    #define  DEFAULT_Ki (1.25*PID_dT)  
135
-//    #define  DEFAULT_Kd (99/PID_dT)  
136
+    #define  DEFAULT_Kp  22.2
137
+    #define  DEFAULT_Ki (1.25*PID_dT)  
138
+    #define  DEFAULT_Kd (99/PID_dT)  
136 139
 
137 140
 // Makergear
138
-    #define  DEFAULT_Kp 7.0
139
-    #define  DEFAULT_Ki 0.1  
140
-    #define  DEFAULT_Kd 12  
141
+//    #define  DEFAULT_Kp 7.0
142
+//    #define  DEFAULT_Ki 0.1  
143
+//    #define  DEFAULT_Kd 12  
141 144
 
142 145
 // Mendel Parts V9 on 12V    
143 146
 //    #define  DEFAULT_Kp  63.0
@@ -170,12 +173,12 @@
170 173
 #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
171 174
 
172 175
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
173
-const bool X_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops. 
174
-const bool Y_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops. 
175
-const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops. 
176
+const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
177
+const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
178
+const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
176 179
 // For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
177 180
 
178
-//#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
181
+#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
179 182
 
180 183
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
181 184
 #define X_ENABLE_ON 0
@@ -186,7 +189,7 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
186 189
 // Disables axis when it's not being used.
187 190
 #define DISABLE_X false
188 191
 #define DISABLE_Y false
189
-#define DISABLE_Z true
192
+#define DISABLE_Z false
190 193
 #define DISABLE_E false // For all extruders
191 194
 
192 195
 // Inverting axis direction
@@ -195,11 +198,11 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
195 198
 //#define INVERT_Z_DIR false    // for Mendel set to false, for Orca set to true
196 199
 //#define INVERT_E*_DIR true   // for direct drive extruder v9 set to true, for geared extruder set to false, used for all extruders
197 200
 
198
-#define INVERT_X_DIR false    // for Mendel set to false, for Orca set to true
201
+#define INVERT_X_DIR true    // for Mendel set to false, for Orca set to true
199 202
 #define INVERT_Y_DIR false    // for Mendel set to true, for Orca set to false
200 203
 #define INVERT_Z_DIR true     // for Mendel set to false, for Orca set to true
201 204
 #define INVERT_E0_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
202
-#define INVERT_E1_DIR true    // for direct drive extruder v9 set to true, for geared extruder set to false
205
+#define INVERT_E1_DIR false    // for direct drive extruder v9 set to true, for geared extruder set to false
203 206
 #define INVERT_E2_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
204 207
 
205 208
 //// ENDSTOP SETTINGS:
@@ -208,15 +211,15 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
208 211
 #define Y_HOME_DIR -1
209 212
 #define Z_HOME_DIR -1
210 213
 
211
-#define min_software_endstops false //If true, axis won't move to coordinates less than zero.
212
-#define max_software_endstops false  //If true, axis won't move to coordinates greater than the defined lengths below.
213
-#define X_MAX_LENGTH 210
214
-#define Y_MAX_LENGTH 210
215
-#define Z_MAX_LENGTH 210
214
+#define min_software_endstops true //If true, axis won't move to coordinates less than zero.
215
+#define max_software_endstops true  //If true, axis won't move to coordinates greater than the defined lengths below.
216
+#define X_MAX_LENGTH 205
217
+#define Y_MAX_LENGTH 205
218
+#define Z_MAX_LENGTH 200
216 219
 
217 220
 //// MOVEMENT SETTINGS
218 221
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
219
-#define HOMING_FEEDRATE {30*60, 30*60, 2*60, 0}  // set the homing speeds (mm/min)
222
+#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
220 223
 
221 224
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
222 225
 #define X_HOME_RETRACT_MM 5 
@@ -230,9 +233,9 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
230 233
 
231 234
 // default settings 
232 235
 
233
-//#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
234
-//#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} //sells mendel with v9 extruder
235
-#define DEFAULT_AXIS_STEPS_PER_UNIT   {80.3232, 80.8900, 2284.7651, 757.2218} // SAE Prusa w/ Wade extruder
236
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
237
+//#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 360} //sells mendel with v9 extruder
238
+//#define DEFAULT_AXIS_STEPS_PER_UNIT   {80.3232, 80.8900, 2284.7651, 757.2218} // SAE Prusa w/ Wade extruder
236 239
 #define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 45}    // (mm/sec)    
237 240
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
238 241
 
@@ -283,10 +286,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
283 286
 // hooke's law says:		force = k * distance
284 287
 // bernoulli's priniciple says:	v ^ 2 / 2 + g . h + pressure / density = constant
285 288
 // so: v ^ 2 is proportional to number of steps we advance the extruder
286
-//#define ADVANCE
289
+#define ADVANCE
287 290
 
288 291
 #ifdef ADVANCE
289
-  #define EXTRUDER_ADVANCE_K .3
292
+  #define EXTRUDER_ADVANCE_K .0
290 293
 
291 294
   #define D_FILAMENT 2.85
292 295
   #define STEPS_MM_E 836
@@ -298,10 +301,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
298 301
 
299 302
 //LCD and SD support
300 303
 //#define ULTRA_LCD  //general lcd support, also 16x2
301
-#define SDSUPPORT // Enable SD Card Support in Hardware Console
304
+//#define SDSUPPORT // Enable SD Card Support in Hardware Console
302 305
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
303 306
 
304
-//#define ULTIPANEL
307
+#define ULTIPANEL
305 308
 #ifdef ULTIPANEL
306 309
   //#define NEWPANEL  //enable this if you have a click-encoder panel
307 310
   #define SDSUPPORT

+ 0
- 2
Marlin/Marlin.h View File

@@ -57,8 +57,6 @@ const prog_char echomagic[] PROGMEM ="echo:";
57 57
 
58 58
 #define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
59 59
 
60
-// Macro for getting current active extruder
61
-#define ACTIVE_EXTRUDER (active_extruder)
62 60
 
63 61
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
64 62
 #define SerialprintPGM(x) serialprintPGM(MYPGM(x))

+ 27
- 19
Marlin/Marlin.pde View File

@@ -465,16 +465,16 @@ FORCE_INLINE bool code_seen(char code)
465 465
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
466 466
     destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
467 467
     feedrate = homing_feedrate[LETTER##_AXIS]; \
468
-    prepare_move(); \
468
+    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
469 469
     \
470 470
     current_position[LETTER##_AXIS] = 0;\
471 471
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
472 472
     destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
473
-    prepare_move(); \
473
+    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
474 474
     \
475 475
     destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
476 476
     feedrate = homing_feedrate[LETTER##_AXIS]/2 ;  \
477
-    prepare_move(); \
477
+    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
478 478
     \
479 479
     current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
480 480
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
@@ -541,6 +541,7 @@ FORCE_INLINE void process_commands()
541 541
       if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) )  //first diagonal move
542 542
       {
543 543
         current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
544
+
544 545
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); 
545 546
         destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
546 547
         destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR; 
@@ -723,7 +724,7 @@ FORCE_INLINE void process_commands()
723 724
       if (code_seen('S')) setTargetBed(code_value());
724 725
       break;
725 726
     case 105 : // M105
726
-      tmp_extruder = ACTIVE_EXTRUDER;
727
+      tmp_extruder = active_extruder;
727 728
       if(code_seen('T')) {
728 729
         tmp_extruder = code_value();
729 730
         if(tmp_extruder >= EXTRUDERS) {
@@ -744,6 +745,10 @@ FORCE_INLINE void process_commands()
744 745
         SERIAL_ERROR_START;
745 746
         SERIAL_ERRORLNPGM("No thermistors - no temp");
746 747
       #endif
748
+      #ifdef PIDTEMP
749
+        SERIAL_PROTOCOLPGM(" @:");
750
+        SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));  
751
+      #endif
747 752
         SERIAL_PROTOCOLLN("");
748 753
       return;
749 754
       break;
@@ -788,24 +793,26 @@ FORCE_INLINE void process_commands()
788 793
         while((residencyStart == -1) ||
789 794
               (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
790 795
       #else
791
-        while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
796
+        while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
792 797
       #endif //TEMP_RESIDENCY_TIME
793 798
           if( (millis() - codenum) > 1000 ) 
794 799
           { //Print Temp Reading and remaining time every 1 second while heating up/cooling down
795 800
             SERIAL_PROTOCOLPGM("T:");
796
-            SERIAL_PROTOCOLLN( degHotend(tmp_extruder) ); 
801
+            SERIAL_PROTOCOL( degHotend(tmp_extruder) ); 
797 802
             SERIAL_PROTOCOLPGM(" E:");
798 803
             SERIAL_PROTOCOLLN( (int)tmp_extruder ); 
799
-            SERIAL_PROTOCOLPGM(" W:");
800
-            if(residencyStart > -1)
801
-            {
802
-               codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
803
-               SERIAL_PROTOCOLLN( codenum );
804
-            }
805
-            else 
806
-            {
807
-               SERIAL_PROTOCOLLN( "?" );
808
-            }
804
+            #ifdef TEMP_RESIDENCY_TIME
805
+              SERIAL_PROTOCOLPGM(" W:");
806
+              if(residencyStart > -1)
807
+              {
808
+                 codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
809
+                 SERIAL_PROTOCOLLN( codenum );
810
+              }
811
+              else 
812
+              {
813
+                 SERIAL_PROTOCOLLN( "?" );
814
+              }
815
+            #endif
809 816
             codenum = millis();
810 817
           }
811 818
           manage_heater();
@@ -834,11 +841,11 @@ FORCE_INLINE void process_commands()
834 841
         {
835 842
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
836 843
           {
837
-            float tt=degHotend(ACTIVE_EXTRUDER);
844
+            float tt=degHotend(active_extruder);
838 845
             SERIAL_PROTOCOLPGM("T:");
839 846
             SERIAL_PROTOCOL(tt);
840 847
             SERIAL_PROTOCOLPGM(" E:");
841
-            SERIAL_PROTOCOLLN( (int)tmp_extruder ); 
848
+            SERIAL_PROTOCOLLN( (int)active_extruder ); 
842 849
             SERIAL_PROTOCOLPGM(" B:");
843 850
             SERIAL_PROTOCOLLN(degBed()); 
844 851
             codenum = millis(); 
@@ -1191,6 +1198,7 @@ void manage_inactivity(byte debug)
1191 1198
 
1192 1199
 void kill()
1193 1200
 {
1201
+  cli(); // Stop interrupts
1194 1202
   disable_heater();
1195 1203
 
1196 1204
   disable_x();
@@ -1207,4 +1215,4 @@ void kill()
1207 1215
   while(1); // Wait for reset
1208 1216
 }
1209 1217
 
1210
-
1218
+

+ 2581
- 2572
Marlin/fastio.h
File diff suppressed because it is too large
View File


+ 736
- 737
Marlin/pins.h
File diff suppressed because it is too large
View File


+ 2
- 2
Marlin/planner.cpp View File

@@ -191,8 +191,8 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
191 191
   }
192 192
 
193 193
   #ifdef ADVANCE
194
-    long initial_advance = block->advance*entry_factor*entry_factor;
195
-    long final_advance = block->advance*exit_factor*exit_factor;
194
+    volatile long initial_advance = block->advance*entry_factor*entry_factor; 
195
+    volatile long final_advance = block->advance*exit_factor*exit_factor;
196 196
   #endif // ADVANCE
197 197
   
198 198
  // block->accelerate_until = accelerate_steps;

+ 56
- 24
Marlin/stepper.cpp View File

@@ -57,7 +57,7 @@ volatile static unsigned long step_events_completed; // The number of step event
57 57
   static long advance_rate, advance, final_advance = 0;
58 58
   static long old_advance = 0;
59 59
 #endif
60
-static long e_steps;
60
+static long e_steps[3];
61 61
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
62 62
 static long acceleration_time, deceleration_time;
63 63
 //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
@@ -266,7 +266,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
266 266
     advance = current_block->initial_advance;
267 267
     final_advance = current_block->final_advance;
268 268
     // Do E steps + advance steps
269
-    e_steps += ((advance >>8) - old_advance);
269
+    e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
270 270
     old_advance = advance >>8;  
271 271
   #endif
272 272
   deceleration_time = 0;
@@ -303,8 +303,8 @@ ISR(TIMER1_COMPA_vect)
303 303
       counter_z = counter_x;
304 304
       counter_e = counter_x;
305 305
       step_events_completed = 0;
306
- //     #ifdef ADVANCE
307
-      e_steps = 0;
306
+//      #ifdef ADVANCE
307
+//      e_steps[current_block->active_extruder] = 0;
308 308
 //      #endif
309 309
     } 
310 310
     else {
@@ -418,11 +418,11 @@ ISR(TIMER1_COMPA_vect)
418 418
 
419 419
     #ifndef ADVANCE
420 420
       if ((out_bits & (1<<E_AXIS)) != 0) {  // -direction
421
-        NORM_E_DIR();
421
+        REV_E_DIR();
422 422
         count_direction[E_AXIS]=-1;
423 423
       }
424 424
       else { // +direction
425
-        REV_E_DIR();
425
+        NORM_E_DIR();
426 426
         count_direction[E_AXIS]=-1;
427 427
       }
428 428
     #endif //!ADVANCE
@@ -437,10 +437,10 @@ ISR(TIMER1_COMPA_vect)
437 437
       if (counter_e > 0) {
438 438
         counter_e -= current_block->step_event_count;
439 439
         if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
440
-          e_steps--;
440
+          e_steps[current_block->active_extruder]--;
441 441
         }
442 442
         else {
443
-          e_steps++;
443
+          e_steps[current_block->active_extruder]++;
444 444
         }
445 445
       }    
446 446
       #endif //ADVANCE
@@ -503,7 +503,7 @@ ISR(TIMER1_COMPA_vect)
503 503
         }
504 504
         //if(advance > current_block->advance) advance = current_block->advance;
505 505
         // Do E steps + advance steps
506
-        e_steps += ((advance >>8) - old_advance);
506
+        e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
507 507
         old_advance = advance >>8;  
508 508
         
509 509
       #endif
@@ -532,7 +532,7 @@ ISR(TIMER1_COMPA_vect)
532 532
         }
533 533
         if(advance < final_advance) advance = final_advance;
534 534
         // Do E steps + advance steps
535
-        e_steps += ((advance >>8) - old_advance);
535
+        e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
536 536
         old_advance = advance >>8;  
537 537
       #endif //ADVANCE
538 538
     }
@@ -557,20 +557,50 @@ ISR(TIMER1_COMPA_vect)
557 557
     old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
558 558
     OCR0A = old_OCR0A;
559 559
     // Set E direction (Depends on E direction + advance)
560
-    for(unsigned char i=0; i<4;) {
561
-      WRITE_E_STEP(LOW);
562
-      if (e_steps == 0) break;
563
-      i++;
564
-      if (e_steps < 0) {
565
-        WRITE_E_DIR(INVERT_E_DIR);    
566
-        e_steps++;
567
-        WRITE_E_STEP(HIGH);
568
-      } 
569
-      else if (e_steps > 0) {
570
-        WRITE_E_DIR(!INVERT_E_DIR);
571
-        e_steps--;
572
-        WRITE_E_STEP(HIGH);
560
+    for(unsigned char i=0; i<4;i++) {
561
+      if (e_steps[0] != 0) {
562
+        WRITE(E0_STEP_PIN, LOW);
563
+        if (e_steps[0] < 0) {
564
+          WRITE(E0_DIR_PIN, INVERT_E0_DIR);
565
+          e_steps[0]++;
566
+          WRITE(E0_STEP_PIN, HIGH);
567
+        } 
568
+        else if (e_steps[0] > 0) {
569
+          WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
570
+          e_steps[0]--;
571
+          WRITE(E0_STEP_PIN, HIGH);
572
+        }
573
+      }
574
+ #if EXTRUDERS > 1
575
+      if (e_steps[1] != 0) {
576
+        WRITE(E1_STEP_PIN, LOW);
577
+        if (e_steps[1] < 0) {
578
+          WRITE(E1_DIR_PIN, INVERT_E1_DIR);
579
+          e_steps[1]++;
580
+          WRITE(E1_STEP_PIN, HIGH);
581
+        } 
582
+        else if (e_steps[1] > 0) {
583
+          WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
584
+          e_steps[1]--;
585
+          WRITE(E1_STEP_PIN, HIGH);
586
+        }
587
+      }
588
+ #endif
589
+ #if EXTRUDERS > 2
590
+      if (e_steps[2] != 0) {
591
+        WRITE(E2_STEP_PIN, LOW);
592
+        if (e_steps[2] < 0) {
593
+          WRITE(E2_DIR_PIN, INVERT_E2_DIR);
594
+          e_steps[2]++;
595
+          WRITE(E2_STEP_PIN, HIGH);
596
+        } 
597
+        else if (e_steps[2] > 0) {
598
+          WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
599
+          e_steps[2]--;
600
+          WRITE(E2_STEP_PIN, HIGH);
601
+        }
573 602
       }
603
+ #endif
574 604
     }
575 605
   }
576 606
 #endif // ADVANCE
@@ -712,7 +742,9 @@ void st_init()
712 742
     TCCR0A &= ~(1<<WGM01);
713 743
     TCCR0A &= ~(1<<WGM00);
714 744
   #endif  
715
-    e_steps = 0;
745
+    e_steps[0] = 0;
746
+    e_steps[1] = 0;
747
+    e_steps[2] = 0;
716 748
     TIMSK0 |= (1<<OCIE0A);
717 749
   #endif //ADVANCE
718 750
   

+ 15
- 0
Marlin/stepper.h View File

@@ -23,6 +23,21 @@
23 23
 
24 24
 #include "planner.h"
25 25
 
26
+#if EXTRUDERS > 2
27
+  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
28
+  #define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(!E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(!E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
29
+  #define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
30
+#elif EXTRUDERS > 1
31
+  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
32
+  #define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
33
+  #define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
34
+#else
35
+  #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
36
+  #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
37
+  #define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
38
+#endif
39
+
40
+
26 41
 // Initialize and start the stepper motor subsystem
27 42
 void st_init();
28 43
 

+ 74
- 31
Marlin/temperature.cpp View File

@@ -26,7 +26,6 @@
26 26
  It has preliminary support for Matthew Roberts advance algorithm 
27 27
     http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
28 28
 
29
- This firmware is optimized for gen6 electronics.
30 29
  */
31 30
 #include <avr/pgmspace.h>
32 31
 
@@ -82,6 +81,7 @@ static unsigned long  previous_millis_bed_heater;
82 81
   // static float pid_output[EXTRUDERS];
83 82
   static bool pid_reset[EXTRUDERS];
84 83
 #endif //PIDTEMP
84
+  static unsigned char soft_pwm[EXTRUDERS];
85 85
   
86 86
 #ifdef WATCHPERIOD
87 87
   static int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
@@ -140,6 +140,10 @@ void updatePID()
140 140
 #endif
141 141
 }
142 142
   
143
+int getHeaterPower(int heater) {
144
+  return soft_pwm[heater];
145
+}
146
+
143 147
 void manage_heater()
144 148
 {
145 149
   #ifdef USE_WATCHDOG
@@ -198,15 +202,16 @@ void manage_heater()
198 202
     }
199 203
   #endif
200 204
 
201
-  // Check if temperature is within the correct range
202
-  if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e])) 
203
-  {
204
-    analogWrite(heater_pin_map[e], pid_output);
205
-  }
206
-  else {
207
-    analogWrite(heater_pin_map[e], 0);
208
-  }
209
-
205
+    // Check if temperature is within the correct range
206
+    if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e])) 
207
+    {
208
+      //analogWrite(heater_pin_map[e], pid_output);
209
+      soft_pwm[e] = (int)pid_output >> 1;
210
+    }
211
+    else {
212
+      //analogWrite(heater_pin_map[e], 0);
213
+      soft_pwm[e] = 0;
214
+    }
210 215
   } // End extruder for loop
211 216
     
212 217
   if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
@@ -418,7 +423,6 @@ void tp_init()
418 423
        DIDR0 |= 1 << TEMP_0_PIN; 
419 424
     #else
420 425
        DIDR2 |= 1<<(TEMP_0_PIN - 8); 
421
-       ADCSRB = 1<<MUX5;
422 426
     #endif
423 427
   #endif
424 428
   #if (TEMP_1_PIN > -1)
@@ -426,7 +430,6 @@ void tp_init()
426 430
        DIDR0 |= 1<<TEMP_1_PIN; 
427 431
     #else
428 432
        DIDR2 |= 1<<(TEMP_1_PIN - 8); 
429
-       ADCSRB = 1<<MUX5;
430 433
     #endif
431 434
   #endif
432 435
   #if (TEMP_2_PIN > -1)
@@ -434,7 +437,6 @@ void tp_init()
434 437
        DIDR0 |= 1 << TEMP_2_PIN; 
435 438
     #else
436 439
        DIDR2 = 1<<(TEMP_2_PIN - 8); 
437
-       ADCSRB = 1<<MUX5;
438 440
     #endif
439 441
   #endif
440 442
   #if (TEMP_BED_PIN > -1)
@@ -442,7 +444,6 @@ void tp_init()
442 444
        DIDR0 |= 1<<TEMP_BED_PIN; 
443 445
     #else
444 446
        DIDR2 |= 1<<(TEMP_BED_PIN - 8); 
445
-       ADCSRB = 1<<MUX5;
446 447
     #endif
447 448
   #endif
448 449
   
@@ -506,6 +507,7 @@ void disable_heater()
506 507
 {
507 508
   #if TEMP_0_PIN > -1
508 509
   target_raw[0]=0;
510
+  soft_pwm[0]=0;
509 511
    #if HEATER_0_PIN > -1  
510 512
      digitalWrite(HEATER_0_PIN,LOW);
511 513
    #endif
@@ -513,6 +515,7 @@ void disable_heater()
513 515
      
514 516
   #if TEMP_1_PIN > -1
515 517
     target_raw[1]=0;
518
+    soft_pwm[1]=0;
516 519
     #if HEATER_1_PIN > -1 
517 520
       digitalWrite(HEATER_1_PIN,LOW);
518 521
     #endif
@@ -520,6 +523,7 @@ void disable_heater()
520 523
       
521 524
   #if TEMP_2_PIN > -1
522 525
     target_raw[2]=0;
526
+    soft_pwm[2]=0;
523 527
     #if HEATER_2_PIN > -1  
524 528
       digitalWrite(HEATER_2_PIN,LOW);
525 529
     #endif
@@ -533,6 +537,26 @@ void disable_heater()
533 537
   #endif 
534 538
 }
535 539
 
540
+void max_temp_error(uint8_t e) {
541
+  digitalWrite(heater_pin_map[e], 0);
542
+  SERIAL_ERROR_START;
543
+  SERIAL_ERRORLN(e);
544
+  SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
545
+}
546
+
547
+void min_temp_error(uint8_t e) {
548
+  digitalWrite(heater_pin_map[e], 0);
549
+  SERIAL_ERROR_START;
550
+  SERIAL_ERRORLN(e);
551
+  SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
552
+}
553
+
554
+void bed_max_temp_error(void) {
555
+  digitalWrite(HEATER_BED_PIN, 0);
556
+  SERIAL_ERROR_START;
557
+  SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
558
+}
559
+
536 560
 // Timer 0 is shared with millies
537 561
 ISR(TIMER0_COMPB_vect)
538 562
 {
@@ -543,6 +567,33 @@ ISR(TIMER0_COMPB_vect)
543 567
   static unsigned long raw_temp_2_value = 0;
544 568
   static unsigned long raw_temp_bed_value = 0;
545 569
   static unsigned char temp_state = 0;
570
+  static unsigned char pwm_count = 1;
571
+  static unsigned char soft_pwm_0;
572
+  static unsigned char soft_pwm_1;
573
+  static unsigned char soft_pwm_2;
574
+  
575
+  if(pwm_count == 0){
576
+    soft_pwm_0 = soft_pwm[0];
577
+    if(soft_pwm_0 > 0) WRITE(HEATER_0_PIN,1);
578
+    #if EXTRUDERS > 1
579
+    soft_pwm_1 = soft_pwm[1];
580
+    if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1);
581
+    #endif
582
+    #if EXTRUDERS > 2
583
+    soft_pwm_2 = soft_pwm[2];
584
+    if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1);
585
+    #endif
586
+  }
587
+  if(soft_pwm_0 <= pwm_count) WRITE(HEATER_0_PIN,0);
588
+  #if EXTRUDERS > 1
589
+  if(soft_pwm_1 <= pwm_count) WRITE(HEATER_1_PIN,0);
590
+  #endif
591
+  #if EXTRUDERS > 2
592
+  if(soft_pwm_2 <= pwm_count) WRITE(HEATER_2_PIN,0);
593
+  #endif
594
+  
595
+  pwm_count++;
596
+  pwm_count &= 0x7f;
546 597
   
547 598
   switch(temp_state) {
548 599
     case 0: // Prepare TEMP_0
@@ -628,10 +679,10 @@ ISR(TIMER0_COMPB_vect)
628 679
       temp_state = 0;
629 680
       temp_count++;
630 681
       break;
631
-    default:
632
-      SERIAL_ERROR_START;
633
-      SERIAL_ERRORLNPGM("Temp measurement error!");
634
-      break;
682
+//    default:
683
+//      SERIAL_ERROR_START;
684
+//      SERIAL_ERRORLNPGM("Temp measurement error!");
685
+//      break;
635 686
   }
636 687
     
637 688
   if(temp_count >= 16) // 8 ms * 16 = 128ms.
@@ -671,21 +722,15 @@ ISR(TIMER0_COMPB_vect)
671 722
     raw_temp_2_value = 0;
672 723
     raw_temp_bed_value = 0;
673 724
 
674
-    for(int e = 0; e < EXTRUDERS; e++) {
725
+    for(unsigned char e = 0; e < EXTRUDERS; e++) {
675 726
        if(current_raw[e] >= maxttemp[e]) {
676 727
           target_raw[e] = 0;
677
-          digitalWrite(heater_pin_map[e], 0);
678
-          SERIAL_ERROR_START;
679
-          SERIAL_ERRORLN((int)e);
680
-          SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
681
-          kill();
728
+          max_temp_error(e);
729
+          kill();;
682 730
        }
683 731
        if(current_raw[e] <= minttemp[e]) {
684 732
           target_raw[e] = 0;
685
-          digitalWrite(heater_pin_map[e], 0);
686
-          SERIAL_ERROR_START;
687
-          SERIAL_ERRORLN(e);
688
-          SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
733
+          min_temp_error(e);
689 734
           kill();
690 735
        }
691 736
     }
@@ -693,9 +738,7 @@ ISR(TIMER0_COMPB_vect)
693 738
 #if defined(BED_MAXTEMP) && (HEATER_BED_PIN > -1)
694 739
     if(current_raw_bed >= bed_maxttemp) {
695 740
        target_raw_bed = 0;
696
-       digitalWrite(HEATER_BED_PIN, 0);
697
-       SERIAL_ERROR_START;
698
-       SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
741
+       bed_max_temp_error();
699 742
        kill();
700 743
     }
701 744
 #endif

+ 143
- 142
Marlin/temperature.h View File

@@ -1,143 +1,144 @@
1
-/*
2
-  temperature.h - temperature controller
3
-  Part of Marlin
4
-
5
-  Copyright (c) 2011 Erik van der Zalm
6
-
7
-  Grbl is free software: you can redistribute it and/or modify
8
-  it under the terms of the GNU General Public License as published by
9
-  the Free Software Foundation, either version 3 of the License, or
10
-  (at your option) any later version.
11
-
12
-  Grbl is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-  GNU General Public License for more details.
16
-
17
-  You should have received a copy of the GNU General Public License
18
-  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
-*/
20
-
21
-#ifndef temperature_h
22
-#define temperature_h 
23
-
24
-#include "Marlin.h"
25
-#include "fastio.h"
26
-#ifdef PID_ADD_EXTRUSION_RATE
27
-  #include "stepper.h"
28
-#endif
29
-
30
-// public functions
31
-void tp_init();  //initialise the heating
32
-void manage_heater(); //it is critical that this is called periodically.
33
-
34
-//low leven conversion routines
35
-// do not use this routines and variables outsie of temperature.cpp
36
-int temp2analog(int celsius, uint8_t e);
37
-int temp2analogBed(int celsius);
38
-float analog2temp(int raw, uint8_t e);
39
-float analog2tempBed(int raw);
40
-extern int target_raw[EXTRUDERS];  
41
-extern int heatingtarget_raw[EXTRUDERS];  
42
-extern int current_raw[EXTRUDERS];
43
-extern int target_raw_bed;
44
-extern int current_raw_bed;
45
-extern float Kp,Ki,Kd,Kc;
46
-
47
-#ifdef PIDTEMP
48
-  extern float pid_setpoint[EXTRUDERS];
49
-#endif
50
-  
51
-#ifdef WATCHPERIOD
52
-  extern int watch_raw[EXTRUDERS] ;
53
-  extern unsigned long watchmillis;
54
-#endif
55
-
56
-
57
-//high level conversion routines, for use outside of temperature.cpp
58
-//inline so that there is no performance decrease.
59
-//deg=degreeCelsius
60
-
61
-FORCE_INLINE float degHotend(uint8_t extruder) {  
62
-  return analog2temp(current_raw[extruder], extruder);
63
-};
64
-
65
-FORCE_INLINE float degBed() {
66
-  return analog2tempBed(current_raw_bed);
67
-};
68
-
69
-FORCE_INLINE float degTargetHotend(uint8_t extruder) {  
70
-  return analog2temp(target_raw[extruder], extruder);
71
-};
72
-
73
-FORCE_INLINE float degTargetBed() {   
74
-  return analog2tempBed(target_raw_bed);
75
-};
76
-
77
-FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {  
78
-  target_raw[extruder] = temp2analog(celsius, extruder);
79
-#ifdef PIDTEMP
80
-  pid_setpoint[extruder] = celsius;
81
-#endif //PIDTEMP
82
-};
83
-
84
-FORCE_INLINE void setTargetBed(const float &celsius) {  
85
-  target_raw_bed = temp2analogBed(celsius);
86
-};
87
-
88
-FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  
89
-  return target_raw[extruder] > current_raw[extruder];
90
-};
91
-
92
-FORCE_INLINE bool isHeatingBed() {
93
-  return target_raw_bed > current_raw_bed;
94
-};
95
-
96
-FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {  
97
-  return target_raw[extruder] < current_raw[extruder];
98
-};
99
-
100
-FORCE_INLINE bool isCoolingBed() {
101
-  return target_raw_bed < current_raw_bed;
102
-};
103
-
104
-#define degHotend0() degHotend(0)
105
-#define degTargetHotend0() degTargetHotend(0)
106
-#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
107
-#define isHeatingHotend0() isHeatingHotend(0)
108
-#define isCoolingHotend0() isCoolingHotend(0)
109
-#if EXTRUDERS > 1
110
-#define degHotend1() degHotend(1)
111
-#define degTargetHotend1() degTargetHotend(1)
112
-#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
113
-#define isHeatingHotend1() isHeatingHotend(1)
114
-#define isCoolingHotend1() isCoolingHotend(1)
115
-#endif
116
-#if EXTRUDERS > 2
117
-#define degHotend2() degHotend(2)
118
-#define degTargetHotend2() degTargetHotend(2)
119
-#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
120
-#define isHeatingHotend2() isHeatingHotend(2)
121
-#define isCoolingHotend2() isCoolingHotend(2)
122
-#endif
123
-#if EXTRUDERS > 3
124
-#error Invalid number of extruders
125
-#endif
126
-
127
-FORCE_INLINE void autotempShutdown(){
128
- #ifdef AUTOTEMP
129
- if(autotemp_enabled)
130
- {
131
-  autotemp_enabled=false;
132
-  if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
133
-    setTargetHotend(0,ACTIVE_EXTRUDER);
134
- }
135
- #endif
136
-}
137
-
138
-void disable_heater();
139
-void setWatch();
140
-void updatePID();
141
-
142
-#endif
1
+/*
2
+  temperature.h - temperature controller
3
+  Part of Marlin
4
+
5
+  Copyright (c) 2011 Erik van der Zalm
6
+
7
+  Grbl is free software: you can redistribute it and/or modify
8
+  it under the terms of the GNU General Public License as published by
9
+  the Free Software Foundation, either version 3 of the License, or
10
+  (at your option) any later version.
11
+
12
+  Grbl is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+  GNU General Public License for more details.
16
+
17
+  You should have received a copy of the GNU General Public License
18
+  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
+*/
20
+
21
+#ifndef temperature_h
22
+#define temperature_h 
23
+
24
+#include "Marlin.h"
25
+#include "fastio.h"
26
+#ifdef PID_ADD_EXTRUSION_RATE
27
+  #include "stepper.h"
28
+#endif
29
+
30
+// public functions
31
+void tp_init();  //initialise the heating
32
+void manage_heater(); //it is critical that this is called periodically.
33
+
34
+//low leven conversion routines
35
+// do not use this routines and variables outsie of temperature.cpp
36
+int temp2analog(int celsius, uint8_t e);
37
+int temp2analogBed(int celsius);
38
+float analog2temp(int raw, uint8_t e);
39
+float analog2tempBed(int raw);
40
+extern int target_raw[EXTRUDERS];  
41
+extern int heatingtarget_raw[EXTRUDERS];  
42
+extern int current_raw[EXTRUDERS];
43
+extern int target_raw_bed;
44
+extern int current_raw_bed;
45
+extern float Kp,Ki,Kd,Kc;
46
+
47
+#ifdef PIDTEMP
48
+  extern float pid_setpoint[EXTRUDERS];
49
+#endif
50
+  
51
+#ifdef WATCHPERIOD
52
+  extern int watch_raw[EXTRUDERS] ;
53
+  extern unsigned long watchmillis;
54
+#endif
55
+
56
+
57
+//high level conversion routines, for use outside of temperature.cpp
58
+//inline so that there is no performance decrease.
59
+//deg=degreeCelsius
60
+
61
+FORCE_INLINE float degHotend(uint8_t extruder) {  
62
+  return analog2temp(current_raw[extruder], extruder);
63
+};
64
+
65
+FORCE_INLINE float degBed() {
66
+  return analog2tempBed(current_raw_bed);
67
+};
68
+
69
+FORCE_INLINE float degTargetHotend(uint8_t extruder) {  
70
+  return analog2temp(target_raw[extruder], extruder);
71
+};
72
+
73
+FORCE_INLINE float degTargetBed() {   
74
+  return analog2tempBed(target_raw_bed);
75
+};
76
+
77
+FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {  
78
+  target_raw[extruder] = temp2analog(celsius, extruder);
79
+#ifdef PIDTEMP
80
+  pid_setpoint[extruder] = celsius;
81
+#endif //PIDTEMP
82
+};
83
+
84
+FORCE_INLINE void setTargetBed(const float &celsius) {  
85
+  target_raw_bed = temp2analogBed(celsius);
86
+};
87
+
88
+FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  
89
+  return target_raw[extruder] > current_raw[extruder];
90
+};
91
+
92
+FORCE_INLINE bool isHeatingBed() {
93
+  return target_raw_bed > current_raw_bed;
94
+};
95
+
96
+FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {  
97
+  return target_raw[extruder] < current_raw[extruder];
98
+};
99
+
100
+FORCE_INLINE bool isCoolingBed() {
101
+  return target_raw_bed < current_raw_bed;
102
+};
103
+
104
+#define degHotend0() degHotend(0)
105
+#define degTargetHotend0() degTargetHotend(0)
106
+#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
107
+#define isHeatingHotend0() isHeatingHotend(0)
108
+#define isCoolingHotend0() isCoolingHotend(0)
109
+#if EXTRUDERS > 1
110
+#define degHotend1() degHotend(1)
111
+#define degTargetHotend1() degTargetHotend(1)
112
+#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
113
+#define isHeatingHotend1() isHeatingHotend(1)
114
+#define isCoolingHotend1() isCoolingHotend(1)
115
+#endif
116
+#if EXTRUDERS > 2
117
+#define degHotend2() degHotend(2)
118
+#define degTargetHotend2() degTargetHotend(2)
119
+#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
120
+#define isHeatingHotend2() isHeatingHotend(2)
121
+#define isCoolingHotend2() isCoolingHotend(2)
122
+#endif
123
+#if EXTRUDERS > 3
124
+#error Invalid number of extruders
125
+#endif
126
+
127
+FORCE_INLINE void autotempShutdown(){
128
+ #ifdef AUTOTEMP
129
+ if(autotemp_enabled)
130
+ {
131
+  autotemp_enabled=false;
132
+  if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
133
+    setTargetHotend(0,ACTIVE_EXTRUDER);
134
+ }
135
+ #endif
136
+}
137
+
138
+int getHeaterPower(int heater);
139
+void disable_heater();
140
+void setWatch();
141
+void updatePID();
142
+
143
+#endif
143 144
 

+ 1842
- 1838
Marlin/ultralcd.pde
File diff suppressed because it is too large
View File


Loading…
Cancel
Save