Bladeren bron

Patch to fix kinematics

Scott Lahteine 8 jaren geleden
bovenliggende
commit
d65f5d816f
2 gewijzigde bestanden met toevoegingen van 73 en 58 verwijderingen
  1. 13
    11
      Marlin/Marlin.h
  2. 60
    47
      Marlin/Marlin_main.cpp

+ 13
- 11
Marlin/Marlin.h Bestand weergeven

302
 float code_value_temp_abs();
302
 float code_value_temp_abs();
303
 float code_value_temp_diff();
303
 float code_value_temp_diff();
304
 
304
 
305
-#if ENABLED(DELTA)
305
+#if IS_KINEMATIC
306
   extern float delta[ABC];
306
   extern float delta[ABC];
307
-  extern float endstop_adj[ABC]; // axis[n].endstop_adj
308
-  extern float delta_radius;
309
-  extern float delta_diagonal_rod;
310
-  extern float delta_segments_per_second;
311
-  extern float delta_diagonal_rod_trim_tower_1;
312
-  extern float delta_diagonal_rod_trim_tower_2;
313
-  extern float delta_diagonal_rod_trim_tower_3;
314
   void inverse_kinematics(const float cartesian[XYZ]);
307
   void inverse_kinematics(const float cartesian[XYZ]);
308
+#endif
309
+
310
+#if ENABLED(DELTA)
311
+  extern float delta[ABC],
312
+               endstop_adj[ABC],
313
+               delta_radius,
314
+               delta_diagonal_rod,
315
+               delta_segments_per_second,
316
+               delta_diagonal_rod_trim_tower_1,
317
+               delta_diagonal_rod_trim_tower_2,
318
+               delta_diagonal_rod_trim_tower_3;
315
   void recalc_delta_settings(float radius, float diagonal_rod);
319
   void recalc_delta_settings(float radius, float diagonal_rod);
316
 #elif IS_SCARA
320
 #elif IS_SCARA
317
-  extern float delta[ABC];
318
   extern float axis_scaling[ABC];  // Build size scaling
321
   extern float axis_scaling[ABC];  // Build size scaling
319
-  void inverse_kinematics(const float cartesian[XYZ]);
320
-  void forward_kinematics_SCARA(float f_scara[ABC]);
322
+  void forward_kinematics_SCARA(const float &a, const float &b);
321
 #endif
323
 #endif
322
 
324
 
323
 #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
325
 #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)

+ 60
- 47
Marlin/Marlin_main.cpp Bestand weergeven

465
   #define COS_60 0.5
465
   #define COS_60 0.5
466
 
466
 
467
   float delta[ABC],
467
   float delta[ABC],
468
-        cartes[XYZ] = { 0 },
469
         endstop_adj[ABC] = { 0 };
468
         endstop_adj[ABC] = { 0 };
470
 
469
 
471
   // these are the default values, can be overriden with M665
470
   // these are the default values, can be overriden with M665
487
         delta_clip_start_height = Z_MAX_POS;
486
         delta_clip_start_height = Z_MAX_POS;
488
 
487
 
489
   float delta_safe_distance_from_top();
488
   float delta_safe_distance_from_top();
490
-  void get_cartesian_from_steppers();
491
 
489
 
492
 #else
490
 #else
493
 
491
 
508
 
506
 
509
   float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND,
507
   float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND,
510
         delta[ABC],
508
         delta[ABC],
511
-        axis_scaling[ABC] = { 1, 1, 1 },    // Build size scaling, default to 1
512
-        cartes[XYZ] = { 0 };
513
-  void get_cartesian_from_steppers() { }    // to be written later
509
+        axis_scaling[ABC] = { 1, 1, 1 };    // Build size scaling, default to 1
514
 #endif
510
 #endif
515
 
511
 
512
+float cartes[XYZ] = { 0 };
513
+
516
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
514
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
517
   bool filament_sensor = false;  //M405 turns on filament_sensor control, M406 turns it off
515
   bool filament_sensor = false;  //M405 turns on filament_sensor control, M406 turns it off
518
   float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404
516
   float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404
598
 void get_available_commands();
596
 void get_available_commands();
599
 void process_next_command();
597
 void process_next_command();
600
 void prepare_move_to_destination();
598
 void prepare_move_to_destination();
599
+
600
+void get_cartesian_from_steppers();
601
 void set_current_from_steppers_for_axis(AxisEnum axis);
601
 void set_current_from_steppers_for_axis(AxisEnum axis);
602
 
602
 
603
 #if ENABLED(ARC_SUPPORT)
603
 #if ENABLED(ARC_SUPPORT)
1347
     }
1347
     }
1348
   #endif
1348
   #endif
1349
 
1349
 
1350
-  #if ENABLED(SCARA)
1350
+  #if ENABLED(MORGAN_SCARA)
1351
 
1351
 
1352
     if (axis == X_AXIS || axis == Y_AXIS) {
1352
     if (axis == X_AXIS || axis == Y_AXIS) {
1353
 
1353
 
1362
        * and calculates homing offset using forward kinematics
1362
        * and calculates homing offset using forward kinematics
1363
        */
1363
        */
1364
       inverse_kinematics(homeposition);
1364
       inverse_kinematics(homeposition);
1365
-      forward_kinematics_SCARA(delta);
1365
+      forward_kinematics_SCARA(delta[A_AXIS], delta[B_AXIS]);
1366
 
1366
 
1367
-      // SERIAL_ECHOPAIR("Delta X=", delta[X_AXIS]);
1368
-      // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]);
1367
+      // SERIAL_ECHOPAIR("Delta X=", cartes[X_AXIS]);
1368
+      // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(cartes[Y_AXIS]);
1369
 
1369
 
1370
-      current_position[axis] = LOGICAL_POSITION(delta[axis], axis);
1370
+      current_position[axis] = LOGICAL_POSITION(cartes[axis], axis);
1371
 
1371
 
1372
       /**
1372
       /**
1373
        * SCARA home positions are based on configuration since the actual
1373
        * SCARA home positions are based on configuration since the actual
1374
        * limits are determined by the inverse kinematic transform.
1374
        * limits are determined by the inverse kinematic transform.
1375
        */
1375
        */
1376
-      soft_endstop_min[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis));
1377
-      soft_endstop_max[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis));
1376
+      soft_endstop_min[axis] = base_min_pos(axis); // + (cartes[axis] - base_home_pos(axis));
1377
+      soft_endstop_max[axis] = base_max_pos(axis); // + (cartes[axis] - base_home_pos(axis));
1378
     }
1378
     }
1379
     else
1379
     else
1380
   #endif
1380
   #endif
5089
 
5089
 
5090
   stepper.report_positions();
5090
   stepper.report_positions();
5091
 
5091
 
5092
-  #if ENABLED(SCARA)
5092
+  #if IS_SCARA
5093
     SERIAL_PROTOCOLPGM("SCARA Theta:");
5093
     SERIAL_PROTOCOLPGM("SCARA Theta:");
5094
     SERIAL_PROTOCOL(delta[X_AXIS]);
5094
     SERIAL_PROTOCOL(delta[X_AXIS]);
5095
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
5095
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
5327
     if (code_seen(axis_codes[i]))
5327
     if (code_seen(axis_codes[i]))
5328
       set_home_offset((AxisEnum)i, code_value_axis_units(i));
5328
       set_home_offset((AxisEnum)i, code_value_axis_units(i));
5329
 
5329
 
5330
-  #if ENABLED(SCARA)
5330
+  #if IS_SCARA
5331
     if (code_seen('T')) set_home_offset(X_AXIS, code_value_axis_units(X_AXIS)); // Theta
5331
     if (code_seen('T')) set_home_offset(X_AXIS, code_value_axis_units(X_AXIS)); // Theta
5332
     if (code_seen('P')) set_home_offset(Y_AXIS, code_value_axis_units(Y_AXIS)); // Psi
5332
     if (code_seen('P')) set_home_offset(Y_AXIS, code_value_axis_units(Y_AXIS)); // Psi
5333
   #endif
5333
   #endif
5808
   #endif
5808
   #endif
5809
 }
5809
 }
5810
 
5810
 
5811
-#if ENABLED(SCARA)
5812
-  bool SCARA_move_to_cal(uint8_t delta_x, uint8_t delta_y) {
5811
+#if ENABLED(MORGAN_SCARA)
5812
+  bool SCARA_move_to_cal(uint8_t delta_a, uint8_t delta_b) {
5813
     //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
5813
     //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
5814
     //SERIAL_ECHOLNPGM(" Soft endstops disabled");
5814
     //SERIAL_ECHOLNPGM(" Soft endstops disabled");
5815
     if (IsRunning()) {
5815
     if (IsRunning()) {
5816
       //gcode_get_destination(); // For X Y Z E F
5816
       //gcode_get_destination(); // For X Y Z E F
5817
-      delta[X_AXIS] = delta_x;
5818
-      delta[Y_AXIS] = delta_y;
5819
-      forward_kinematics_SCARA(delta);
5820
-      destination[X_AXIS] = delta[X_AXIS] / axis_scaling[X_AXIS];
5821
-      destination[Y_AXIS] = delta[Y_AXIS] / axis_scaling[Y_AXIS];
5817
+      forward_kinematics_SCARA(delta_a, delta_b);
5818
+      destination[X_AXIS] = cartes[X_AXIS] / axis_scaling[X_AXIS];
5819
+      destination[Y_AXIS] = cartes[Y_AXIS] / axis_scaling[Y_AXIS];
5820
+      destination[Z_AXIS] = current_position[Z_AXIS];
5822
       prepare_move_to_destination();
5821
       prepare_move_to_destination();
5823
       //ok_to_send();
5822
       //ok_to_send();
5824
       return true;
5823
       return true;
7456
         gcode_M303();
7455
         gcode_M303();
7457
         break;
7456
         break;
7458
 
7457
 
7459
-      #if ENABLED(SCARA)
7458
+      #if ENABLED(MORGAN_SCARA)
7460
         case 360:  // M360 SCARA Theta pos1
7459
         case 360:  // M360 SCARA Theta pos1
7461
           if (gcode_M360()) return;
7460
           if (gcode_M360()) return;
7462
           break;
7461
           break;
7794
     forward_kinematics_DELTA(point[A_AXIS], point[B_AXIS], point[C_AXIS]);
7793
     forward_kinematics_DELTA(point[A_AXIS], point[B_AXIS], point[C_AXIS]);
7795
   }
7794
   }
7796
 
7795
 
7797
-  void get_cartesian_from_steppers() {
7798
-    forward_kinematics_DELTA(stepper.get_axis_position_mm(A_AXIS),
7799
-                             stepper.get_axis_position_mm(B_AXIS),
7800
-                             stepper.get_axis_position_mm(C_AXIS));
7801
-  }
7802
-
7803
   #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
7796
   #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
7804
 
7797
 
7805
     // Adjust print surface height by linear interpolation over the bed_level array.
7798
     // Adjust print surface height by linear interpolation over the bed_level array.
8274
 
8267
 
8275
 #endif // HAS_CONTROLLERFAN
8268
 #endif // HAS_CONTROLLERFAN
8276
 
8269
 
8277
-#if ENABLED(SCARA)
8270
+#if IS_SCARA
8278
 
8271
 
8279
-  void forward_kinematics_SCARA(float f_scara[ABC]) {
8280
-    // Perform forward kinematics, and place results in delta[]
8272
+  void forward_kinematics_SCARA(const float &a, const float &b) {
8273
+    // Perform forward kinematics, and place results in cartes[]
8281
     // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014
8274
     // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014
8282
 
8275
 
8283
-    float x_sin, x_cos, y_sin, y_cos;
8276
+    float a_sin, a_cos, b_sin, b_cos;
8284
 
8277
 
8285
-    //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]);
8286
-    //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]);
8278
+    //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(a);
8279
+    //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(b);
8287
 
8280
 
8288
-    x_sin = sin(RADIANS(f_scara[X_AXIS])) * L1;
8289
-    x_cos = cos(RADIANS(f_scara[X_AXIS])) * L1;
8290
-    y_sin = sin(RADIANS(f_scara[Y_AXIS])) * L2;
8291
-    y_cos = cos(RADIANS(f_scara[Y_AXIS])) * L2;
8281
+    a_sin = sin(RADIANS(a)) * L1;
8282
+    a_cos = cos(RADIANS(a)) * L1;
8283
+    b_sin = sin(RADIANS(b)) * L2;
8284
+    b_cos = cos(RADIANS(b)) * L2;
8292
 
8285
 
8293
-    //SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin);
8294
-    //SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos);
8295
-    //SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin);
8296
-    //SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos);
8286
+    //SERIAL_ECHOPGM(" a_sin="); SERIAL_ECHO(a_sin);
8287
+    //SERIAL_ECHOPGM(" a_cos="); SERIAL_ECHO(a_cos);
8288
+    //SERIAL_ECHOPGM(" b_sin="); SERIAL_ECHO(b_sin);
8289
+    //SERIAL_ECHOPGM(" b_cos="); SERIAL_ECHOLN(b_cos);
8297
 
8290
 
8298
-    delta[X_AXIS] = x_cos + y_cos + SCARA_OFFSET_X;  //theta
8299
-    delta[Y_AXIS] = x_sin + y_sin + SCARA_OFFSET_Y;  //theta+phi
8291
+    cartes[X_AXIS] = a_cos + b_cos + SCARA_OFFSET_X;  //theta
8292
+    cartes[Y_AXIS] = a_sin + b_sin + SCARA_OFFSET_Y;  //theta+phi
8300
 
8293
 
8301
-    //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]);
8302
-    //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
8294
+    //SERIAL_ECHOPGM(" cartes[X_AXIS]="); SERIAL_ECHO(cartes[X_AXIS]);
8295
+    //SERIAL_ECHOPGM(" cartes[Y_AXIS]="); SERIAL_ECHOLN(cartes[Y_AXIS]);
8303
   }
8296
   }
8304
 
8297
 
8305
   void inverse_kinematics(const float cartesian[XYZ]) {
8298
   void inverse_kinematics(const float cartesian[XYZ]) {
8343
     //*/
8336
     //*/
8344
   }
8337
   }
8345
 
8338
 
8346
-#endif // MORGAN_SCARA
8339
+#endif // IS_SCARA
8340
+
8341
+void get_cartesian_from_steppers() {
8342
+  #if ENABLED(DELTA)
8343
+    forward_kinematics_DELTA(
8344
+      stepper.get_axis_position_mm(A_AXIS),
8345
+      stepper.get_axis_position_mm(B_AXIS),
8346
+      stepper.get_axis_position_mm(C_AXIS)
8347
+    );
8348
+  #elif IS_SCARA
8349
+    forward_kinematics_SCARA(
8350
+      stepper.get_axis_position_degrees(A_AXIS),
8351
+      stepper.get_axis_position_degrees(B_AXIS)
8352
+    );
8353
+    cartes[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
8354
+  #else
8355
+    cartes[X_AXIS] = stepper.get_axis_position_mm(X_AXIS);
8356
+    cartes[Y_AXIS] = stepper.get_axis_position_mm(Y_AXIS);
8357
+    cartes[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
8358
+  #endif
8359
+}
8347
 
8360
 
8348
 #if ENABLED(TEMP_STAT_LEDS)
8361
 #if ENABLED(TEMP_STAT_LEDS)
8349
 
8362
 

Laden…
Annuleren
Opslaan