From 96b1b93d28f131c121ccab695fef8233bec3c048 Mon Sep 17 00:00:00 2001 From: Paciente8159 Date: Wed, 14 Feb 2024 10:47:02 +0000 Subject: [PATCH 1/2] Added option for rotational axis - added option for rotational axis work always in relative distances --- uCNC/cnc_config.h | 2 +- uCNC/cnc_hal_config.h | 11 +++++++++++ uCNC/src/core/parser.c | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/uCNC/cnc_config.h b/uCNC/cnc_config.h index 89cb9ef9a..79bb47f44 100644 --- a/uCNC/cnc_config.h +++ b/uCNC/cnc_config.h @@ -67,7 +67,7 @@ extern "C" * */ #ifndef AXIS_COUNT -#define AXIS_COUNT 3 +#define AXIS_COUNT 4 #endif #ifndef KINEMATIC diff --git a/uCNC/cnc_hal_config.h b/uCNC/cnc_hal_config.h index e67c9d3d3..0b8ac505d 100644 --- a/uCNC/cnc_hal_config.h +++ b/uCNC/cnc_hal_config.h @@ -107,6 +107,17 @@ extern "C" */ // #define ENABLE_XY_SIMULTANEOUS_HOMING +/** + * Rotational axis - force relative distances + * Enable this option if you want the rotation axis to work in relative distance mode only + * This will mean that no matter if the machine is working in absolute (G90) or relative (G91) coordinates + * the rotational axis will always calculate the motion in relative distance mode + * +*/ +// #define AXIS_A_FORCE_RELATIVE_MODE +// #define AXIS_B_FORCE_RELATIVE_MODE +// #define AXIS_C_FORCE_RELATIVE_MODE + /** * Uncomment this feature to enable multi motor axis * NOTE: If Laser PPI is enabled one of the stepper drivers position will be used by the laser controller diff --git a/uCNC/src/core/parser.c b/uCNC/src/core/parser.c index 8383bcecd..39ff4b877 100644 --- a/uCNC/src/core/parser.c +++ b/uCNC/src/core/parser.c @@ -1402,19 +1402,31 @@ uint8_t parser_exec_command(parser_state_t *new_state, parser_words_t *words, pa #ifdef AXIS_A if (CHECKFLAG(cmd->words, GCODE_WORD_A)) { +#ifndef AXIS_A_FORCE_RELATIVE_MODE target[AXIS_A] = (abspos) ? words->xyzabc[AXIS_A] : (words->xyzabc[AXIS_A] + target[AXIS_A]); +#else + target[AXIS_A] = (words->xyzabc[AXIS_A] + target[AXIS_A]); +#endif } #endif #ifdef AXIS_B if (CHECKFLAG(cmd->words, GCODE_WORD_B)) { +#ifndef AXIS_B_FORCE_RELATIVE_MODE target[AXIS_B] = (abspos) ? words->xyzabc[AXIS_B] : (words->xyzabc[AXIS_B] + target[AXIS_B]); +#else + target[AXIS_B] = (words->xyzabc[AXIS_B] + target[AXIS_B]); +#endif } #endif #ifdef AXIS_C if (CHECKFLAG(cmd->words, GCODE_WORD_C)) { +#ifndef AXIS_C_FORCE_RELATIVE_MODE target[AXIS_C] = (abspos) ? words->xyzabc[AXIS_C] : (words->xyzabc[AXIS_C] + target[AXIS_C]); +#else + target[AXIS_C] = (words->xyzabc[AXIS_C] + target[AXIS_C]); +#endif } #endif From c76b01e86f855aeb5cda8e92c40e7380e7e567fa Mon Sep 17 00:00:00 2001 From: Paciente8159 Date: Wed, 14 Feb 2024 10:48:26 +0000 Subject: [PATCH 2/2] Update cnc_config.h --- uCNC/cnc_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uCNC/cnc_config.h b/uCNC/cnc_config.h index 79bb47f44..89cb9ef9a 100644 --- a/uCNC/cnc_config.h +++ b/uCNC/cnc_config.h @@ -67,7 +67,7 @@ extern "C" * */ #ifndef AXIS_COUNT -#define AXIS_COUNT 4 +#define AXIS_COUNT 3 #endif #ifndef KINEMATIC