Have a read through gnea/grbl As per Grbl Wiki An inverted Z is very weird, one wants to home Z up away from the workpiece to avoid crashing. Put your switches at Max of each axis, and use default of $23=0 custom compile, or stock official Hex installed? And test without the “solenoids” - if that is part of the cause, consider actual Optos instead. Mechanical devices have a lot of “bounce” and is far from ideal for this use case. Hook up an oscilloscope, you will be shocked at the output from the solenoid contacts.