auto update of probe height
-
I have a macro that probes 10 times so that the user can update G31 with the average probe height.
The macro now calculates the average probe height but I don't know how to update G31 permanently from within the macro.
My current G31 X-25 Y-5 Z0.67 P500 needs to be amended to be G31 X-25 Y-5 Z(average value) P500Any ideas on how to do this?
-
Checking the object model, it looks like the median value spit out from the G30 S-1 runs is not available. But
sensors.probes[0].lastStopHeight
is. So with the variables that landed in 3.3b2, you might be able to read that after each individual probing run, and then in the end build your own median or average from the measurements.Untested code that will most certainly not work (I don't have a standalone machine with 3.3b2 at hand to test), assuming a single probe:
stop_heights = 0.0 while iterations < 30 G30 P{iterations} X0 Y0 Z-99999 stop_heights = stop_heights + sensors.probes[0].lastStopHeight G30 P31 X0 Y0 Z-9999 S-1 stop_heights = stop_heights + sensors.probes[0].lastStopHeight avg_heights = stop_heights_sum/32 ; iterations starts at 0 G31 X-25 Y-5 Z{avg_heights} P500
-
I feel like M500 P31 and G30 S-3 could probably come into play here, but I'm not if that's needed now that conditional is available.
https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_M500_Store_parameters
If the P31 parameter is used, the G31 trigger height, trigger value and X and Y offsets for each possible Z probe type (in older firmware versions the G31 parameters are stored even if the P31 parameter is not present)
https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_G30_Single_Z_Probe
G30 S-3 ; Probe the bed and set the Z probe trigger height to the height it stopped at (supported in RRF 2.03 and later)
The downside of G30 S-3 is that it takes the singular result and not any average of several results.