dynamic zProbe trigger value
-
Hello everybody
This week i have finished more or less the work on my delta printer.
I have changed from an old Arduino/Ramps setup to a DUET2 with underbed piezo sensors. At the moment, i try to use the piezos in analog mode.
The system works fine, but i'd like to improve my bed.g, because when i change something mechanical on my bed, the absolute analog value of the piezo probe (untriggered) is changing too.
I had the idea to calculate an average value of the probe input and add a "trigger offset" (100 in this case).My questions:
- does somebody see big errors in my code? Or should it work more or less...
- the variable in the "G31 P" command will not be an integer! Can the FW handle that? Or is there a possibility to convert the variable to an integer?
Thanks in advance
This is the code which i'd like to implement in bed.g, somewhere between homing and probing...
var zProbeTriggerValue = sensors.probes[x].value[x] ;first reading of analog value, setting variable while iterations < 3 ;reading 2-4 G4 P200 ; delay set var.zProbeTriggerValue = var.zProbeTriggerValue + sensors.probes[x].value[x] set var.zProbeTriggerValue = var.zProbeTriggerValue / 4 ; calculate average G31 P{var.zProbeTriggerValue + 100} ; setting zProbeTriggerValue
-
@cosmowave change line 9 to
G31 P{floor(var.zProbeTriggerValue) +100} ; setting zProbeTriggerValue
and you should get a nice integer value.
Maybe add a safeguard against the average being 900 or higher...
-
@oliof said in dynamic zProbe trigger value:
Maybe add a safeguard against the average being 900 or higher...
That's a good idea!
Thank you!