I have used several methods, one is a board that cncbuildingblocks made, it is used on my lathe to convert the limits switch 24v to 5v, sadly Ed is no longer making his boards
I also use relays to convert the 5v to 24v and vice versa. On the mill I am presently doing I made up a board with 7 relays on it, I can have the switched contacts of the relays either all in series, all seperate or a mixture of both just by placing jumpers accordingly. The idea behind this was I could connect a load of limit switches to the board and as the switched contacts were in series I would only need 1 input to Mach. I also have a similar one that takes outputs from Mach at 5V and has 24V accross the switched contacts, I use this for the Inputs to my servo drives which are 12 to 24V.
Hood