You need to have a routine that is called from setup() which slowly (step by step) moves the system to the end of the track where the limit switch is situated. After each move check to see if the switch has been pressed. If it has you are at the Zero position.
...R