Welcome! Log In Create A New Profile

Advanced

hacking marlin to enable individual software endstops

Posted by friarfish 
hacking marlin to enable individual software endstops
October 08, 2015 07:33AM
Hi folks,
I was taking a break from cabling the printer and was reading through the
Marlin code. The thought occurred to me having control over the individual
software endstops on each axis would be useful.

I played around in Marlin_main.cpp and came up with the following.
Am I heading down the right path folks?

Many thanks,
Andrew

void clamp_to_software_endstops(float target[3])
{
// new definition for software endstops
// min_software_endstops
// #define min_x_software_endstop true
// #define min_y_software_endstop true
// #define min_z_software_endstop true
//
// max_software_endstop
// #define max_x_software_endstop true
// #define max_y_software_endstop true
// #define max_z_software_endstop true
//
// Insert #defines into configuration.h

// Old code
// if (min_software_endstops) {
// if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];
// if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];

// basically all my stuff below.
// Not exactly rocket science

if (min_x_software_endstop){
if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];}
if (min_y_software_endstop){
if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];}

// this bit is the original stuff
//
float negative_z_offset = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER;
if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS];
#endif

if (min_z_software_endstop) {
if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset;
}


// Now define functions to handle max_x_software_endstop
//
if (max_x_software_endstop) {
if (target[X_AXIS] > max_pos[X_AXIS]) target[X_AXIS] = max_pos[X_AXIS];}
if (max_x_software_endstop) {
if (target[Y_AXIS] > max_pos[Y_AXIS]) target[Y_AXIS] = max_pos[Y_AXIS];}
if (max_x_software_endstop) {
if (target[Z_AXIS] > max_pos[Z_AXIS]) target[Z_AXIS] = max_pos[Z_AXIS];}
}
Sorry, only registered users may post in this forum.

Click here to login