If you are working with GRBL CNC, you might have faced false hard-limit alarm (especially if you are making your own or new to CNC world).
An unexpected error was detected: (ALARM:1) Hard limit has been triggered. Machine position is likely lost due to sudden halt. Re-homing is highly recommended.
1 – Change limit switches
The first thing you need to do is make sure to use NC – Normally closed limit switches for homing of hard limit. This is because you are for sure going to get some EMI – Electro Magnetic Interference. Be default many go for NO – Normally Open switches, since stepper motors, USB, and Switch mode power supply are all sources of noise. This noise can be picked by the sensitive inputs of Arduino (in case of GRBL shield)
2 – Check connection / joints
After switching to Normally closed switches. If this problem still persists, make sure to double check your connections. Are the rock solid, make sure there is no funny solder joint playing games with you (yes, loose solder joints / connectors can give you quite a run in crazy world)
3 – Soft limit (Enable / disable)
If above all is not working, which was the case for me. I have once used soft limits, but I turned it off later. My cnc setup would occasionally give false alarm of limits being triggered. Just tweaking around things, I reset the soft limits and to my surprise the false alarm issue went away. To make sure of this. I check the CNC jogging to extreme ends several times. The problem was gone.
Problem solved. Happy CNCing