Browse Source

first-commit

Erik van der Zalm 14 years ago
parent
commit
26bf57e22c
3 changed files with 111 additions and 57 deletions
  1. 21
    22
      Marlin/Configuration.h
  2. 34
    35
      Marlin/Marlin.pde
  3. 56
    0
      README

+ 21
- 22
Marlin/Configuration.h View File

13
 // 3 is mendel-parts thermistor
13
 // 3 is mendel-parts thermistor
14
 #define THERMISTORHEATER 3
14
 #define THERMISTORHEATER 3
15
 
15
 
16
-// extruder advance constant (s2/mm3)
17
-//
18
-// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
19
-//
20
-// hooke's law says:		force = k * distance
21
-// bernoulli's priniciple says:	v ^ 2 / 2 + g . h + pressure / density = constant
22
-// so: v ^ 2 is proportional to number of steps we advance the extruder
23
-//#define ADVANCE
24
-
25
-#ifdef ADVANCE
26
-#define EXTRUDER_ADVANCE_K 0.02
27
-
28
-#define D_FILAMENT 1.7
29
-#define STEPS_MM_E 65
30
-//#define D_FILAMENT 2.85
31
-//#define STEPS_MM_E 367.35
32
-#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
33
-#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
34
-
35
-#endif // ADVANCE
36
 
16
 
37
 //// Calibration variables
17
 //// Calibration variables
38
 // X, Y, Z, E steps per unit - Metric Prusa Mendel with V9 extruder:
18
 // X, Y, Z, E steps per unit - Metric Prusa Mendel with V9 extruder:
94
 
74
 
95
 //// Acceleration settings
75
 //// Acceleration settings
96
 // 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.
76
 // 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.
97
-float acceleration = 3000;         // Normal acceleration mm/s^2
77
+float acceleration = 2000;         // Normal acceleration mm/s^2
98
 float retract_acceleration = 7000; // Normal acceleration mm/s^2
78
 float retract_acceleration = 7000; // Normal acceleration mm/s^2
99
 float max_jerk = 20*60;
79
 float max_jerk = 20*60;
100
-long max_acceleration_units_per_sq_second[] = {7000,7000,20,10000}; // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
80
+long max_acceleration_units_per_sq_second[] = {7000,7000,100,10000}; // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
101
 // Not used long max_travel_acceleration_units_per_sq_second[] = {500,500,50,500}; // X, Y, Z max acceleration in mm/s^2 for travel moves
81
 // Not used long max_travel_acceleration_units_per_sq_second[] = {500,500,50,500}; // X, Y, Z max acceleration in mm/s^2 for travel moves
102
 
82
 
103
 
83
 
130
 #endif // PIDTEMP
110
 #endif // PIDTEMP
131
 
111
 
132
 
112
 
113
+// extruder advance constant (s2/mm3)
114
+//
115
+// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
116
+//
117
+// hooke's law says:		force = k * distance
118
+// bernoulli's priniciple says:	v ^ 2 / 2 + g . h + pressure / density = constant
119
+// so: v ^ 2 is proportional to number of steps we advance the extruder
120
+//#define ADVANCE
121
+
122
+#ifdef ADVANCE
123
+#define EXTRUDER_ADVANCE_K 0.02
124
+
125
+#define D_FILAMENT 1.7
126
+#define STEPS_MM_E 65
127
+#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
128
+#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
129
+
130
+#endif // ADVANCE
131
+
133
 #endif
132
 #endif

+ 34
- 35
Marlin/Marlin.pde View File

18
 
18
 
19
 /*
19
 /*
20
  This firmware is a mashup between Sprinter and grbl.
20
  This firmware is a mashup between Sprinter and grbl.
21
+  (https://github.com/kliment/Sprinter)
22
+  (https://github.com/simen/grbl/tree)
23
+ 
21
  It has preliminary support for Matthew Roberts advance algorithm 
24
  It has preliminary support for Matthew Roberts advance algorithm 
22
     http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
25
     http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
23
- (https://github.com/kliment/Sprinter)
24
- (https://github.com/simen/grbl/tree)
26
+
25
  This firmware is optimized for gen6 electronics.
27
  This firmware is optimized for gen6 electronics.
26
  */
28
  */
27
 
29
 
35
 
37
 
36
 #ifdef SDSUPPORT
38
 #ifdef SDSUPPORT
37
 #include "SdFat.h"
39
 #include "SdFat.h"
38
-#endif
40
+#endif //SDSUPPORT
39
 
41
 
40
 #ifndef CRITICAL_SECTION_START
42
 #ifndef CRITICAL_SECTION_START
41
 #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli()
43
 #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli()
42
 #define CRITICAL_SECTION_END    SREG = _sreg
44
 #define CRITICAL_SECTION_END    SREG = _sreg
43
-#endif
45
+#endif //CRITICAL_SECTION_START
44
 
46
 
45
 // look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
47
 // look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
46
 // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
48
 // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
138
   double pid_input;
140
   double pid_input;
139
   double pid_output;
141
   double pid_output;
140
   bool pid_reset;
142
   bool pid_reset;
141
-#endif
143
+#endif //PIDTEMP
142
 
144
 
143
 #ifdef WATCHPERIOD
145
 #ifdef WATCHPERIOD
144
 int watch_raw = -1000;
146
 int watch_raw = -1000;
145
 unsigned long watchmillis = 0;
147
 unsigned long watchmillis = 0;
146
-#endif
148
+#endif //WATCHPERIOD
147
 #ifdef MINTEMP
149
 #ifdef MINTEMP
148
 int minttemp = temp2analogh(MINTEMP);
150
 int minttemp = temp2analogh(MINTEMP);
149
-#endif
151
+#endif //MINTEMP
150
 #ifdef MAXTEMP
152
 #ifdef MAXTEMP
151
 int maxttemp = temp2analogh(MAXTEMP);
153
 int maxttemp = temp2analogh(MAXTEMP);
152
-#endif
154
+#endif //MAXTEMP
153
 
155
 
154
 //Inactivity shutdown variables
156
 //Inactivity shutdown variables
155
 unsigned long previous_millis_cmd = 0;
157
 unsigned long previous_millis_cmd = 0;
183
     Serial.println("openRoot failed");
185
     Serial.println("openRoot failed");
184
   else 
186
   else 
185
     sdactive = true;
187
     sdactive = true;
186
-#endif
188
+#endif //SDSS
187
 }
189
 }
188
 
190
 
189
 inline void write_command(char *buf){
191
 inline void write_command(char *buf){
205
     Serial.println("error writing to file");
207
     Serial.println("error writing to file");
206
   }
208
   }
207
 }
209
 }
208
-#endif
210
+#endif //SDSUPPORT
209
 
211
 
210
 
212
 
211
 void setup()
213
 void setup()
278
   SET_INPUT(Z_MAX_PIN); 
280
   SET_INPUT(Z_MAX_PIN); 
279
   WRITE(Z_MAX_PIN,HIGH);
281
   WRITE(Z_MAX_PIN,HIGH);
280
 #endif
282
 #endif
281
-#else
283
+#else //ENDSTOPPULLUPS
282
 #if X_MIN_PIN > -1
284
 #if X_MIN_PIN > -1
283
   SET_INPUT(X_MIN_PIN); 
285
   SET_INPUT(X_MIN_PIN); 
284
 #endif
286
 #endif
297
 #if Z_MAX_PIN > -1
299
 #if Z_MAX_PIN > -1
298
   SET_INPUT(Z_MAX_PIN); 
300
   SET_INPUT(Z_MAX_PIN); 
299
 #endif
301
 #endif
300
-#endif
302
+#endif //ENDSTOPPULLUPS
301
 
303
 
302
 #if (HEATER_0_PIN > -1) 
304
 #if (HEATER_0_PIN > -1) 
303
   SET_OUTPUT(HEATER_0_PIN);
305
   SET_OUTPUT(HEATER_0_PIN);
333
 #if SDPOWER > -1
335
 #if SDPOWER > -1
334
   SET_OUTPUT(SDPOWER); 
336
   SET_OUTPUT(SDPOWER); 
335
   WRITE(SDPOWER,HIGH);
337
   WRITE(SDPOWER,HIGH);
336
-#endif
338
+#endif //SDPOWER
337
   initsd();
339
   initsd();
338
 
340
 
339
-#endif
341
+#endif //SDSUPPORT
340
   plan_init();  // Initialize planner;
342
   plan_init();  // Initialize planner;
341
   st_init();    // Initialize stepper;
343
   st_init();    // Initialize stepper;
342
   tp_init();    // Initialize temperature loop
344
   tp_init();    // Initialize temperature loop
367
     }
369
     }
368
 #else
370
 #else
369
     process_commands();
371
     process_commands();
370
-#endif
372
+#endif //SDSUPPORT
371
     buflen = (buflen-1);
373
     buflen = (buflen-1);
372
     bufindr = (bufindr + 1)%BUFSIZE;
374
     bufindr = (bufindr + 1)%BUFSIZE;
373
   }
375
   }
446
 #ifdef SDSUPPORT
448
 #ifdef SDSUPPORT
447
             if(savetosd)
449
             if(savetosd)
448
               break;
450
               break;
449
-#endif
451
+#endif //SDSUPPORT
450
             Serial.println("ok"); 
452
             Serial.println("ok"); 
451
             break;
453
             break;
452
           default:
454
           default:
497
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
499
       if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
498
     }
500
     }
499
   }
501
   }
500
-#endif
502
+#endif //SDSUPPORT
501
 
503
 
502
 }
504
 }
503
 
505
 
751
       //processed in write to file routine above
753
       //processed in write to file routine above
752
       //savetosd = false;
754
       //savetosd = false;
753
       break;
755
       break;
754
-#endif
756
+#endif //SDSUPPORT
755
     case 104: // M104
757
     case 104: // M104
756
 #ifdef PID_OPENLOOP
758
 #ifdef PID_OPENLOOP
757
       if (code_seen('S')) PidTemp_Output = code_value() * (PID_MAX/100.0);
759
       if (code_seen('S')) PidTemp_Output = code_value() * (PID_MAX/100.0);
790
       else{
792
       else{
791
         watchmillis = 0;
793
         watchmillis = 0;
792
       }
794
       }
793
-#endif
795
+#endif //WATCHERPERIOD
794
       codenum = millis(); 
796
       codenum = millis(); 
795
       while(current_raw < target_raw) {
797
       while(current_raw < target_raw) {
796
         if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
798
         if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
922
 #ifdef SDSUPPORT
924
 #ifdef SDSUPPORT
923
   if(fromsd[bufindr])
925
   if(fromsd[bufindr])
924
     return;
926
     return;
925
-#endif
927
+#endif //SDSUPPORT
926
   Serial.println("ok"); 
928
   Serial.println("ok"); 
927
 }
929
 }
928
 
930
 
958
 CRITICAL_SECTION_END;
960
 CRITICAL_SECTION_END;
959
 
961
 
960
 #ifdef PIDTEMP
962
 #ifdef PIDTEMP
961
-  pid_input = analog2temp(current_raw);//ACT
963
+  pid_input = analog2temp(current_raw);
962
 
964
 
963
 #ifndef PID_OPENLOOP
965
 #ifndef PID_OPENLOOP
964
   pid_error = pid_setpoint - pid_input;
966
   pid_error = pid_setpoint - pid_input;
1000
    Serial.println();
1002
    Serial.println();
1001
 #endif //PID_DEBUG
1003
 #endif //PID_DEBUG
1002
   OCR2B = pid_output;
1004
   OCR2B = pid_output;
1003
-#endif
1005
+#endif //PIDTEMP
1004
 }
1006
 }
1005
 
1007
 
1006
 
1008
 
1051
   target_raw=0;
1053
   target_raw=0;
1052
 #ifdef PIDTEMP
1054
 #ifdef PIDTEMP
1053
   pid_setpoint = 0.0;
1055
   pid_setpoint = 0.0;
1054
-#endif PIDTEMP
1056
+#endif //PIDTEMP
1055
   OCR2B = 0;
1057
   OCR2B = 0;
1056
   WRITE(HEATER_0_PIN,LOW);
1058
   WRITE(HEATER_0_PIN,LOW);
1057
 
1059
 
1465
   float speed_factor = 1;
1467
   float speed_factor = 1;
1466
   float tmp_speed_factor;
1468
   float tmp_speed_factor;
1467
   if(abs(block->speed_x) > max_feedrate[X_AXIS]) {
1469
   if(abs(block->speed_x) > max_feedrate[X_AXIS]) {
1468
-    speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_x);
1470
+    speed_factor = max_feedrate[X_AXIS] / abs(block->speed_x);
1469
   }
1471
   }
1470
   if(abs(block->speed_y) > max_feedrate[Y_AXIS]){
1472
   if(abs(block->speed_y) > max_feedrate[Y_AXIS]){
1471
     tmp_speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_y);
1473
     tmp_speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_y);
1473
   }
1475
   }
1474
   if(abs(block->speed_z) > max_feedrate[Z_AXIS]){
1476
   if(abs(block->speed_z) > max_feedrate[Z_AXIS]){
1475
     tmp_speed_factor = max_feedrate[Z_AXIS] / abs(block->speed_z);
1477
     tmp_speed_factor = max_feedrate[Z_AXIS] / abs(block->speed_z);
1476
-    if(tmp_speed_factor < speed_factor) speed_factor = tmp_speed_factor;
1478
+    if(speed_factor > tmp_speed_factor) speed_factor = tmp_speed_factor;
1477
   }
1479
   }
1478
   if(abs(block->speed_e) > max_feedrate[E_AXIS]){
1480
   if(abs(block->speed_e) > max_feedrate[E_AXIS]){
1479
     tmp_speed_factor = max_feedrate[E_AXIS] / abs(block->speed_e);
1481
     tmp_speed_factor = max_feedrate[E_AXIS] / abs(block->speed_e);
1480
-    if(tmp_speed_factor < speed_factor) speed_factor = tmp_speed_factor;
1482
+    if(speed_factor > tmp_speed_factor) speed_factor = tmp_speed_factor;
1481
   }
1483
   }
1482
   multiplier = multiplier * speed_factor;
1484
   multiplier = multiplier * speed_factor;
1483
   block->speed_z = delta_z_mm * multiplier; 
1485
   block->speed_z = delta_z_mm * multiplier; 
1910
   // Critical section needed because Timer 1 interrupt has higher priority. 
1912
   // Critical section needed because Timer 1 interrupt has higher priority. 
1911
   // The pin set functions are placed on trategic position to comply with the stepper driver timing.
1913
   // The pin set functions are placed on trategic position to comply with the stepper driver timing.
1912
   WRITE(E_STEP_PIN, LOW);
1914
   WRITE(E_STEP_PIN, LOW);
1913
-  // e_steps is changed in timer 1 interrupt
1914
-  CRITICAL_SECTION_START;
1915
   // Set E direction (Depends on E direction + advance)
1915
   // Set E direction (Depends on E direction + advance)
1916
   if (e_steps < 0) {
1916
   if (e_steps < 0) {
1917
     WRITE(E_DIR_PIN,INVERT_E_DIR);    
1917
     WRITE(E_DIR_PIN,INVERT_E_DIR);    
1923
     e_steps--;
1923
     e_steps--;
1924
     WRITE(E_STEP_PIN, HIGH);
1924
     WRITE(E_STEP_PIN, HIGH);
1925
   }
1925
   }
1926
-  CRITICAL_SECTION_END;
1927
   old_OCR0A += 25; // 10kHz interrupt
1926
   old_OCR0A += 25; // 10kHz interrupt
1928
   OCR0A = old_OCR0A;
1927
   OCR0A = old_OCR0A;
1929
 }
1928
 }
1974
   TCCR2A = 0x23;  //OC2A disable; FastPWM noninverting; FastPWM mode 7
1973
   TCCR2A = 0x23;  //OC2A disable; FastPWM noninverting; FastPWM mode 7
1975
 #else
1974
 #else
1976
   TCCR2A = 0x03;  //OC2A disable; FastPWM noninverting; FastPWM mode 7
1975
   TCCR2A = 0x03;  //OC2A disable; FastPWM noninverting; FastPWM mode 7
1977
-#endif
1976
+#endif //PIDTEMP
1978
   OCR2A = 156;    //Period is ~10ms
1977
   OCR2A = 156;    //Period is ~10ms
1979
   OCR2B = 0;      //Duty Cycle for heater pin is 0 (startup)
1978
   OCR2B = 0;      //Duty Cycle for heater pin is 0 (startup)
1980
   TIMSK2 = 0x01;  //Enable overflow interrupt
1979
   TIMSK2 = 0x01;  //Enable overflow interrupt
2009
       OCR2B = 0;
2008
       OCR2B = 0;
2010
 #else
2009
 #else
2011
       WRITE(HEATER_0_PIN,LOW);
2010
       WRITE(HEATER_0_PIN,LOW);
2012
-#endif
2011
+#endif //PIDTEMP
2013
     }
2012
     }
2014
-#endif
2013
+#endif //MAXTEMP
2015
 #ifdef MINTEMP
2014
 #ifdef MINTEMP
2016
     if(current_raw <= minttemp) {
2015
     if(current_raw <= minttemp) {
2017
       target_raw = 0;
2016
       target_raw = 0;
2019
       OCR2B = 0;
2018
       OCR2B = 0;
2020
 #else
2019
 #else
2021
       WRITE(HEATER_0_PIN,LOW);
2020
       WRITE(HEATER_0_PIN,LOW);
2022
-#endif
2021
+#endif //PIDTEMP
2023
     }
2022
     }
2024
-#endif
2023
+#endif //MAXTEMP
2025
 #ifndef PIDTEMP
2024
 #ifndef PIDTEMP
2026
     if(current_raw >= target_raw)
2025
     if(current_raw >= target_raw)
2027
     {
2026
     {
2031
     {
2030
     {
2032
       WRITE(HEATER_0_PIN,HIGH);
2031
       WRITE(HEATER_0_PIN,HIGH);
2033
     }
2032
     }
2034
-#endif
2033
+#endif //PIDTEMP
2035
   }
2034
   }
2036
 }
2035
 }
2037
 
2036
 

+ 56
- 0
README View File

1
+This firmware is a mashup between Sprinter, grbl and many original parts.
2
+ (https://github.com/kliment/Sprinter)
3
+ (https://github.com/simen/grbl/tree)
4
+
5
+Features:
6
+ - Interrupt based movement with real linear acceleration
7
+ - High steprate
8
+ - Look ahead (Keep the speed high when possible. High cornering speed)
9
+ - Interrupt based temperature protection
10
+ - preliminary support for Matthew Roberts advance algorithm 
11
+   For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
12
+
13
+This firmware is optimized for gen6 electronics.
14
+
15
+The default baudrate is 250000. 
16
+This gives less communication errors then regular baudrates.
17
+
18
+========================================================================================
19
+
20
+Configuring and compilation
21
+
22
+
23
+Install the arduino software version 0018
24
+   http://www.arduino.cc/en/Main/Software
25
+
26
+Install the sanguino software, version 0018
27
+   http://sanguino.cc/useit
28
+
29
+Install pronterface
30
+   https://github.com/kliment/Printrun
31
+
32
+Copy the Marlin firmware
33
+   https:/github.com/ErikZalm/Marlin
34
+   (Use the download button)
35
+
36
+Start the arduino IDE.
37
+Select Tools -> Board -> Sanguino 
38
+Select the correct serial port in Tools ->Serial Port
39
+Open Marlin.pde
40
+
41
+Change the printer specific setting in Configuration.h to the correct values.
42
+
43
+The following values are the most important:
44
+ - float axis_steps_per_unit[]....         // Set the correct steps / mm in the corresponding field
45
+ - const bool ENDSTOPS_INVERTING = false;  // Change if only positive moves are executed
46
+ - #define INVERT_x_DIR true               // Change if the motor direction is wrong
47
+
48
+Click the Upload button
49
+If all goes well the firmware is uploading
50
+
51
+Start pronterface
52
+
53
+Select the correct Serial Port. Type 250000 in the baudrate field.
54
+Press the Connect button.
55
+
56
+

Loading…
Cancel
Save