Browse Source

first-commit

Erik van der Zalm 12 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,26 +13,6 @@
13 13
 // 3 is mendel-parts thermistor
14 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 17
 //// Calibration variables
38 18
 // X, Y, Z, E steps per unit - Metric Prusa Mendel with V9 extruder:
@@ -94,10 +74,10 @@ bool axis_relative_modes[] = {false, false, false, false};
94 74
 
95 75
 //// Acceleration settings
96 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 78
 float retract_acceleration = 7000; // Normal acceleration mm/s^2
99 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 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,4 +110,23 @@ double Kd = 80/PID_dT;
130 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 132
 #endif

+ 34
- 35
Marlin/Marlin.pde View File

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

+ 56
- 0
README View File

@@ -0,0 +1,56 @@
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