I've a question that seems to be quite trivial. However, I'm writing a program to control my CNC machine. I yet have to build this machine, but I've ordered the parts last week.

Now, I don't seem to grasp the best way to calibrate the machine.

1) stop switches on every axis of the machine
2) no stop switches, but using the PC's keyboard to step to the right spot
3) as 2 but with a small keyboard attached to the machine

The most practical solution definitely must be 1. Though, I think this is the most inaccurate one, too. For example, it's impossible to exactly set the Z-axis to zero with a stop switch. (?)

So, what's the best way to do this?