I instrumented motion.cpp, planner.cpp and probe.cpp with tons of DEBUG statements and found that setting the axis pos to zero has no effect.
Relevant code lines from function void do_homing_move() in file motion.cpp:
// Get the ABC or XYZ positions in mm
abce_pos_t target = planner.get_axis_positions_mm();
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("###1331 axis= ", axis); //ZABEX 2020-08-29
DEBUG_POS("###1332 do_homing_move BEFORE target[axis]=0", current_position);//ZABEX 2020-08-29
target[axis] = 0; // Set the single homing axis to 0
planner.set_machine_position_mm(target); // Update the machine position
DEBUG_POS("###1336 do_homing_move AFTER target[axis]=0", current_position);//ZABEX 2020-08-29
The result of debug output ###1332 is 15.5mm and of debug output ###1336 is also 15.5mm instead of zero.
Here an extract from my logging:
18:52:03.027 : >>> do_homing_move X223.00 Y170.00 Z15.50
18:52:03.027 : ###1278 do_homing_move:distance=15.00
18:52:03.027 : ###1279 do_homing_move:fr_mm_s=10.00
18:52:03.028 : ###1283 do_homing_move:real_fr_mm_s=10.00
18:52:03.028 : ...(Z, 15.00, 10.00)
18:52:03.028 : ###1309 do_homing_move:is_home_dir=0
18:52:03.028 : ###1331 axis= 2
18:52:03.028 : current_position= X223.00 Y170.00 Z15.50 : ###1332 do_homing_move BEFORE target[axis]=0
18:52:03.028 : current_position= X223.00 Y170.00 Z15.50 : ###2861 planner:set_machine_position_mm BEFORE position.set
18:52:03.028 : ###2862 planner: c=0.00
18:52:03.028 : current_position= X223.00 Y170.00 Z15.50 : ###2868 planner: set_machine_position_mm AFTER position.set
18:52:03.028 : ###2873 planner: set_machine_position_mm AFTER position.set, position.c=0
18:52:03.029 : current_position= X223.00 Y170.00 Z15.50 : ###2879 planner: set_machine_position_mm AFTER stepper.set_position()
18:52:03.029 : current_position= X223.00 Y170.00 Z15.50 : ###1336 do_homing_move AFTER target[axis]=0
18:52:03.029 : ###1340 target[axis]=distance = 15.00
18:52:03.029 : current_position= X223.00 Y170.00 Z15.50 : ###1351 do_homing_move AFTER target[axis]=distance
18:52:03.030 : ###1348 planner.synchronize
18:52:03.137 : current_position= X223.00 Y170.00 Z15.50 : ###1355 do_homing_move AFTER planner.synchronize()
18:52:03.137 : <<< do_homing_move X223.00 Y170.00 Z15.50
In void Planner::set_machine_position_mm() I inserted a
set_current_from_steppers_for_axis(ALL_AXES); //ZABEX Bugfix 020-08-29
in the ELSE block after stepper.set_position(position);
So the code looks like:
void Planner::set_machine_position_mm(const float &a, const float &b, const float &c, const float &e) {
TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder);
TERN_(HAS_POSITION_FLOAT, position_float.set(a, b, c, e));
DEBUG_POS("###2861 planner:set_machine_position_mm BEFORE position.set", current_position);//ZABEX 2020-08-29
DEBUG_ECHOLNPAIR("###2862 planner: c=", c);//ZABEX 2020-08-29
position.set(LROUND(a * settings.axis_steps_per_mm[A_AXIS]),
LROUND(b * settings.axis_steps_per_mm[B_AXIS]),
LROUND(c * settings.axis_steps_per_mm[C_AXIS]),
LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(active_extruder)]));
DEBUG_POS("###2872 planner: set_machine_position_mm AFTER position.set", current_position);//ZABEX 2020-08-29
//FALSCH: set_current_from_steppers_for_axis(ALL_AXES); //ZABEX Bugfix 020-08-29
if (has_blocks_queued()) {
//previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest.
//previous_speed.reset();
buffer_sync_block();
DEBUG_POS("###2878 planner: set_machine_position_mm AFTER buffer_sync_block", current_position);//ZABEX 2020-08-29
}
else
{
stepper.set_position(position);
DEBUG_POS("###2885 planner: set_machine_position_mm AFTER stepper.set_position(", current_position);//ZABEX 2020-08-29
set_current_from_steppers_for_axis(ALL_AXES); //ZABEX Bugfix 020-08-29
DEBUG_ECHOLNPAIR("###2885 planner: set_machine_position_mm AFTER set_current_from_steppers_for_axis() position.c=", position.c);//ZABEX 2020-08-29
DEBUG_POS("###2886 planner: AFTER set_current_from_steppers_for_axis", current_position);//ZABEX 2020-08-29
}
}
That changes the current position to zero but unfortunately the axis still does not move up for Move Away before Home 2 Slow.
Is there anybody who has deeper knowledge of the mechanisms around the handling of the values between position and current_position?
Best regards,
Zabex