Skip to content

Commit 866cdac

Browse files
committed
Implemented feed parameter for G161/162 homing operations.
1 parent fea1644 commit 866cdac

File tree

3 files changed

+51
-28
lines changed

3 files changed

+51
-28
lines changed

gcode_process.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -329,23 +329,23 @@ void process_gcode_command() {
329329
//?
330330
//? Find the minimum limit of the specified axes by searching for the limit switch.
331331
if (next_target.seen_X)
332-
home_x_negative();
332+
home_x_negative( next_target.target.F);
333333
if (next_target.seen_Y)
334-
home_y_negative();
334+
home_y_negative( next_target.target.F);
335335
if (next_target.seen_Z)
336-
home_z_negative();
336+
home_z_negative( next_target.target.F);
337337
break;
338338
// G162 - Home positive
339339
case 162:
340340
//? ==== G162: Home positive ====
341341
//?
342342
//? Find the maximum limit of the specified axes by searching for the limit switch.
343343
if (next_target.seen_X)
344-
home_x_positive();
344+
home_x_positive( next_target.target.F);
345345
if (next_target.seen_Y)
346-
home_y_positive();
346+
home_y_positive( next_target.target.F);
347347
if (next_target.seen_Z)
348-
home_z_positive();
348+
home_z_positive( next_target.target.F);
349349
break;
350350

351351
// unknown gcode: spit an error

home.c

+38-15
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,51 @@ static void axis_direction( uint8_t axis, uint8_t from_limit)
255255

256256
// Execute the actual homing operation. The hardware selected with the 'axis'
257257
// variable must exist or we'll fail miserably, so filter before calling here!
258-
static void run_home_one_axis( uint8_t axis)
258+
static void run_home_one_axis( uint8_t axis, uint32_t feed)
259259
{
260260
uint32_t fast_step_period = 75; // init to keep compiler happy
261261
uint32_t slow_step_period = 250; // init to keep compiler happy
262262
uint32_t max_pulses_on_axis = 0; // init to keep compiler happy
263263
uint32_t max_pulses_for_release = 0; // init to keep compiler happy
264264
uint8_t limit_switch_state = 0; // init to keep compiler happy
265265

266+
// TODO: handle undefined _MIN and _MAX values!
267+
266268
if (axis == home_x_min || axis == home_x_max) {
269+
#if 1
270+
if (feed > MAXIMUM_FEEDRATE_X) {
271+
feed = MAXIMUM_FEEDRATE_X;
272+
}
273+
fast_step_period = (uint32_t) 1 + (60000000L / STEPS_PER_MM_X) / feed;
274+
#else
267275
fast_step_period = (uint32_t) HOME_FAST_STEP_PERIOD_X;
276+
#endif
268277
slow_step_period = (uint32_t) HOME_SLOW_STEP_PERIOD_X;
269278
limit_switch_state = (axis & home_x_max) ? x_max() : x_min();
270279
max_pulses_on_axis = (uint32_t)((X_MAX - X_MIN) * STEPS_PER_MM_X);
271280
max_pulses_for_release = (uint32_t)(RELEASE_DISTANCE * STEPS_PER_MM_X);
272281
} else if (axis == home_y_min || axis == home_y_max) {
282+
#if 1
283+
if (feed > MAXIMUM_FEEDRATE_Y) {
284+
feed = MAXIMUM_FEEDRATE_Y;
285+
}
286+
fast_step_period = (uint32_t) 1 + (60000000L / STEPS_PER_MM_Y) / feed;
287+
#else
273288
fast_step_period = (uint32_t) HOME_FAST_STEP_PERIOD_Y;
289+
#endif
274290
slow_step_period = (uint32_t) HOME_SLOW_STEP_PERIOD_Y;
275291
limit_switch_state = (axis & home_y_max) ? y_max() : y_min();
276292
max_pulses_on_axis = (uint32_t)((Y_MAX - Y_MIN) * STEPS_PER_MM_Y);
277293
max_pulses_for_release = (uint32_t)(RELEASE_DISTANCE * STEPS_PER_MM_Y);
278294
} else if (axis == home_z_min || axis == home_z_max) {
295+
#if 1
296+
if (feed > MAXIMUM_FEEDRATE_Z) {
297+
feed = MAXIMUM_FEEDRATE_Z;
298+
}
299+
fast_step_period = (uint32_t) 1 + (60000000L / STEPS_PER_MM_Z) / feed;
300+
#else
279301
fast_step_period = (uint32_t) HOME_FAST_STEP_PERIOD_Z;
302+
#endif
280303
slow_step_period = (uint32_t) HOME_SLOW_STEP_PERIOD_Z;
281304
limit_switch_state = (axis & home_z_max) ? z_max() : z_min();
282305
max_pulses_on_axis = (uint32_t)((Z_MAX - Z_MIN) * STEPS_PER_MM_Z);
@@ -313,21 +336,21 @@ static void run_home_one_axis( uint8_t axis)
313336

314337
/// home the selected axis to the selected limit switch.
315338
// keep all preprocessor configuration stuff at or below this level.
316-
static void home_one_axis( uint8_t axis) {
339+
static void home_one_axis( uint8_t axis, uint32_t feed) {
317340

318341
// get ready for the action
319342
power_on();
320343
queue_wait();
321344

322345
// move to a limit switch or sensor
323-
run_home_one_axis( axis);
346+
run_home_one_axis( axis, feed);
324347

325348
}
326349

327350
/// find X MIN endstop
328-
void home_x_negative() {
351+
void home_x_negative( uint32_t feed) {
329352
#if defined X_MIN_PIN
330-
home_one_axis( home_x_min);
353+
home_one_axis( home_x_min, feed);
331354
#endif
332355
// reference 'home' position to current position
333356
#ifdef X_MIN
@@ -340,9 +363,9 @@ void home_x_negative() {
340363
}
341364

342365
/// find X_MAX endstop
343-
void home_x_positive() {
366+
void home_x_positive( uint32_t feed) {
344367
#if defined X_MAX_PIN
345-
home_one_axis( home_x_max);
368+
home_one_axis( home_x_max, feed);
346369
#endif
347370
// reference 'home' position to current position
348371
#ifdef X_MAX
@@ -355,9 +378,9 @@ void home_x_positive() {
355378
}
356379

357380
/// find Y MIN endstop
358-
void home_y_negative() {
381+
void home_y_negative( uint32_t feed) {
359382
#if defined Y_MIN_PIN
360-
home_one_axis( home_y_min);
383+
home_one_axis( home_y_min, feed);
361384
#endif
362385
// reference 'home' position to current position
363386
#ifdef Y_MIN
@@ -370,9 +393,9 @@ void home_y_negative() {
370393
}
371394

372395
/// find Y MAX endstop
373-
void home_y_positive() {
396+
void home_y_positive( uint32_t feed) {
374397
#if defined Y_MAX_PIN
375-
home_one_axis( home_y_max);
398+
home_one_axis( home_y_max, feed);
376399
#endif
377400
// reference 'home' position to current position
378401
#ifdef Y_MAX
@@ -385,9 +408,9 @@ void home_y_positive() {
385408
}
386409

387410
/// find Z MIN endstop
388-
void home_z_negative() {
411+
void home_z_negative( uint32_t feed) {
389412
#if defined Z_MIN_PIN
390-
home_one_axis( home_z_min);
413+
home_one_axis( home_z_min, feed);
391414
#endif
392415
// reference 'home' position to current position
393416
#ifdef Z_MIN
@@ -400,9 +423,9 @@ void home_z_negative() {
400423
}
401424

402425
/// find Z MAX endstop
403-
void home_z_positive() {
426+
void home_z_positive( uint32_t feed) {
404427
#if defined Z_MAX_PIN
405-
home_one_axis( home_z_max);
428+
home_one_axis( home_z_max, feed);
406429
#endif
407430
// reference 'home' position to current position
408431
#ifdef Z_MAX

home.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#ifndef _HOME_H
22
#define _HOME_H
33

4-
void home(void);
4+
#include <stdint.h>
55

6-
void home_x_negative(void);
7-
void home_x_positive(void);
8-
void home_y_negative(void);
9-
void home_y_positive(void);
10-
void home_z_negative(void);
11-
void home_z_positive(void);
6+
void home_x_negative( uint32_t feed);
7+
void home_x_positive( uint32_t feed);
8+
void home_y_negative( uint32_t feed);
9+
void home_y_positive( uint32_t feed);
10+
void home_z_negative( uint32_t feed);
11+
void home_z_positive( uint32_t feed);
1212

1313
#endif /* _HOME_H */

0 commit comments

Comments
 (0)