EtteGit / EnragedRabbitProject

GNU General Public License v3.0
2.37k stars 336 forks source link

When doing sensorless calibration ERCF_CALIBRATE fails to measure extruder #169

Open jwhite opened 1 year ago

jwhite commented 1 year ago

I have reproduced this numerous time.

When doing a calibrate single tool the calibration succeeds and sets the length of the ercf->extruder correctly.

When running ERCF_CALIBRATE_SINGLE_TOOL

17:01:13 $ ERCF_CALIBRATE_SINGLE TOOL=0
17:01:13 // TRACE: Disable encoder sensor
17:01:13 // Homing ERCF...
17:01:13 // DEBUG: Checking for filament in encoder
17:01:13 // DEBUG: Setting servo to down angle: 115
17:01:14 // TRACE: After buzzing gear motor, encoder read 0.0
17:01:14 // DEBUG: Setting servo to up angle: 25
17:01:14 // DEBUG: Filament already ejected!
17:01:14 // Homing selector
17:01:14 // DEBUG: Moving up to 62.0mm to home a 2 channel ERCF
17:01:15 manual_stepper gear_stepper:TRIGGERED manual_stepper selector_stepper:open x:open y:open z:open
17:01:18 manual_stepper gear_stepper:TRIGGERED manual_stepper selector_stepper:TRIGGERED x:open y:open z:open
17:01:18 // Homing ERCF ended...
17:01:18 // Select Tool 0...
17:01:18 // Tool 0 Enabled
17:01:18 // DEBUG: Setting servo to down angle: 115
17:01:18 // TRACE: Setting ERCF gear motor step ratio to 1.0
17:01:18 // M118 Heating extruder above min extrusion temp (180.0)
17:01:25 $ SET_HEATER_TEMPERATURE HEATER=extruder TARGET=210
17:02:27 // Calibrating reference tool
17:02:31 // TRACE: Initial load into encoder of 70.0mm - read 46.2 on encoder
17:02:42 // Load move done: 955.9 / 953.8 (diff: -2.1)
17:02:42 // DEBUG: Moved to calibration distance 1000.0 - encoder reads 1002.1
17:02:42 // DEBUG: Homing to extruder with 2mm moves
17:02:43 // TRACE: Step #0: pos: 1004.3, last delta: 2.1
17:02:44 // TRACE: Step #1: pos: 1006.4, last delta: 2.1
17:02:45 // TRACE: Step #2: pos: 1008.5, last delta: 2.1
17:02:45 // TRACE: Step #3: pos: 1010.7, last delta: 2.1
17:02:46 // TRACE: Step #4: pos: 1012.8, last delta: 2.1

<<snip>>

17:03:22 // TRACE: Step #43: pos: 1094.6, last delta: 1.4
17:03:23 // TRACE: Step #44: pos: 1097.4, last delta: 2.8
17:03:24 // TRACE: Step #45: pos: 1098.9, last delta: 1.4
17:03:25 // TRACE: Step #46: pos: 1101.0, last delta: 2.1
17:03:25 // TRACE: Step #47: pos: 1102.4, last delta: 1.4
17:03:26 // TRACE: Step #48: pos: 1102.4, last delta: 0.0
17:03:26 // DEBUG: Extruder reached after 48 moves
17:03:26 
// Calibration reference is 1102.4

When running ERCF_CALIBRATE

17:04:22 $ ERCF_CALIBRATE
17:04:22 // TRACE: Disable encoder sensor
17:04:22 // Start the complete auto calibration...
17:04:22 // TRACE: Disable encoder sensor
17:04:22 // Homing ERCF...
17:04:22 // DEBUG: Checking for filament in encoder
17:04:22 // DEBUG: Setting servo to down angle: 115
17:04:24 // TRACE: After buzzing gear motor, encoder read 0.0
17:04:24 // DEBUG: Setting servo to up angle: 25
17:04:24 // DEBUG: Filament already ejected!
17:04:24 // Homing selector
17:04:24 // DEBUG: Moving up to 62.0mm to home a 2 channel ERCF
17:04:24 manual_stepper gear_stepper:TRIGGERED manual_stepper selector_stepper:open x:open y:open z:open
17:04:27 manual_stepper gear_stepper:TRIGGERED manual_stepper selector_stepper:TRIGGERED x:open y:open z:open
17:04:27 // Homing ERCF ended...
17:04:27 // Select Tool 0...
17:04:27 // Tool 0 Enabled
17:04:27 // DEBUG: Setting servo to down angle: 115
17:04:28 // TRACE: Setting ERCF gear motor step ratio to 1.0
17:04:28 // Calibrating reference tool
17:04:31 // TRACE: Initial load into encoder of 70.0mm - read 44.8 on encoder
17:04:43 // Load move done: 982.9 / 955.2 (diff: -27.7)
17:04:43 // DEBUG: Moved to calibration distance 1000.0 - encoder reads 1027.7
17:04:43 // DEBUG: Homing to extruder with 2mm moves
17:04:44 // TRACE: Step #0: pos: 1029.2, last delta: 1.4
17:04:44 // TRACE: Step #1: pos: 1031.3, last delta: 2.1
17:04:45 // TRACE: Step #2: pos: 1032.0, last delta: 0.7
17:04:45 // DEBUG: Extruder reached after 2 moves
17:04:45 // Calibration reference is 1031.3

This can be consistently reproduced. Note that the second calibrate stops well short of the end of the bowden tube, so there is no chance there is a clog or snag. Also note that 0.7 is only a single tooth misread on the encoder. Moving 2mm on my encoder moves the encoder by 2 teeth, or 1.4. Slightly less than 2mm would be 0.7 and falsely detected as the end of calibration.

On my machine, move of 2 will be aliased by the encoder resolution and return either 2.1, 1.4, or 0.7.
(The encoder will return a number of pulses in the range of 1-3)

The current detection code will stop at 0.7 because it is looking for a value of 2mm / 2. or .5, which is below 0.7 causing the false detection.

My suggestion is to stop detection at < step-1 / 2. to ensure the stop is a true stop by the encoder.