24volt to 5volt pulse conversion without affecting frequency
If the output is open collector, all you need to do is provide a pullup to 5 volts instead of 24 volts. Open collector means the output device only pulls low, not high, so the pullup resistor determines the high voltage.

If you can't do that for some reason, you can build a voltage divider using the existing pullup resistor and one to ground, calculated to output 5 volts with 24 volts input. This will affect anything else attempting to measure the same signal, however.