GRBL interacting

I am writing my own specific PC-side software to interact with GRBL CNC controller. I have XYZ limit switches (both sides) and Homing cycle is enabled. All hardware is working good. I need it for repetitive movements and I would like to have quick recovering in case if something went wrong (like touching limit sensors). My questions are:

  1. How PC-side software may know position is lost and re-homing is required?
    I am planning to rely on error or alarm messages from GRBL, is this valid approach? Any better ideas?

  2. Standard homing command ($H) fails when I am already on position with tripped limit switches. I have to manually move it out of edges and run $H after that. What is the best procedure to automatically recover?

GRBL version is 1.1f.

  1. If the position is lost because of skipped steps, there is no way for the machine to know of position lost. If it contacts a limit switch and the setup is right, the machine will alarm out. Then you may be faced with 2).

  2. Danged if I know.

The PC will not know unless your steppers have encoders to form a "closed loop" system.
This is one of the reasons GRBL based machines are so cheap.

There are other parameters that need to be enabled for limit / homing switches.
Make sure you have them set correctly.

Seeing your parameters may be useful as often it is easy to spot some of the more simple issues.

In additon to all that's beeing said: Don't use GRBL for your requirement. Get the sofdtware for Maslov https://www.maslowcnc.com/ and modify the kinematics. It has already encoder support for position feedback, so your 2 problems will be solved. But you need Atmega256.