Browse Source

Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into Marlin_v1

Bernhard Kubicek 13 years ago
parent
commit
163efdf1c7
4 changed files with 707 additions and 753 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 5
    108
      Marlin/Marlin.pde
  3. 7
    6
      Marlin/motion_control.cpp
  4. 693
    637
      Marlin/pins.h

+ 2
- 2
Marlin/Configuration.h View File

14
 // Gen6 = 5,
14
 // Gen6 = 5,
15
 // Sanguinololu 1.2 and above = 62
15
 // Sanguinololu 1.2 and above = 62
16
 // Ultimaker = 7,
16
 // Ultimaker = 7,
17
+// Teensylu = 8
17
 #define MOTHERBOARD 7
18
 #define MOTHERBOARD 7
18
-//#define MOTHERBOARD 5
19
+
19
 
20
 
20
 
21
 
21
 //// Thermistor settings:
22
 //// Thermistor settings:
59
 // #define ULTRA_LCD  //any lcd 
60
 // #define ULTRA_LCD  //any lcd 
60
 
61
 
61
 #define ULTIPANEL
62
 #define ULTIPANEL
62
-#define ULTIPANEL
63
 #ifdef ULTIPANEL
63
 #ifdef ULTIPANEL
64
   //#define NEWPANEL  //enable this if you have a click-encoder panel
64
   //#define NEWPANEL  //enable this if you have a click-encoder panel
65
   #define SDSUPPORT
65
   #define SDSUPPORT

+ 5
- 108
Marlin/Marlin.pde View File

1152
 inline void get_arc_coordinates()
1152
 inline void get_arc_coordinates()
1153
 {
1153
 {
1154
    get_coordinates();
1154
    get_coordinates();
1155
-   if(code_seen("I")) offset[0] = code_value();
1156
-   if(code_seen("J")) offset[1] = code_value();
1155
+   if(code_seen('I')) offset[0] = code_value();
1156
+   if(code_seen('J')) offset[1] = code_value();
1157
 }
1157
 }
1158
 
1158
 
1159
 void prepare_move()
1159
 void prepare_move()
1165
 }
1165
 }
1166
 
1166
 
1167
 void prepare_arc_move(char isclockwise) {
1167
 void prepare_arc_move(char isclockwise) {
1168
-#if 0
1169
-  if (radius_mode) {
1170
-    /* 
1171
-      We need to calculate the center of the circle that has the designated radius and passes
1172
-      through both the current position and the target position. This method calculates the following
1173
-      set of equations where [x,y] is the vector from current to target position, d == magnitude of 
1174
-      that vector, h == hypotenuse of the triangle formed by the radius of the circle, the distance to
1175
-      the center of the travel vector. A vector perpendicular to the travel vector [-y,x] is scaled to the 
1176
-      length of h [-y/d*h, x/d*h] and added to the center of the travel vector [x/2,y/2] to form the new point 
1177
-      [i,j] at [x/2-y/d*h, y/2+x/d*h] which will be the center of our arc.
1178
-      
1179
-      d^2 == x^2 + y^2
1180
-      h^2 == r^2 - (d/2)^2
1181
-      i == x/2 - y/d*h
1182
-      j == y/2 + x/d*h
1183
-      
1184
-                                                           O <- [i,j]
1185
-                                                        -  |
1186
-                                              r      -     |
1187
-                                                  -        |
1188
-                                               -           | h
1189
-                                            -              |
1190
-                              [0,0] ->  C -----------------+--------------- T  <- [x,y]
1191
-                                        | <------ d/2 ---->|
1192
-                
1193
-      C - Current position
1194
-      T - Target position
1195
-      O - center of circle that pass through both C and T
1196
-      d - distance from C to T
1197
-      r - designated radius
1198
-      h - distance from center of CT to O
1199
-      
1200
-      Expanding the equations:
1201
-
1202
-      d -> sqrt(x^2 + y^2)
1203
-      h -> sqrt(4 * r^2 - x^2 - y^2)/2
1204
-      i -> (x - (y * sqrt(4 * r^2 - x^2 - y^2)) / sqrt(x^2 + y^2)) / 2 
1205
-      j -> (y + (x * sqrt(4 * r^2 - x^2 - y^2)) / sqrt(x^2 + y^2)) / 2
1206
-     
1207
-      Which can be written:
1208
-      
1209
-      i -> (x - (y * sqrt(4 * r^2 - x^2 - y^2))/sqrt(x^2 + y^2))/2
1210
-      j -> (y + (x * sqrt(4 * r^2 - x^2 - y^2))/sqrt(x^2 + y^2))/2
1211
-      
1212
-      Which we for size and speed reasons optimize to:
1213
-
1214
-      h_x2_div_d = sqrt(4 * r^2 - x^2 - y^2)/sqrt(x^2 + y^2)
1215
-      i = (x - (y * h_x2_div_d))/2
1216
-      j = (y + (x * h_x2_div_d))/2
1217
-      
1218
-    */
1219
-    
1220
-    // Calculate the change in position along each selected axis
1221
-    double x = target[gc.plane_axis_0]-gc.position[gc.plane_axis_0];
1222
-    double y = target[gc.plane_axis_1]-gc.position[gc.plane_axis_1];
1223
-    
1224
-    clear_vector(offset);
1225
-    double h_x2_div_d = -sqrt(4 * r*r - x*x - y*y)/hypot(x,y); // == -(h * 2 / d)
1226
-    // If r is smaller than d, the arc is now traversing the complex plane beyond the reach of any
1227
-    // real CNC, and thus - for practical reasons - we will terminate promptly:
1228
-    if(isnan(h_x2_div_d)) { FAIL(STATUS_FLOATING_POINT_ERROR); return(gc.status_code); }
1229
-    // Invert the sign of h_x2_div_d if the circle is counter clockwise (see sketch below)
1230
-    if (gc.motion_mode == MOTION_MODE_CCW_ARC) { h_x2_div_d = -h_x2_div_d; }
1231
-    
1232
-    /* The counter clockwise circle lies to the left of the target direction. When offset is positive,
1233
-       the left hand circle will be generated - when it is negative the right hand circle is generated.
1234
-       
1235
-       
1236
-                                                         T  <-- Target position
1237
-                                                         
1238
-                                                         ^ 
1239
-              Clockwise circles with this center         |          Clockwise circles with this center will have
1240
-              will have > 180 deg of angular travel      |          < 180 deg of angular travel, which is a good thing!
1241
-                                               \         |          /   
1242
-  center of arc when h_x2_div_d is positive ->  x <----- | -----> x <- center of arc when h_x2_div_d is negative
1243
-                                                         |
1244
-                                                         |
1245
-                                                         
1246
-                                                         C  <-- Current position                                 */
1247
-                
1248
-
1249
-    // Negative R is g-code-alese for "I want a circle with more than 180 degrees of travel" (go figure!), 
1250
-    // even though it is advised against ever generating such circles in a single line of g-code. By 
1251
-    // inverting the sign of h_x2_div_d the center of the circles is placed on the opposite side of the line of
1252
-    // travel and thus we get the unadvisably long arcs as prescribed.
1253
-    if (r < 0) { 
1254
-        h_x2_div_d = -h_x2_div_d; 
1255
-        r = -r; // Finished with r. Set to positive for mc_arc
1256
-    }        
1257
-    // Complete the operation by calculating the actual center of the arc
1258
-    offset[gc.plane_axis_0] = 0.5*(x-(y*h_x2_div_d));
1259
-    offset[gc.plane_axis_1] = 0.5*(y+(x*h_x2_div_d));
1260
-
1261
-  } else { // Offset mode specific computations
1262
-#endif
1263
-    float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
1264
-
1265
-//  }
1266
-  
1267
-  // Set clockwise/counter-clockwise sign for mc_arc computations
1268
-//  uint8_t isclockwise = false;
1269
-//  if (gc.motion_mode == MOTION_MODE_CW_ARC) { isclockwise = true; }
1168
+  float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
1270
 
1169
 
1271
   // Trace the arc
1170
   // Trace the arc
1272
   mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60.0/100.0, r, isclockwise);
1171
   mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60.0/100.0, r, isclockwise);
1273
-    
1274
-//  }
1275
   
1172
   
1276
   // As far as the parser is concerned, the position is now == target. In reality the
1173
   // As far as the parser is concerned, the position is now == target. In reality the
1277
   // motion control system might still be processing the action and the real tool position
1174
   // motion control system might still be processing the action and the real tool position
1278
   // in any intermediate location.
1175
   // in any intermediate location.
1279
-  for(int ii=0; ii < NUM_AXIS; ii++) {
1280
-    current_position[ii] = destination[ii];
1176
+  for(int i=0; i < NUM_AXIS; i++) {
1177
+    current_position[i] = destination[i];
1281
   }
1178
   }
1282
 }
1179
 }
1283
 
1180
 

+ 7
- 6
Marlin/motion_control.cpp View File

19
   along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
   along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
20
 */
20
 */
21
 
21
 
22
-//#include "motion_control.h"
23
 #include "Configuration.h"
22
 #include "Configuration.h"
24
 #include "Marlin.h"
23
 #include "Marlin.h"
25
-//#include <util/delay.h>
26
-//#include <math.h>
27
-//#include <stdlib.h>
28
 #include "stepper.h"
24
 #include "stepper.h"
29
 #include "planner.h"
25
 #include "planner.h"
30
 
26
 
35
 {      
31
 {      
36
   //   int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled();
32
   //   int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled();
37
   //   plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc
33
   //   plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc
38
-  SERIAL_ECHOLN("mc_arc.");
39
   float center_axis0 = position[axis_0] + offset[axis_0];
34
   float center_axis0 = position[axis_0] + offset[axis_0];
40
   float center_axis1 = position[axis_1] + offset[axis_1];
35
   float center_axis1 = position[axis_1] + offset[axis_1];
41
   float linear_travel = target[axis_linear] - position[axis_linear];
36
   float linear_travel = target[axis_linear] - position[axis_linear];
37
+  float extruder_travel = target[E_AXIS] - position[E_AXIS];
42
   float r_axis0 = -offset[axis_0];  // Radius vector from center to current location
38
   float r_axis0 = -offset[axis_0];  // Radius vector from center to current location
43
   float r_axis1 = -offset[axis_1];
39
   float r_axis1 = -offset[axis_1];
44
   float rt_axis0 = target[axis_0] - center_axis0;
40
   float rt_axis0 = target[axis_0] - center_axis0;
60
   */
56
   */
61
   float theta_per_segment = angular_travel/segments;
57
   float theta_per_segment = angular_travel/segments;
62
   float linear_per_segment = linear_travel/segments;
58
   float linear_per_segment = linear_travel/segments;
59
+  float extruder_per_segment = extruder_travel/segments;
63
   
60
   
64
   /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector,
61
   /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector,
65
      and phi is the angle of rotation. Based on the solution approach by Jens Geisler.
62
      and phi is the angle of rotation. Based on the solution approach by Jens Geisler.
90
   float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation
87
   float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation
91
   float sin_T = theta_per_segment;
88
   float sin_T = theta_per_segment;
92
   
89
   
93
-  float arc_target[3];
90
+  float arc_target[4];
94
   float sin_Ti;
91
   float sin_Ti;
95
   float cos_Ti;
92
   float cos_Ti;
96
   float r_axisi;
93
   float r_axisi;
99
 
96
 
100
   // Initialize the linear axis
97
   // Initialize the linear axis
101
   arc_target[axis_linear] = position[axis_linear];
98
   arc_target[axis_linear] = position[axis_linear];
99
+  
100
+  // Initialize the extruder axis
101
+  arc_target[E_AXIS] = position[E_AXIS];
102
 
102
 
103
   for (i = 1; i<segments; i++) { // Increment (segments-1)
103
   for (i = 1; i<segments; i++) { // Increment (segments-1)
104
     
104
     
122
     arc_target[axis_0] = center_axis0 + r_axis0;
122
     arc_target[axis_0] = center_axis0 + r_axis0;
123
     arc_target[axis_1] = center_axis1 + r_axis1;
123
     arc_target[axis_1] = center_axis1 + r_axis1;
124
     arc_target[axis_linear] += linear_per_segment;
124
     arc_target[axis_linear] += linear_per_segment;
125
+    arc_target[E_AXIS] += extruder_per_segment;
125
     plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], target[E_AXIS], feed_rate);
126
     plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], target[E_AXIS], feed_rate);
126
     
127
     
127
   }
128
   }

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


Loading…
Cancel
Save