forked from gnea/grbl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrbl11h-backlash.txt
575 lines (534 loc) · 22.1 KB
/
grbl11h-backlash.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
Only in bklc/: backlash.c
Only in bklc/: backlash.h
diff -c grbl/config.h bklc/config.h
*** grbl/config.h 2021-01-23 09:13:48.000000000 +0900
--- bklc/config.h 2022-05-19 00:19:22.000000000 +0900
***************
*** 102,116 ****
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
// will not be affected by pin sharing.
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
#define HOMING_CYCLE_0 (1<<Z_AXIS) // REQUIRED: First move Z to clear workspace.
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) // OPTIONAL: Then move X,Y at the same time.
// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable
// NOTE: The following are two examples to setup homing for 2-axis machines.
// #define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS)) // NOT COMPATIBLE WITH COREXY: Homes both X-Y in one cycle.
! // #define HOMING_CYCLE_0 (1<<X_AXIS) // COREXY COMPATIBLE: First home X
! // #define HOMING_CYCLE_1 (1<<Y_AXIS) // COREXY COMPATIBLE: Then home Y
// Number of homing cycles performed after when the machine initially jogs to limit switches.
// This help in preventing overshoot and should improve repeatability. This value should be one or
--- 102,121 ----
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
// will not be affected by pin sharing.
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
+ #if 0
#define HOMING_CYCLE_0 (1<<Z_AXIS) // REQUIRED: First move Z to clear workspace.
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) // OPTIONAL: Then move X,Y at the same time.
+ #endif
// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable
// NOTE: The following are two examples to setup homing for 2-axis machines.
// #define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS)) // NOT COMPATIBLE WITH COREXY: Homes both X-Y in one cycle.
! #if 1
! // uncomment below for 2 axes machine
! #define HOMING_CYCLE_0 (1<<X_AXIS) // COREXY COMPATIBLE: First home X
! #define HOMING_CYCLE_1 (1<<Y_AXIS) // COREXY COMPATIBLE: Then home Y
! #endif
// Number of homing cycles performed after when the machine initially jogs to limit switches.
// This help in preventing overshoot and should improve repeatability. This value should be one or
***************
*** 688,692 ****
--- 693,701 ----
// Paste default settings definitions here.
+ /* ---------------------------------------------------------------------------------------
+ backlash compensation ported from grbl-mega
+ */
+ #define BACKLASH_COMP // uncomment to enable backlash compensation
#endif
diff -c grbl/defaults.h bklc/defaults.h
*** grbl/defaults.h 2021-01-23 09:13:48.000000000 +0900
--- bklc/defaults.h 2022-05-17 09:33:41.000000000 +0900
***************
*** 32,37 ****
--- 32,42 ----
#define DEFAULT_X_STEPS_PER_MM 250.0
#define DEFAULT_Y_STEPS_PER_MM 250.0
#define DEFAULT_Z_STEPS_PER_MM 250.0
+ #ifdef BACKLASH_COMP
+ #define DEFAULT_X_BACKLASH_MM 0.0
+ #define DEFAULT_Y_BACKLASH_MM 0.0
+ #define DEFAULT_Z_BACKLASH_MM 0.0
+ #endif
#define DEFAULT_X_MAX_RATE 500.0 // mm/min
#define DEFAULT_Y_MAX_RATE 500.0 // mm/min
#define DEFAULT_Z_MAX_RATE 500.0 // mm/min
Common subdirectories: grbl/examples and bklc/examples
diff -c grbl/grbl.h bklc/grbl.h
*** grbl/grbl.h 2021-01-23 09:13:48.000000000 +0900
--- bklc/grbl.h 2022-05-17 09:33:45.000000000 +0900
***************
*** 46,51 ****
--- 46,52 ----
#include "defaults.h"
#include "cpu_map.h"
#include "planner.h"
+ #include "backlash.h"
#include "coolant_control.h"
#include "eeprom.h"
#include "gcode.h"
diff -c grbl/main.c bklc/main.c
*** grbl/main.c 2021-01-23 09:13:48.000000000 +0900
--- bklc/main.c 2022-05-17 09:31:48.000000000 +0900
***************
*** 43,48 ****
--- 43,52 ----
settings_init(); // Load Grbl settings from EEPROM
stepper_init(); // Configure stepper pins and interrupt timers
system_init(); // Configure pinout pins and pin-change interrupt
+ #if 0
+ DDRC |= (1<<4); // A4 to output
+ PORTC &= ~(1<<4); // A4 to LOW
+ #endif
memset(sys_position,0,sizeof(sys_position)); // Clear machine position.
sei(); // Enable interrupts
***************
*** 93,98 ****
--- 97,105 ----
probe_init();
plan_reset(); // Clear block buffer and planner variables
st_reset(); // Clear stepper subsystem variables.
+ #ifdef BACKLASH_COMP
+ backlash_initialize();
+ #endif
// Sync cleared gcode and planner positions to current system position.
plan_sync_position();
diff -c grbl/motion_control.c bklc/motion_control.c
*** grbl/motion_control.c 2021-01-23 09:13:48.000000000 +0900
--- bklc/motion_control.c 2022-05-18 23:05:09.000000000 +0900
***************
*** 35,41 ****
// from everywhere in Grbl.
if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE)) {
// NOTE: Block jog state. Jogging is a special case and soft limits are handled independently.
! if (sys.state != STATE_JOG) { limits_soft_check(target); }
}
// If in check gcode mode, prevent motion by blocking planner. Soft limits still work.
--- 35,46 ----
// from everywhere in Grbl.
if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE)) {
// NOTE: Block jog state. Jogging is a special case and soft limits are handled independently.
! #if defined(BACKLASH_COMP)
! // And NO soft limits check at backlash comp
! if (sys.state != STATE_JOG && !(pl_data->condition & (1<<PL_COND_FLAG_BACKLASH_COMP))) { limits_soft_check(target); }
! #else
! if (sys.state != STATE_JOG) { limits_soft_check(target); }
! #endif
}
// If in check gcode mode, prevent motion by blocking planner. Soft limits still work.
***************
*** 54,59 ****
--- 59,75 ----
// indicates to Grbl what is a backlash compensation motion, so that Grbl executes the move but
// doesn't update the machine position values. Since the position values used by the g-code
// parser and planner are separate from the system machine positions, this is doable.
+ #ifdef BACKLASH_COMP
+ //Determines if the motion we are about to execute has an axis moving in the opposite direction
+ //If it does, the value in settings for that axis is used to determine how far it needs to move
+ //to take up the mechanical slack in the motion for that axis.
+ //This could be a re-entrant call from backlash comp, so if it is, we dont want to 'comp the comp move'
+ if (!(pl_data->condition &(1<<PL_COND_FLAG_BACKLASH_COMP)))
+ {
+ backlash_comp(target,pl_data);
+ }
+
+ #endif
// If the buffer is full: good! That means we are well ahead of the robot.
// Remain in this loop until there is room in the buffer.
diff -c grbl/planner.c bklc/planner.c
*** grbl/planner.c 2021-01-23 09:13:48.000000000 +0900
--- bklc/planner.c 2022-05-19 00:02:58.000000000 +0900
***************
*** 39,44 ****
--- 39,51 ----
} planner_t;
static planner_t pl;
+ #ifdef BACKLASH_COMP
+ int32_t *plan_get_position()
+ {
+ return pl.position;
+ }
+ #endif
+
// Returns the index of the next block in the ring buffer. Also called by stepper segment buffer.
uint8_t plan_next_block_index(uint8_t block_index)
***************
*** 330,335 ****
--- 337,348 ----
float unit_vec[N_AXIS], delta_mm;
uint8_t idx;
+ #ifdef BACKLASH_COMP
+ if ((pl_data->condition &(1<<PL_COND_FLAG_BACKLASH_COMP)))
+ block->back_lash_comp = 1;
+
+ memset(position_steps,0,sizeof(position_steps));
+ #endif
// Copy position data based on type of motion being planned.
if (block->condition & PL_COND_FLAG_SYSTEM_MOTION) {
#ifdef COREXY
***************
*** 339,345 ****
#else
memcpy(position_steps, sys_position, sizeof(sys_position));
#endif
! } else { memcpy(position_steps, pl.position, sizeof(pl.position)); }
#ifdef COREXY
target_steps[A_MOTOR] = lround(target[A_MOTOR]*settings.steps_per_mm[A_MOTOR]);
--- 352,366 ----
#else
memcpy(position_steps, sys_position, sizeof(sys_position));
#endif
! } else {
! #ifdef BACKLASH_COMP
! //If compensated motion, assume we are starting from zero.
! if (!block->back_lash_comp)
! memcpy(position_steps, pl.position, sizeof(pl.position));
! #else
! memcpy(position_steps, pl.position, sizeof(pl.position));
! #endif
! }
#ifdef COREXY
target_steps[A_MOTOR] = lround(target[A_MOTOR]*settings.steps_per_mm[A_MOTOR]);
***************
*** 372,380 ****
delta_mm = (target_steps[idx] - position_steps[idx])/settings.steps_per_mm[idx];
#endif
unit_vec[idx] = delta_mm; // Store unit vector numerator
!
// Set direction bits. Bit enabled always means direction is negative.
! if (delta_mm < 0.0 ) { block->direction_bits |= get_direction_pin_mask(idx); }
}
// Bail if this is a zero-length block. Highly unlikely to occur.
--- 393,409 ----
delta_mm = (target_steps[idx] - position_steps[idx])/settings.steps_per_mm[idx];
#endif
unit_vec[idx] = delta_mm; // Store unit vector numerator
! #ifdef BACKLASH_COMP
! if (delta_mm!=0)
! back_lash_compensation.last_comp_direction[idx] = 1;
! #endif
// Set direction bits. Bit enabled always means direction is negative.
! if (delta_mm < 0.0 ) {
! block->direction_bits |= get_direction_pin_mask(idx);
! #ifdef BACKLASH_COMP
! back_lash_compensation.last_comp_direction[idx] = -1;
! #endif
! }
}
// Bail if this is a zero-length block. Highly unlikely to occur.
***************
*** 459,465 ****
// Update previous path unit_vector and planner position.
memcpy(pl.previous_unit_vec, unit_vec, sizeof(unit_vec)); // pl.previous_unit_vec[] = unit_vec[]
! memcpy(pl.position, target_steps, sizeof(target_steps)); // pl.position[] = target_steps[]
// New block is all set. Update buffer head and next buffer head indices.
block_buffer_head = next_buffer_head;
--- 488,502 ----
// Update previous path unit_vector and planner position.
memcpy(pl.previous_unit_vec, unit_vec, sizeof(unit_vec)); // pl.previous_unit_vec[] = unit_vec[]
!
! #ifdef BACKLASH_COMP
! //Dont update the planner position for blc. This move should be unknown to the planner.
! //This should still allow the planner to string the motions together though.
! if (!(block->back_lash_comp))
! memcpy(pl.position, target_steps, sizeof(target_steps)); // pl.position[] = target_steps[]
! #else
! memcpy(pl.position, target_steps, sizeof(target_steps)); // pl.position[] = target_steps[]
! #endif
// New block is all set. Update buffer head and next buffer head indices.
block_buffer_head = next_buffer_head;
diff -c grbl/planner.h bklc/planner.h
*** grbl/planner.h 2021-01-23 09:13:48.000000000 +0900
--- bklc/planner.h 2022-05-18 20:54:11.000000000 +0900
***************
*** 45,50 ****
--- 45,53 ----
#define PL_COND_FLAG_SPINDLE_CCW bit(5)
#define PL_COND_FLAG_COOLANT_FLOOD bit(6)
#define PL_COND_FLAG_COOLANT_MIST bit(7)
+ #ifdef BACKLASH_COMP
+ #define PL_COND_FLAG_BACKLASH_COMP 8
+ #endif
#define PL_COND_MOTION_MASK (PL_COND_FLAG_RAPID_MOTION|PL_COND_FLAG_SYSTEM_MOTION|PL_COND_FLAG_NO_FEED_OVERRIDE)
#define PL_COND_SPINDLE_MASK (PL_COND_FLAG_SPINDLE_CW|PL_COND_FLAG_SPINDLE_CCW)
#define PL_COND_ACCESSORY_MASK (PL_COND_FLAG_SPINDLE_CW|PL_COND_FLAG_SPINDLE_CCW|PL_COND_FLAG_COOLANT_FLOOD|PL_COND_FLAG_COOLANT_MIST)
***************
*** 83,88 ****
--- 86,94 ----
// Stored spindle speed data used by spindle overrides and resuming methods.
float spindle_speed; // Block spindle speed. Copied from pl_line_data.
#endif
+ #ifdef BACKLASH_COMP
+ uint8_t back_lash_comp;
+ #endif
} plan_block_t;
***************
*** 90,101 ****
typedef struct {
float feed_rate; // Desired feed rate for line motion. Value is ignored, if rapid motion.
float spindle_speed; // Desired spindle speed through line motion.
- uint8_t condition; // Bitflag variable to indicate planner conditions. See defines above.
#ifdef USE_LINE_NUMBERS
int32_t line_number; // Desired line number to report when executing.
#endif
} plan_line_data_t;
// Initialize and reset the motion plan subsystem
void plan_reset(); // Reset all
--- 96,114 ----
typedef struct {
float feed_rate; // Desired feed rate for line motion. Value is ignored, if rapid motion.
float spindle_speed; // Desired spindle speed through line motion.
#ifdef USE_LINE_NUMBERS
int32_t line_number; // Desired line number to report when executing.
#endif
+ #ifdef BACKLASH_COMP
+ uint16_t condition; // Bitflag variable to indicate planner conditions. See defines above.
+ #else
+ uint8_t condition; // Bitflag variable to indicate planner conditions. See defines above.
+ #endif
} plan_line_data_t;
+ #ifdef BACKLASH_COMP
+ int32_t * plan_get_position();
+ #endif
// Initialize and reset the motion plan subsystem
void plan_reset(); // Reset all
diff -c grbl/report.c bklc/report.c
*** grbl/report.c 2021-01-23 09:13:48.000000000 +0900
--- bklc/report.c 2022-05-18 22:41:04.000000000 +0900
***************
*** 169,175 ****
--- 169,179 ----
// Welcome message
void report_init_message()
{
+ #ifdef BACKLASH_COMP
+ printPgmString(PSTR("\r\nGrbl " GRBL_VERSION "(backlash comp) ['$' for help]\r\n"));
+ #else
printPgmString(PSTR("\r\nGrbl " GRBL_VERSION " ['$' for help]\r\n"));
+ #endif
}
// Grbl help message
***************
*** 218,223 ****
--- 222,230 ----
case 1: report_util_float_setting(val+idx,settings.max_rate[idx],N_DECIMAL_SETTINGVALUE); break;
case 2: report_util_float_setting(val+idx,settings.acceleration[idx]/(60*60),N_DECIMAL_SETTINGVALUE); break;
case 3: report_util_float_setting(val+idx,-settings.max_travel[idx],N_DECIMAL_SETTINGVALUE); break;
+ #if defined(BACKLASH_COMP)
+ case 4: report_util_float_setting(val+idx,settings.backlash_per_axis[idx],N_DECIMAL_SETTINGVALUE); break;
+ #endif
}
}
val += AXIS_SETTINGS_INCREMENT;
diff -c grbl/settings.c bklc/settings.c
*** grbl/settings.c 2021-01-23 09:13:48.000000000 +0900
--- bklc/settings.c 2022-05-18 22:39:07.000000000 +0900
***************
*** 57,64 ****
.acceleration[Z_AXIS] = DEFAULT_Z_ACCELERATION,
.max_travel[X_AXIS] = (-DEFAULT_X_MAX_TRAVEL),
.max_travel[Y_AXIS] = (-DEFAULT_Y_MAX_TRAVEL),
! .max_travel[Z_AXIS] = (-DEFAULT_Z_MAX_TRAVEL)};
!
// Method to store startup lines into EEPROM
void settings_store_startup_line(uint8_t n, char *line)
--- 57,69 ----
.acceleration[Z_AXIS] = DEFAULT_Z_ACCELERATION,
.max_travel[X_AXIS] = (-DEFAULT_X_MAX_TRAVEL),
.max_travel[Y_AXIS] = (-DEFAULT_Y_MAX_TRAVEL),
! .max_travel[Z_AXIS] = (-DEFAULT_Z_MAX_TRAVEL),
! #if defined(BACKLASH_COMP)
! .backlash_per_axis[X_AXIS]=DEFAULT_X_BACKLASH_MM,
! .backlash_per_axis[Y_AXIS]=DEFAULT_Y_BACKLASH_MM,
! .backlash_per_axis[Z_AXIS]=DEFAULT_Z_BACKLASH_MM,
! #endif
! };
// Method to store startup lines into EEPROM
void settings_store_startup_line(uint8_t n, char *line)
***************
*** 215,221 ****
break;
case 2: settings.acceleration[parameter] = value*60*60; break; // Convert to mm/min^2 for grbl internal use.
case 3: settings.max_travel[parameter] = -value; break; // Store as negative for grbl internal use.
! }
break; // Exit while-loop after setting has been configured and proceed to the EEPROM write call.
} else {
set_idx++;
--- 220,229 ----
break;
case 2: settings.acceleration[parameter] = value*60*60; break; // Convert to mm/min^2 for grbl internal use.
case 3: settings.max_travel[parameter] = -value; break; // Store as negative for grbl internal use.
! #if defined(BACKLASH_COMP)
! case 4: settings.backlash_per_axis[parameter] = value; break;
! #endif
! }
break; // Exit while-loop after setting has been configured and proceed to the EEPROM write call.
} else {
set_idx++;
diff -c grbl/settings.h bklc/settings.h
*** grbl/settings.h 2021-01-23 09:13:48.000000000 +0900
--- bklc/settings.h 2022-05-18 22:39:49.000000000 +0900
***************
*** 79,85 ****
--- 79,89 ----
// #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported)
// Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS.
+ #if defined(BACKLASH_COMP)
+ #define AXIS_N_SETTINGS 5
+ #else
#define AXIS_N_SETTINGS 4
+ #endif
#define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255.
#define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings
***************
*** 87,92 ****
--- 91,99 ----
typedef struct {
// Axis settings
float steps_per_mm[N_AXIS];
+ #if defined(BACKLASH_COMP)
+ float backlash_per_axis[N_AXIS];
+ #endif
float max_rate[N_AXIS];
float acceleration[N_AXIS];
float max_travel[N_AXIS];
diff -c grbl/stepper.c bklc/stepper.c
*** grbl/stepper.c 2021-01-23 09:13:48.000000000 +0900
--- bklc/stepper.c 2022-05-17 09:32:22.000000000 +0900
***************
*** 73,78 ****
--- 73,81 ----
#ifdef VARIABLE_SPINDLE
uint8_t is_pwm_rate_adjusted; // Tracks motions that require constant laser power/rate
#endif
+ #ifdef BACKLASH_COMP
+ uint8_t back_lash_comp;
+ #endif
} st_block_t;
static st_block_t st_block_buffer[SEGMENT_BUFFER_SIZE-1];
***************
*** 423,430 ****
st.step_outbits_dual = (1<<DUAL_STEP_BIT);
#endif
st.counter_x -= st.exec_block->step_event_count;
! if (st.exec_block->direction_bits & (1<<X_DIRECTION_BIT)) { sys_position[X_AXIS]--; }
! else { sys_position[X_AXIS]++; }
}
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_y += st.steps[Y_AXIS];
--- 426,441 ----
st.step_outbits_dual = (1<<DUAL_STEP_BIT);
#endif
st.counter_x -= st.exec_block->step_event_count;
! #ifdef BACKLASH_COMP
! //Dont update system position data until all backlash steps are taken up.
! if (!st.exec_block->back_lash_comp)
! {
! #endif
! if (st.exec_block->direction_bits & (1<<X_DIRECTION_BIT)) { sys_position[X_AXIS]--; }
! else { sys_position[X_AXIS]++; }
! #ifdef BACKLASH_COMP
! }
! #endif
}
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_y += st.steps[Y_AXIS];
***************
*** 437,444 ****
st.step_outbits_dual = (1<<DUAL_STEP_BIT);
#endif
st.counter_y -= st.exec_block->step_event_count;
! if (st.exec_block->direction_bits & (1<<Y_DIRECTION_BIT)) { sys_position[Y_AXIS]--; }
! else { sys_position[Y_AXIS]++; }
}
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_z += st.steps[Z_AXIS];
--- 448,463 ----
st.step_outbits_dual = (1<<DUAL_STEP_BIT);
#endif
st.counter_y -= st.exec_block->step_event_count;
! #ifdef BACKLASH_COMP
! //Dont update system position data until all backlash steps are taken up.
! if (!st.exec_block->back_lash_comp)
! {
! #endif
! if (st.exec_block->direction_bits & (1<<Y_DIRECTION_BIT)) { sys_position[Y_AXIS]--; }
! else { sys_position[Y_AXIS]++; }
! #ifdef BACKLASH_COMP
! }
! #endif
}
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_z += st.steps[Z_AXIS];
***************
*** 448,455 ****
if (st.counter_z > st.exec_block->step_event_count) {
st.step_outbits |= (1<<Z_STEP_BIT);
st.counter_z -= st.exec_block->step_event_count;
! if (st.exec_block->direction_bits & (1<<Z_DIRECTION_BIT)) { sys_position[Z_AXIS]--; }
! else { sys_position[Z_AXIS]++; }
}
// During a homing cycle, lock out and prevent desired axes from moving.
--- 467,482 ----
if (st.counter_z > st.exec_block->step_event_count) {
st.step_outbits |= (1<<Z_STEP_BIT);
st.counter_z -= st.exec_block->step_event_count;
! #ifdef BACKLASH_COMP
! //Dont update system position data until all backlash steps are taken up.
! if (!st.exec_block->back_lash_comp)
! {
! #endif
! if (st.exec_block->direction_bits & (1<<Z_DIRECTION_BIT)) { sys_position[Z_AXIS]--; }
! else { sys_position[Z_AXIS]++; }
! #ifdef BACKLASH_COMP
! }
! #endif
}
// During a homing cycle, lock out and prevent desired axes from moving.
***************
*** 711,723 ****
#endif
uint8_t idx;
#ifndef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
! for (idx=0; idx<N_AXIS; idx++) { st_prep_block->steps[idx] = (pl_block->steps[idx] << 1); }
st_prep_block->step_event_count = (pl_block->step_event_count << 1);
#else
// With AMASS enabled, simply bit-shift multiply all Bresenham data by the max AMASS
// level, such that we never divide beyond the original data anywhere in the algorithm.
// If the original data is divided, we can lose a step from integer roundoff.
! for (idx=0; idx<N_AXIS; idx++) { st_prep_block->steps[idx] = pl_block->steps[idx] << MAX_AMASS_LEVEL; }
st_prep_block->step_event_count = pl_block->step_event_count << MAX_AMASS_LEVEL;
#endif
--- 738,762 ----
#endif
uint8_t idx;
#ifndef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
! for (idx=0; idx<N_AXIS; idx++)
! {
! st_prep_block->steps[idx] = (pl_block->steps[idx] << 1);
! #ifdef BACKLASH_COMP
! st_prep_block->back_lash_comp = pl_block->back_lash_comp;
! #endif
! }
st_prep_block->step_event_count = (pl_block->step_event_count << 1);
#else
// With AMASS enabled, simply bit-shift multiply all Bresenham data by the max AMASS
// level, such that we never divide beyond the original data anywhere in the algorithm.
// If the original data is divided, we can lose a step from integer roundoff.
! for (idx=0; idx<N_AXIS; idx++)
! {
! st_prep_block->steps[idx] = pl_block->steps[idx] << MAX_AMASS_LEVEL;
! #ifdef BACKLASH_COMP
! st_prep_block->back_lash_comp = pl_block->back_lash_comp;
! #endif
! }
st_prep_block->step_event_count = pl_block->step_event_count << MAX_AMASS_LEVEL;
#endif