Skip to content

Commit

Permalink
add PENTA_AXIS_HT and PENTA_AXIS_TRT kinematics
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndere1 committed Oct 1, 2024
1 parent 8c61606 commit 49ddf6b
Show file tree
Hide file tree
Showing 47 changed files with 1,459 additions and 153 deletions.
85 changes: 84 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,14 @@
*/
//#define ELECTROMAGNETIC_SWITCHING_TOOLHEAD


// Safe toolchange start Z position.
//#define SAFE_TOOLCHANGE_START_Z 200

#if ANY(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
//#define SWITCHING_TOOLHEAD_Z_POS 100 // (mm) Z position of the toolhead dock.
// Leave this option disabled if the bed can move in Z direction
//#define SWITCHING_TOOLHEAD_Z_CLEAR 60 // (mm) Minimum distance from dock along Z for unobstructed X axis if the tools are placed onto the dock in Z direction
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
Expand Down Expand Up @@ -371,7 +378,7 @@

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
// For the other hotends it is their distance from the extruder 0 hotend in positive axis direction.
//#define HOTEND_OFFSET_X { 0.0, 20.00 } // (mm) relative X-offset for each nozzle
//#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle
//#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle
Expand Down Expand Up @@ -1117,6 +1124,75 @@
#define FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
#endif

// @section PENTA_AXIS_TRT

/**
* For a 5 axis CNC machine in tilting rotary table configuration.
* This machine has a rotary table (C axis) mounted on a tilting table
* (A axis parallel to the X axis, or B axis parallel to the Y axis).
* More information can be found at https://github.com/DerAndere1/Marlin/wiki/Marlin2ForPipetBot:-five-axis-CNC
*/
//#define PENTA_AXIS_TRT
#if ENABLED(PENTA_AXIS_TRT)

// Machine rotary zero point offsets
// The distance along the X axis from machine zero point to the center of rotation. The center of rotation is
// usually the center of the top surface of the table when all axes are at machine position 0.
#define DEFAULT_MRZP_OFFSET_X 0.0 // (mm)

// The distance along the Y axis from machine zero point to the center of rotation. The center of rotation is
// usually the center of the top surface of the table when all axes are at machine position 0.
#define DEFAULT_MRZP_OFFSET_Y 0.0 // (mm)

// The distance along the Z axis from machine zero point to the center of rotation. The center of rotation is
// usually the center of the top surface of the table when all axes are at machine position 0.
#define DEFAULT_MRZP_OFFSET_Z 0.0 // (mm)

// For a machine with XYZBC axes, this is the distance along the x axis from the vertical centerline of the
// joint of the horizontal rotary table to the horizontal centerline of the joint that tilts the table.
// Measured when the table is oriented horizontally.
#define DEFAULT_ROTATIONAL_JOINT_OFFSET_X 0.0 // (mm)

// For a machine with XYZAC axes, this is the distance along the y axis from the vertical centerline of the
// joint of the horizontal table to the horizontal centerline of the joint that tilts the table.
// Measured when the table is oriented horizontally.
#define DEFAULT_ROTATIONAL_JOINT_OFFSET_Y 0.0 // (mm)

// This is the distance along the Z axis from the surface at the top of the table to the horizontal
// centerline of the joint that tilts the table when the table is oriented horizontally.
#define DEFAULT_ROTATIONAL_JOINT_OFFSET_Z 0.0 // (mm)

// Moves involving rotational axes is broken up into small straight segments (linear interpolation).
// This is a trade-off between visible corners (not enough segments)
// and processor overload (too many expensive sqrt calls).
#define DEFAULT_SEGMENTS_PER_SECOND 200

// Print surface diameter/2
#define PRINTABLE_RADIUS 100.0 // (mm)
#endif

// @section PENTA_AXIS_HT

/**
* For a 5 axis CNC machine in head-table configuration.
* This machine has a swivel head and a horizontal rotary table.
*/
//#define PENTA_AXIS_HT
#if ENABLED(PENTA_AXIS_HT)

// Machine rotary zero point offset is the distance from the gage line at the tool head (tip of the nozzle of tool 0) to the horizontal
// centerline of the joint that tilts the tool head. Measured when all axes are at machine position 0.
#define DEFAULT_MRZP_OFFSET_Z 100.0 // (mm)

// Moves involving rotational axes is broken up into small straight segments (linear interpolation).
// This is a trade-off between visible corners (not enough segments)
// and processor overload (too many expensive sqrt calls).
#define DEFAULT_SEGMENTS_PER_SECOND 200

// Print surface diameter/2
#define PRINTABLE_RADIUS 100.0 // (mm)
#endif

// @section machine

// Articulated robot (arm). Joints are directly mapped to axes with no kinematics.
Expand Down Expand Up @@ -1902,6 +1978,13 @@
#endif

#if ANY(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
/**
* Abort printing when any software endstop is triggered.
* This feature is enabled with 'M541 S1' or from the LCD menu.
* Software endstops must be activated for this option to work.
*/
//#define ABORT_ON_SOFTWARE_ENDSTOP

//#define SOFT_ENDSTOPS_MENU_ITEM // Enable/Disable software endstops from the LCD
#endif

Expand Down
7 changes: 5 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@
//#define XY_COUNTERPART_BACKOFF_MM 0 // (mm) Backoff X after homing Y, and vice-versa

//#define QUICK_HOME // If G28 contains XY do a diagonal move first
#if ENABLED(QUICK_HOME)
//#define QUICK_HOME_SECONDARY_AXES // If G28 contains XYABCUVW, first do a coordinated move of axes XYABCUVW towards the limit used for homing.
#endif
//#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X
//#define HOME_Z_FIRST // Home Z first. Requires a real endstop (not a probe).
//#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first
Expand Down Expand Up @@ -2784,7 +2787,7 @@
* Universal tool change settings.
* Applies to all types of extruders except where explicitly noted.
*/
#if HAS_MULTI_EXTRUDER
#if HAS_MULTI_TOOLS
// Z raise distance for tool-change, as needed for some extruders
#define TOOLCHANGE_ZRAISE 2 // (mm)
//#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
Expand Down Expand Up @@ -2891,7 +2894,7 @@
//#define TOOLCHANGE_MIGRATION_DO_PARK // Force park (or no-park) on migration
#endif
#endif
#endif // HAS_MULTI_EXTRUDER
#endif // HAS_MULTI_TOOLS

// @section advanced pause

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
#include "module/scara.h"
#elif ENABLED(POLAR)
#include "module/polar.h"
#elif ENABLED(PENTA_AXIS_TRT)
#include "module/penta_axis_trt.h"
#elif ENABLED(PENTA_AXIS_HT)
#include "module/penta_axis_ht.h"
#endif

#if HAS_LEVELING
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
#define STR_SD_CANT_ENTER_SUBDIR "Cannot enter subdir: "

#define STR_ENDSTOPS_HIT "endstops hit: "
#define STR_ERR_SW_ENDSTOP "software endstops hit"
#define STR_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
#define STR_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
#define STR_ERR_HOTEND_TOO_COLD "Hotend too cold"
Expand Down Expand Up @@ -283,6 +284,8 @@
#define STR_SCARA_SETTINGS "SCARA"
#define STR_POLAR_SETTINGS "Polar"
#define STR_POLARGRAPH_SETTINGS "Polargraph"
#define STR_PAX_TRT_SETTINGS "Penta-Axis-TRT"
#define STR_PAX_HT_SETTINGS "Penta-Axis-Head-Table"
#define STR_SCARA_P_T_Z "P<theta-psi-offset> T<theta-offset> Z<home-offset>"
#define STR_ENDSTOP_ADJUSTMENT "Endstop adjustment"
#define STR_SKEW_FACTOR "Skew Factor"
Expand Down
10 changes: 10 additions & 0 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ enum AxisEnum : uint8_t {
#define LOOP_DISTINCT_AXES(VAR) for (uint8_t VAR = 0; VAR < DISTINCT_AXES; ++VAR)
#define LOOP_DISTINCT_E(VAR) for (uint8_t VAR = 0; VAR < DISTINCT_E; ++VAR)


//
// Enumerates tool types
//
enum ToolTypeEnum : uint8_t {
TYPE_EXTRUDER,
TYPE_LASER,
TYPE_SPINLDE
};

//
// feedRate_t is just a humble float
//
Expand Down
9 changes: 7 additions & 2 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,8 +1281,13 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
if (!isnan(z_values[i][j])) continue; // Skip valid mesh points

// Skip unreachable points
if (!probe.can_reach(get_mesh_x(i), get_mesh_y(j)))
continue;
#if ANY(PENTA_AXIS_HT, PENTA_AXIS_TRT)
if (!probe.can_reach(NUM_AXIS_LIST(get_mesh_x(i), get_mesh_y(j), TERN0(SAFE_BED_LEVELING_START_Z, SAFE_BED_LEVELING_START_Z), TERN0(SAFE_BED_LEVELING_START_I, SAFE_BED_LEVELING_START_I), TERN0(SAFE_BED_LEVELING_START_J, SAFE_BED_LEVELING_START_J), TERN0(SAFE_BED_LEVELING_START_K, SAFE_BED_LEVELING_START_K), TERN0(SAFE_BED_LEVELING_START_U, SAFE_BED_LEVELING_START_U), TERN0(SAFE_BED_LEVELING_START_V, SAFE_BED_LEVELING_START_V), TERN0(SAFE_BED_LEVELING_START_W, SAFE_BED_LEVELING_START_W))))
continue;
#else
if (!probe.can_reach(get_mesh_x(i), get_mesh_y(j)))
continue;
#endif

found_a_NAN = true;

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void PrintJobRecovery::resume() {
#endif

// Restore the previously active tool (with no_move)
#if HAS_MULTI_EXTRUDER || HAS_MULTI_HOTEND
#if HAS_MULTI_TOOLS || HAS_MULTI_HOTEND
PROCESS_SUBCOMMANDS_NOW(TS('T', info.active_extruder, 'S'));
#endif

Expand Down Expand Up @@ -638,7 +638,7 @@ void PrintJobRecovery::resume() {
DEBUG_EOL();
#endif

#if HAS_MULTI_EXTRUDER
#if HAS_MULTI_TOOLS
DEBUG_ECHOLNPGM("active_extruder: ", info.active_extruder);
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/powerloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ typedef struct {
#if HAS_WORKSPACE_OFFSET
xyz_pos_t workspace_offset;
#endif
#if HAS_MULTI_EXTRUDER
#if HAS_MULTI_TOOLS
uint8_t active_extruder;
#endif

Expand Down
52 changes: 46 additions & 6 deletions Marlin/src/feature/spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#endif

SpindleLaser cutter;
uint8_t SpindleLaser::active_tool_type; // Tool type: 0 for extruder, 1 for spindle, 2 for laser
bool SpindleLaser::enable_state; // Virtual enable state, controls enable pin if present and or apply power if > 0
uint8_t SpindleLaser::power, // Actual power output 0-255 ocr or "0 = off" > 0 = "on"
SpindleLaser::last_power_applied; // = 0 // Basic power state tracking
Expand All @@ -65,21 +66,36 @@ cutter_frequency_t SpindleLaser::frequency; // PWM fre
* Init the cutter to a safe OFF state
*/
void SpindleLaser::init() {
#if ENABLED(LASER_FEATURE) && LASER_TOOL == 0
active_tool_type = TYPE_LASER;
#elif ENABLED(SPINDLE_FEATURE) && LASER_TOOL == 0
active_tool_type = TYPE_LASER;
#else
active_tool_type = TYPE_EXTRUDER;
#endif
#if ENABLED(SPINDLE_SERVO)
servo[SPINDLE_SERVO_NR].move(SPINDLE_SERVO_MIN);
#elif PIN_EXISTS(SPINDLE_LASER_ENA)
OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off
#endif
#if PIN_EXISTS(LASER_ENA)
OUT_WRITE(LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off
#endif
#if ENABLED(SPINDLE_CHANGE_DIR)
OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR); // Init rotation to clockwise (M3)
#endif
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
frequency = SPINDLE_LASER_FREQUENCY;
hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY);
hal.set_pwm_frequency(pin_t(LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY);
#endif
#if ENABLED(SPINDLE_LASER_USE_PWM)
SET_PWM(SPINDLE_LASER_PWM_PIN);
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed
#if PIN_EXISTS(LASER_PWM)
SET_PWM(SPINDLE_LASER_PWM_PIN);
hal.set_pwm_duty(pin_t(LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed
#endif
#endif
#if ENABLED(AIR_EVACUATION)
OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower OFF
Expand All @@ -98,21 +114,37 @@ void SpindleLaser::init() {
*/
void SpindleLaser::_set_ocr(const uint8_t ocr) {
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency);
if (active_tool_type == TYPE_LASER)
hal.set_pwm_frequency(pin_t(LASER_PWM_PIN), frequency);
else
hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency);
#endif
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
if (active_tool_type == TYPE_LASER)
hal.set_pwm_duty(pin_t(LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
elif (active_tool_type == TYPE_SPINDLE)
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
}

void SpindleLaser::set_ocr(const uint8_t ocr) {
#if PIN_EXISTS(LASER_ENA)
if (tool_type == TYPE_LASER)
WRITE(LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON
#endif
#if PIN_EXISTS(SPINDLE_LASER_ENA)
WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON
if (tool_type == TYPE_SPINDLE)
WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON
#endif
_set_ocr(ocr);
}

void SpindleLaser::ocr_off() {
#if PIN_EXISTS(LASER_ENA)
if (active_tool_type == TYPE_LASER)
WRITE(LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF
#endif
#if PIN_EXISTS(SPINDLE_LASER_ENA)
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF
if (active_tool_type TYPE_SPINDLE)
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF
#endif
_set_ocr(0);
}
Expand Down Expand Up @@ -143,13 +175,21 @@ void SpindleLaser::apply_power(const uint8_t opwr) {
#elif ENABLED(SPINDLE_SERVO)
servo[SPINDLE_SERVO_NR].move(opwr);
#else
WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
if (active_tool_type == TYPE_LASER)
WRITE(LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
elif (active_tool_type == TYPE_SPINDLE)
WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
isReadyForUI = true;
#endif
}
else {
#if PIN_EXISTS(LASER_ENA)
if (active_tool_type == TYPE_LASER)
WRITE(LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE);
#endif
#if PIN_EXISTS(SPINDLE_LASER_ENA)
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE);
if (active_tool_type == TYPE_SPINDLE)
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE);
#endif
isReadyForUI = false; // Only used for UI display updates.
TERN_(SPINDLE_LASER_USE_PWM, ocr_off());
Expand Down
12 changes: 11 additions & 1 deletion Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ class SpindleLaser {
static void init();

#if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); }
static void refresh_frequency() {
if (active_tool_type == TYPE_LASER) {
hal.set_pwm_frequency(pin_t(LASER_PWM_PIN), frequency);
}
elif (active_tool_type == TYPE_SPINDLE) {
hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency);
}
}
#endif

// Modifying this function should update everywhere
Expand Down Expand Up @@ -211,6 +218,9 @@ class SpindleLaser {
enable = false;
apply_power(0);
}
#if PIN_EXISTS(LASER_ENA)
WRITE(LASER_ENA_PIN, enable ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
#endif
#if PIN_EXISTS(SPINDLE_LASER_ENA)
WRITE(SPINDLE_LASER_ENA_PIN, enable ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
#endif
Expand Down
Loading

0 comments on commit 49ddf6b

Please sign in to comment.