Browse Source

A lot of changes in the planner code

Erik van der Zalm 13 years ago
parent
commit
65934eee9c
7 changed files with 2019 additions and 1877 deletions
  1. 26
    11
      Marlin/Configuration.h
  2. 6
    2
      Marlin/Marlin.pde
  3. 704
    593
      Marlin/planner.cpp
  4. 95
    92
      Marlin/planner.h
  5. 616
    611
      Marlin/stepper.cpp
  6. 563
    561
      Marlin/temperature.cpp
  7. 9
    7
      Marlin/thermistortables.h

+ 26
- 11
Marlin/Configuration.h View File

@@ -6,6 +6,15 @@
6 6
 #define MM_PER_ARC_SEGMENT 1
7 7
 #define N_ARC_CORRECTION 25
8 8
 
9
+// Frequency limit
10
+// See nophead's blog for more info
11
+#define XY_FREQUENCY_LIMIT  15
12
+
13
+// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
14
+// of the buffer and all stops. This should not be much greater than zero and should only be changed
15
+// if unwanted behavior is observed on a user's machine when running at very slow speeds.
16
+#define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
17
+
9 18
 // BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration
10 19
 
11 20
 //// The following define selects which electronics board you have. Please choose the one that matches your setup
@@ -97,6 +106,11 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
97 106
 #define DISABLE_E false
98 107
 
99 108
 // Inverting axis direction
109
+//#define INVERT_X_DIR false    // for Mendel set to false, for Orca set to true
110
+//#define INVERT_Y_DIR true   // for Mendel set to true, for Orca set to false
111
+//#define INVERT_Z_DIR false    // for Mendel set to false, for Orca set to true
112
+//#define INVERT_E_DIR true   // for direct drive extruder v9 set to true, for geared extruder set to false
113
+
100 114
 #define INVERT_X_DIR true    // for Mendel set to false, for Orca set to true
101 115
 #define INVERT_Y_DIR false   // for Mendel set to true, for Orca set to false
102 116
 #define INVERT_Z_DIR true    // for Mendel set to false, for Orca set to true
@@ -117,7 +131,7 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
117 131
 //// MOVEMENT SETTINGS
118 132
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
119 133
 //note: on bernhards ultimaker 200 200 12 are working well.
120
-#define HOMING_FEEDRATE {50*60, 50*60, 12*60, 0}  // set the homing speeds
134
+#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
121 135
 
122 136
 #define AXIS_RELATIVE_MODES {false, false, false, false}
123 137
 
@@ -126,19 +140,20 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
126 140
 // default settings 
127 141
 
128 142
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {79.87220447,79.87220447,200*8/3,14}                    // default steps per unit for ultimaker 
129
-#define DEFAULT_MAX_FEEDRATE          {160*60, 160*60, 10*60, 500000}        
130
-#define DEFAULT_MAX_ACCELERATION      {9000,9000,150,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.
143
+//#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} 
144
+#define DEFAULT_MAX_FEEDRATE          {500, 500, 10, 500000}    // (mm/min)    
145
+#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.
131 146
 
132 147
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
133 148
 #define DEFAULT_RETRACT_ACCELERATION  7000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
134 149
 
135
-#define DEFAULT_MINIMUMFEEDRATE       10     // minimum feedrate
136
-#define DEFAULT_MINTRAVELFEEDRATE     10
150
+#define DEFAULT_MINIMUMFEEDRATE       0     // minimum feedrate
151
+#define DEFAULT_MINTRAVELFEEDRATE     0
137 152
 
138 153
 // minimum time in microseconds that a movement needs to take if the buffer is emptied.   Increase this number if you see blobs while printing high speed & high detail.  It will slowdown on the detailed stuff.
139 154
 #define DEFAULT_MINSEGMENTTIME        20000
140
-#define DEFAULT_XYJERK                30.0*60    
141
-#define DEFAULT_ZJERK                 10.0*60
155
+#define DEFAULT_XYJERK                30.0    // (mm/sec)
156
+#define DEFAULT_ZJERK                 0.4     // (mm/sec)
142 157
 
143 158
 
144 159
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
@@ -162,7 +177,7 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
162 177
 //#define TEMP_HYSTERESIS 5       // (C°) range of +/- temperatures considered "close" to the target one
163 178
 
164 179
 //// The minimal temperature defines the temperature below which the heater will not be enabled
165
-#define HEATER_0_MINTEMP 5
180
+//#define HEATER_0_MINTEMP 5
166 181
 //#define HEATER_1_MINTEMP 5
167 182
 //#define BED_MINTEMP 5
168 183
 
@@ -170,7 +185,7 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
170 185
 // When temperature exceeds max temp, your heater will be switched off.
171 186
 // This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
172 187
 // You should use MINTEMP for thermistor short/failure protection.
173
-#define HEATER_0_MAXTEMP 275
188
+//#define HEATER_0_MAXTEMP 275
174 189
 //#define_HEATER_1_MAXTEMP 275
175 190
 //#define BED_MAXTEMP 150
176 191
 
@@ -246,9 +261,9 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
246 261
 // The number of linear motions that can be in the plan at any give time.  
247 262
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
248 263
 #if defined SDSUPPORT
249
-  #define BLOCK_BUFFER_SIZE 16   // SD,LCD,Buttons take more memory, block buffer needs to be smaller
264
+  #define BLOCK_BUFFER_SIZE 8   // SD,LCD,Buttons take more memory, block buffer needs to be smaller
250 265
 #else
251
-  #define BLOCK_BUFFER_SIZE 16 // maximize block buffer
266
+  #define BLOCK_BUFFER_SIZE 8 // maximize block buffer
252 267
 #endif
253 268
 
254 269
 //The ASCII buffer for recieving from the serial:

+ 6
- 2
Marlin/Marlin.pde View File

@@ -114,7 +114,9 @@ extern float HeaterPower;
114 114
 //===========================================================================
115 115
 //=============================public variables=============================
116 116
 //===========================================================================
117
+#ifdef SDSUPPORT
117 118
 CardReader card;
119
+#endif
118 120
 float homing_feedrate[] = HOMING_FEEDRATE;
119 121
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
120 122
 volatile int feedmultiply=100; //100->1 200->2
@@ -215,7 +217,9 @@ void loop()
215 217
 {
216 218
   if(buflen<3)
217 219
     get_command();
220
+  #ifdef SDSUPPORT
218 221
   card.checkautostart(false);
222
+  #endif
219 223
   if(buflen)
220 224
   {
221 225
     #ifdef SDSUPPORT
@@ -933,7 +937,7 @@ inline void get_arc_coordinates()
933 937
 
934 938
 void prepare_move()
935 939
 {
936
-  plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60.0/100.0);
940
+  plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0);
937 941
   for(int8_t i=0; i < NUM_AXIS; i++) {
938 942
     current_position[i] = destination[i];
939 943
   }
@@ -943,7 +947,7 @@ void prepare_arc_move(char isclockwise) {
943 947
   float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
944 948
 
945 949
   // Trace the arc
946
-  mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60.0/100.0, r, isclockwise);
950
+  mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60/100.0, r, isclockwise);
947 951
   
948 952
   // As far as the parser is concerned, the position is now == target. In reality the
949 953
   // motion control system might still be processing the action and the real tool position

+ 704
- 593
Marlin/planner.cpp
File diff suppressed because it is too large
View File


+ 95
- 92
Marlin/planner.h View File

@@ -1,93 +1,96 @@
1
-/*
2
-  planner.h - buffers movement commands and manages the acceleration profile plan
3
-  Part of Grbl
4
-
5
-  Copyright (c) 2009-2011 Simen Svale Skogsrud
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
-// This module is to be considered a sub-module of stepper.c. Please don't include 
22
-// this file from any other module.
23
-
24
-#ifndef planner_h
25
-#define planner_h
26
-
27
-#include "Configuration.h"
28
-
29
-// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in 
30
-// the source g-code and may never actually be reached if acceleration management is active.
31
-typedef struct {
32
-  // Fields used by the bresenham algorithm for tracing the line
33
-  long steps_x, steps_y, steps_z, steps_e;  // Step count along each axis
34
-  long step_event_count;                    // The number of step events required to complete this block
35
-  volatile long accelerate_until;           // The index of the step event on which to stop acceleration
36
-  volatile long decelerate_after;           // The index of the step event on which to start decelerating
37
-  volatile long acceleration_rate;          // The acceleration rate used for acceleration calculation
38
-  unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
39
-  #ifdef ADVANCE
40
-    long advance_rate;
41
-    volatile long initial_advance;
42
-    volatile long final_advance;
43
-    float advance;
44
-  #endif
45
-
46
-  // Fields used by the motion planner to manage acceleration
47
-  float speed_x, speed_y, speed_z, speed_e;          // Nominal mm/minute for each axis
48
-  float nominal_speed;                               // The nominal speed for this block in mm/min  
49
-  float millimeters;                                 // The total travel of this block in mm
50
-  float entry_speed;
51
-  float acceleration;                                // acceleration mm/sec^2
52
-
53
-  // Settings for the trapezoid generator
54
-  long nominal_rate;                                 // The nominal step rate for this block in step_events/sec 
55
-  volatile long initial_rate;                        // The jerk-adjusted step rate at start of block  
56
-  volatile long final_rate;                          // The minimal rate at exit
57
-  long acceleration_st;                              // acceleration steps/sec^2
58
-  volatile char busy;
59
-} block_t;
60
-
61
-// Initialize the motion plan subsystem      
62
-void plan_init();
63
-
64
-// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in 
65
-// millimaters. Feed rate specifies the speed of the motion.
66
-void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate);
67
-
68
-// Set position. Used for G92 instructions.
69
-void plan_set_position(const float &x, const float &y, const float &z, const float &e);
70
-
71
-
72
-// Called when the current block is no longer needed. Discards the block and makes the memory
73
-// availible for new blocks.
74
-void plan_discard_current_block();
75
-
76
-// Gets the current block. Returns NULL if buffer empty
77
-block_t *plan_get_current_block();
78
-
79
-void check_axes_activity();
80
-
81
-extern unsigned long minsegmenttime;
82
-extern float max_feedrate[4]; // set the max speeds
83
-extern float axis_steps_per_unit[4];
84
-extern long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
85
-extern float minimumfeedrate;
86
-extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
87
-extern float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
88
-extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
89
-extern float max_z_jerk;
90
-extern float mintravelfeedrate;
91
-extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
92
-
1
+/*
2
+  planner.h - buffers movement commands and manages the acceleration profile plan
3
+  Part of Grbl
4
+
5
+  Copyright (c) 2009-2011 Simen Svale Skogsrud
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
+// This module is to be considered a sub-module of stepper.c. Please don't include 
22
+// this file from any other module.
23
+
24
+#ifndef planner_h
25
+#define planner_h
26
+
27
+#include "Configuration.h"
28
+
29
+// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in 
30
+// the source g-code and may never actually be reached if acceleration management is active.
31
+typedef struct {
32
+  // Fields used by the bresenham algorithm for tracing the line
33
+  long steps_x, steps_y, steps_z, steps_e;  // Step count along each axis
34
+  long step_event_count;                    // The number of step events required to complete this block
35
+  volatile long accelerate_until;           // The index of the step event on which to stop acceleration
36
+  volatile long decelerate_after;           // The index of the step event on which to start decelerating
37
+  volatile long acceleration_rate;          // The acceleration rate used for acceleration calculation
38
+  unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
39
+  #ifdef ADVANCE
40
+//    long advance_rate;
41
+//    volatile long initial_advance;
42
+//    volatile long final_advance;
43
+//    float advance;
44
+  #endif
45
+
46
+  // Fields used by the motion planner to manage acceleration
47
+//  float speed_x, speed_y, speed_z, speed_e;        // Nominal mm/minute for each axis
48
+  float nominal_speed;                               // The nominal speed for this block in mm/min  
49
+  float entry_speed;                                 // Entry speed at previous-current junction in mm/min
50
+  float max_entry_speed;                             // Maximum allowable junction entry speed in mm/min
51
+  float millimeters;                                 // The total travel of this block in mm
52
+  float acceleration;                                // acceleration mm/sec^2
53
+  unsigned char recalculate_flag;                          // Planner flag to recalculate trapezoids on entry junction
54
+  unsigned char nominal_length_flag;                       // Planner flag for nominal speed always reached
55
+
56
+  // Settings for the trapezoid generator
57
+  long nominal_rate;                                 // The nominal step rate for this block in step_events/sec 
58
+  volatile long initial_rate;                        // The jerk-adjusted step rate at start of block  
59
+  volatile long final_rate;                          // The minimal rate at exit
60
+  long acceleration_st;                              // acceleration steps/sec^2
61
+  volatile char busy;
62
+} block_t;
63
+
64
+// Initialize the motion plan subsystem      
65
+void plan_init();
66
+
67
+// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in 
68
+// millimaters. Feed rate specifies the speed of the motion.
69
+void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate);
70
+
71
+// Set position. Used for G92 instructions.
72
+void plan_set_position(const float &x, const float &y, const float &z, const float &e);
73
+
74
+
75
+// Called when the current block is no longer needed. Discards the block and makes the memory
76
+// availible for new blocks.
77
+void plan_discard_current_block();
78
+
79
+// Gets the current block. Returns NULL if buffer empty
80
+block_t *plan_get_current_block();
81
+
82
+void check_axes_activity();
83
+
84
+extern unsigned long minsegmenttime;
85
+extern float max_feedrate[4]; // set the max speeds
86
+extern float axis_steps_per_unit[4];
87
+extern long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
88
+extern float minimumfeedrate;
89
+extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
90
+extern float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
91
+extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
92
+extern float max_z_jerk;
93
+extern float mintravelfeedrate;
94
+extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
95
+
93 96
 #endif

+ 616
- 611
Marlin/stepper.cpp
File diff suppressed because it is too large
View File


+ 563
- 561
Marlin/temperature.cpp
File diff suppressed because it is too large
View File


+ 9
- 7
Marlin/thermistortables.h View File

@@ -1,12 +1,14 @@
1 1
 #ifndef THERMISTORTABLES_H_
2 2
 #define THERMISTORTABLES_H_
3 3
 
4
+#include <avr/pgmspace.h>
5
+
4 6
 #define OVERSAMPLENR 16
5 7
 
6 8
 #if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORBED == 1) //100k bed thermistor
7 9
 
8 10
 #define NUMTEMPS_1 61
9
-const short temptable_1[NUMTEMPS_1][2] = {
11
+const short temptable_1[NUMTEMPS_1][2] PROGMEM = {
10 12
 {       23*OVERSAMPLENR ,       300     },
11 13
 {       25*OVERSAMPLENR ,       295     },
12 14
 {       27*OVERSAMPLENR ,       290     },
@@ -72,7 +74,7 @@ const short temptable_1[NUMTEMPS_1][2] = {
72 74
 #endif
73 75
 #if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORBED == 2) //200k bed thermistor
74 76
 #define NUMTEMPS_2 21
75
-const short temptable_2[NUMTEMPS_2][2] = {
77
+const short temptable_2[NUMTEMPS_2][2] PROGMEM = {
76 78
    {1*OVERSAMPLENR, 848},
77 79
    {54*OVERSAMPLENR, 275},
78 80
    {107*OVERSAMPLENR, 228},
@@ -99,7 +101,7 @@ const short temptable_2[NUMTEMPS_2][2] = {
99 101
 #endif
100 102
 #if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORBED == 3) //mendel-parts
101 103
 #define NUMTEMPS_3 28
102
-const short temptable_3[NUMTEMPS_3][2] = {
104
+const short temptable_3[NUMTEMPS_3][2] PROGMEM = {
103 105
                 {1*OVERSAMPLENR,864},
104 106
                 {21*OVERSAMPLENR,300},
105 107
                 {25*OVERSAMPLENR,290},
@@ -134,7 +136,7 @@ const short temptable_3[NUMTEMPS_3][2] = {
134 136
 #if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORBED == 4) //10k thermistor
135 137
 
136 138
 #define NUMTEMPS_4 20
137
-short temptable_4[NUMTEMPS_4][2] = {
139
+const short temptable_4[NUMTEMPS_4][2] PROGMEM = {
138 140
    {1*OVERSAMPLENR, 430},
139 141
    {54*OVERSAMPLENR, 137},
140 142
    {107*OVERSAMPLENR, 107},
@@ -161,7 +163,7 @@ short temptable_4[NUMTEMPS_4][2] = {
161 163
 #if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
162 164
 
163 165
 #define NUMTEMPS_5 61
164
-const short temptable_5[NUMTEMPS_5][2] = {
166
+const short temptable_5[NUMTEMPS_5][2] PROGMEM = {
165 167
 {1*OVERSAMPLENR, 713},
166 168
 {18*OVERSAMPLENR, 316},
167 169
 {35*OVERSAMPLENR, 266},
@@ -228,7 +230,7 @@ const short temptable_5[NUMTEMPS_5][2] = {
228 230
 
229 231
 #if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
230 232
 #define NUMTEMPS_6 36
231
-const short temptable_6[NUMTEMPS_6][2] = {
233
+const short temptable_6[NUMTEMPS_6][2] PROGMEM = {
232 234
    {28*OVERSAMPLENR, 250},
233 235
    {31*OVERSAMPLENR, 245},
234 236
    {35*OVERSAMPLENR, 240},
@@ -270,7 +272,7 @@ const short temptable_6[NUMTEMPS_6][2] = {
270 272
 
271 273
 #if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
272 274
 #define NUMTEMPS_7 54
273
-const short temptable_7[NUMTEMPS_7][2] = {
275
+const short temptable_7[NUMTEMPS_7][2] PROGMEM = {
274 276
    {46*OVERSAMPLENR, 270},
275 277
    {50*OVERSAMPLENR, 265},
276 278
    {54*OVERSAMPLENR, 260},

Loading…
Cancel
Save