Things you can check:
- Check that the second time you're pressing the HMI button, the robot is getting a Start at Main. If it's only getting a Start, it's continuing the previous program, and it's not evaluating its location again.
- When you press it the second time briefly, what are the states of doR1_MoveHome, giR1_StyleCode, goR1_StyleCode, giR1_StyleCode,
g0R1_StyleCode and doR1_HomePos?
r1_Comau_init() is not actually checking if the robot is already at home before starting the homing routine. It relies on the style number sent from the PLC to start the homing routine. This means you'll always evaluate all the IF/ELSEIF statements in the recovery routine. If the robot can't find a predetermined location, it just goes to home. (Ah!)
- Does this behavior happen every time you test it or does it only happen when you're trying to send the robot home from a specific location? Could it be that you're trying to home the robot from a location that isn't covered in CheckLocation?
I second what was previously mentioned:
Also, in the event that the robot is actually outside of recoverable range, I would delete the commented STOP instruction and the HomePos call and replace them with an EXIT instruction or some kind of error handler.
In case the robot is not in any of the predetermined locations, it should not default to go home. Uncomment the STOP instruction, so it stops and manually homed if it's not in a safe location.