Fixed homing problem with root cause in new feedhold code. Deleted NORMALLY_OPEN and NORMALLY_CLOSED defines (Use IO_ACTIVE_LOW and IO_ACTIVE_HIGH - respectively - instead.)

This commit is contained in:
Alden Hart
2018-04-15 12:35:40 -04:00
parent 8e7e62cb9a
commit 2ec0edfcf5
8 changed files with 30 additions and 19 deletions

View File

@@ -1061,7 +1061,8 @@ stat_t cm_set_absolute_origin(const float origin[], bool flag[])
for (uint8_t axis = AXIS_X; axis < AXES; axis++) {
if (flag[axis]) {
value[axis] = _to_millimeters(origin[axis]);
// REMOVED value[axis] = cm->offset[cm->gm.coord_system][axis] + _to_millimeters(origin[axis]); // G2 Issue #26
value[axis] = _to_millimeters(origin[axis]); // replaced the above
cm->gmx.position[axis] = value[axis]; // set model position
cm->gm.target[axis] = value[axis]; // reset model target
mp_set_planner_position(axis, value[axis]); // set mm position

View File

@@ -127,7 +127,8 @@ typedef enum { // feedhold final operation
FEEDHOLD_EXIT_END, // perform program end
FEEDHOLD_EXIT_ALARM, // perform alarm
FEEDHOLD_EXIT_SHUTDOWN, // perform shutdown
FEEDHOLD_EXIT_INTERLOCK // report as interlock
FEEDHOLD_EXIT_INTERLOCK, // report as interlock
FEEDHOLD_EXIT_RESET_POSITION // reset machine positions to hold point
} cmFeedholdExit;
typedef enum { // feedhold state machine
@@ -318,7 +319,7 @@ typedef struct cmMachine { // struct to manage canonical machin
cmProbeState probe_state[PROBES_STORED]; // probing state machine (simple)
float probe_results[PROBES_STORED][AXES]; // probing results
float rotation_matrix[3][3]; // three-by-three rotation matrix. We ignore UVW and ABC rotary axes
float rotation_matrix[3][3]; // three-by-three rotation matrix. We ignore UVW and ABC axes
float rotation_z_offset; // separately handle a z-offset to maintain consistent distance to bed
float jogging_dest; // jogging destination as a relative move from current position

View File

@@ -58,6 +58,7 @@ static stat_t _run_program_end(void);
static stat_t _run_alarm(void);
static stat_t _run_shutdown(void);
static stat_t _run_interlock(void);
static stat_t _run_reset_position(void);
/****************************************************************************************
* OPERATIONS AND ACTIONS
@@ -314,6 +315,12 @@ static stat_t _run_program_end()
return (STAT_OK);
}
static stat_t _run_reset_position()
{
cm_reset_position_to_absolute_position(cm);
return (STAT_OK);
}
static stat_t _run_alarm() { return (STAT_OK); }
static stat_t _run_shutdown() { return (STAT_OK); }
static stat_t _run_interlock() { return (STAT_OK); }
@@ -530,6 +537,7 @@ void cm_request_feedhold(cmFeedholdType type, cmFeedholdExit exit)
case FEEDHOLD_EXIT_ALARM: { op.add_action(_run_alarm); break; }
case FEEDHOLD_EXIT_SHUTDOWN: { op.add_action(_run_shutdown); break; }
case FEEDHOLD_EXIT_INTERLOCK: { op.add_action(_run_interlock); break; }
case FEEDHOLD_EXIT_RESET_POSITION: { op.add_action(_run_reset_position); break; }
default: {}
}
return;
@@ -638,7 +646,6 @@ static stat_t _feedhold_skip()
{
if (cm1.hold_state == FEEDHOLD_OFF) { // if entered while OFF start a feedhold
cm1.hold_type = FEEDHOLD_TYPE_SKIP;
// cm1.hold_exit = FEEDHOLD_EXIT_FLUSH; // default exit for SKIP is FLUSH...
cm1.hold_state = FEEDHOLD_SYNC; // ...FLUSH can be overridden by setting hold_exit after this function
}
if (cm1.hold_state < FEEDHOLD_MOTION_STOPPED) {

View File

@@ -49,7 +49,6 @@ struct hmHomingSingleton { // persistent homing runtime variables
bool set_coordinates; // G28.4 flag. true = set coords to zero at the end of homing cycle
stat_t (*func)(int8_t axis); // binding for callback function state machine
// float axes[AXES]; // local storage for axis words and associated flags
bool axis_flags[AXES]; // local storage for axis flags
// per-axis parameters

View File

@@ -103,6 +103,7 @@ struct ioDigitalInputExt {
bool pin_value = (bool)input_pin;
int8_t pin_value_corrected = (pin_value ^ ((int)in->mode ^ 1)); // correct for NO or NC mode
in->state = (ioState)pin_value_corrected;
in->ext_pin_number = ext_pin_number; // diagnostic only. Not used by code
}
void pin_changed() {
@@ -131,7 +132,7 @@ struct ioDigitalInputExt {
// lockout the pin for lockout_ms
in->lockout_timer.set(in->lockout_ms);
// record the changed state
// record the changed state (we know it changed or we would have exited beforehand)
in->state = (ioState)pin_value_corrected;
if (pin_value_corrected == INPUT_ACTIVE) {
in->edge = INPUT_EDGE_LEADING;
@@ -143,7 +144,8 @@ struct ioDigitalInputExt {
if (in->homing_mode) {
if (in->edge == INPUT_EDGE_LEADING) { // we only want the leading edge to fire
en_take_encoder_snapshot();
cm_request_feedhold(FEEDHOLD_TYPE_SKIP, FEEDHOLD_EXIT_STOP);
// cm_request_feedhold(FEEDHOLD_TYPE_SKIP, FEEDHOLD_EXIT_STOP);
cm_request_feedhold(FEEDHOLD_TYPE_SKIP, FEEDHOLD_EXIT_RESET_POSITION);
}
return;
}

View File

@@ -49,8 +49,8 @@ typedef enum {
IO_MODE_DISABLED = 2 // input is disabled
} ioMode;
#define IO_MODE_MAX IO_MODE_DISABLED
#define NORMALLY_OPEN IO_ACTIVE_LOW // equivalent
#define NORMALLY_CLOSED IO_ACTIVE_HIGH // equivalent
//#define NORMALLY_OPEN IO_ACTIVE_LOW // equivalent
//#define NORMALLY_CLOSED IO_ACTIVE_HIGH // equivalent
// *** NOTE: The active hi/low values currently agree with spindle and coolant values
// The above will all need to be changed to ACTIVE_HIGH = 0, ACTIVE_LOW = 1
@@ -108,6 +108,7 @@ typedef enum {
* GPIO structures
*/
typedef struct ioDigitalInput { // one struct per digital input
int8_t ext_pin_number; // for easier debugging - not actually used
ioMode mode; // -1=disabled, 0=active low (NO), 1= active high (NC)
inputAction action; // 0=none, 1=stop, 2=halt, 3=stop_steps, 4=reset
inputFunc function; // function to perform when activated / deactivated

View File

@@ -243,7 +243,7 @@
*/
// Xmin on v9 board // X homing - see X axis setup
#define DI1_MODE NORMALLY_CLOSED
#define DI1_MODE IO_ACTIVE_HIGH // Normally Closed
#define DI1_ACTION INPUT_ACTION_NONE
#define DI1_FUNCTION INPUT_FUNCTION_NONE
@@ -253,22 +253,22 @@
#define DI2_FUNCTION INPUT_FUNCTION_SHUTDOWN
// Ymin // Y homing - see Y axis setup
#define DI3_MODE NORMALLY_CLOSED
#define DI3_MODE IO_ACTIVE_HIGH
#define DI3_ACTION INPUT_ACTION_NONE
#define DI3_FUNCTION INPUT_FUNCTION_NONE
// Ymax // Safety interlock
#define DI4_MODE IO_ACTIVE_HIGH
#define DI4_ACTION INPUT_ACTION_NONE // (hold is performed by Interlock function)
#define DI4_ACTION INPUT_ACTION_NONE // (hold is performed by Interlock function)
#define DI4_FUNCTION INPUT_FUNCTION_INTERLOCK
// Zmin // Z probe
#define DI5_MODE IO_ACTIVE_LOW
#define DI5_MODE IO_ACTIVE_LOW // Normally Open
#define DI5_ACTION INPUT_ACTION_NONE
#define DI5_FUNCTION INPUT_FUNCTION_PROBE
// Zmax // Z homing - see Z axis for setup
#define DI6_MODE NORMALLY_CLOSED
#define DI6_MODE IO_ACTIVE_HIGH
#define DI6_ACTION INPUT_ACTION_NONE
#define DI6_FUNCTION INPUT_FUNCTION_NONE

View File

@@ -269,7 +269,7 @@
*/
// Xmin on v9 board // X homing - see X axis setup
#define DI1_MODE NORMALLY_CLOSED
#define DI1_MODE IO_ACTIVE_HIGH // Normally CLosed
#define DI1_ACTION INPUT_ACTION_NONE
#define DI1_FUNCTION INPUT_FUNCTION_NONE
@@ -279,22 +279,22 @@
#define DI2_FUNCTION INPUT_FUNCTION_SHUTDOWN
// Ymin // Y homing - see Y axis setup
#define DI3_MODE NORMALLY_CLOSED
#define DI3_MODE IO_ACTIVE_HIGH
#define DI3_ACTION INPUT_ACTION_NONE
#define DI3_FUNCTION INPUT_FUNCTION_NONE
// Ymax // Safety interlock
#define DI4_MODE IO_ACTIVE_HIGH
#define DI4_ACTION INPUT_ACTION_NONE // (hold is performed by Interlock function)
#define DI4_ACTION INPUT_ACTION_NONE // (hold is performed by Interlock function)
#define DI4_FUNCTION INPUT_FUNCTION_INTERLOCK
// Zmin // Z probe
#define DI5_MODE IO_ACTIVE_LOW
#define DI5_MODE IO_ACTIVE_LOW // Normally Open
#define DI5_ACTION INPUT_ACTION_NONE
#define DI5_FUNCTION INPUT_FUNCTION_PROBE
// Zmax // Z homing - see Z axis for setup
#define DI6_MODE NORMALLY_CLOSED
#define DI6_MODE IO_ACTIVE_HIGH
#define DI6_ACTION INPUT_ACTION_NONE
#define DI6_FUNCTION INPUT_FUNCTION_NONE