I can't really answer your questions but I've reviewed your code.
Float Switch as a Limit Switch
I think there is an error in logic treating the float switch as a limit switch. If there is no material under the torch, nothing will be triggered and the axis will crash. You really need a separate limit switch for the lower end of travel. A lot of examples X axis mechanisms I looked at did not have a lower limit switch but I added one to my machine. (Due to space constraints, I used a mechanical micro switch instead of a proximity switch) I figured it would have a low duty cycle so should never wear out.
If your float switch and upper limit switch share the same output, there is no excuse for this when you are using a Mesa card which has inputs to burn.
Float Switch as Back up if Ohmic Circuit Fails
When probing, the float switch should be treated as a valid input as it should serve as a backup if the ohmic sensing circuit fails so it is definitely not an error if triggered while probing.
Gotos are considered bad form
I personally don't like using goto statements but they can be efficient for error handling but nested if statements also do the job without adding excessive code. I hope I've cleaned them out correctly.
Implement timeouts using current time
With time outs, somewhere you have to read the current time as you enter a routine for the first time and then check if the time exceeds this time plus desired delay. Normally in C, I would use a static variable that holds its value between calls. IN HAL, it seems global variables are used, so I've added two variables. One to hold the time and the other a flag that is true on the first call to the procedure. I did this as I treated the code as if it was an interrupt service routine in case this procedure actually gets called multiple times during execution from the servo thread. Don't forget to reset the flag on exit from the procedure.
So with those comments, here is what I came up with.
Code:
# Pseudo code for probing sheet top with conductive (ohmic) sensing and floating switch safety
#Parameters
# W_height = position above -Z soft limit that Z feedrate is reduced to probing feedrate,
# usually about -Z soft limit + thickness of thickest material used + safety (.1" to .25")
# probing_timeout = probing error occurred if it takes longer than this
# probe_rate = feedrate to probe at
#
# Global/static/persistent variables, call them what you will
start_time
first_pass = 1
start
if(first_pass == True)
start_time = now
time_out = start_time + probing_timeout
first_pass = 0
Feed Hold X & Y Axis
Set Error to ""
Enable Conductive (ohmic) Sensor
if( Probe == False)
Move Z axis Position to W_height at Rapid_Feedrate
Set Z feedrate to probe_rate
while((Probe == False) && (float_switch == False) && (now < time_out))
Z axis move in - direction
Stop Z axis move
if(now >= time_out)
Set Error to "Timeout"
else
Set Z axis feedrate to probe_rate/2
while((Probe == True) && (float_switch == False) && (now < time_out))
Z axis move in + direction
Stop Z axis move
Disable Conductive (ohmic) Sensor
if(now >= time_out)
Set Error to "Timeout"
else
Set part 0 to present Z axis position
first_pass = 1
Return (1)
else
Set Error to "Sensor_Shorted"
Disable Conductive (ohmic) Sensor
Set Z axis feedrate to Rapid_Feedrate
Move Z axis to Safe_G0_Height
Send Error to GUI
first_pass = 1
Return (-1)