Positive to negative PWM converter
Take your 24V pulses and strongly differentiate them with an RC high pass filter: -



Make sure they are properly differentiated like example (a) below: -



The resistor shown above needs to be connected to -2.5 volts - maybe use two equal value resistors - one to 0V and one to -5V

Reduce the amplitude to 5Vp-p (resistors and/or diode clamps can do this)

Set up a schmitt trigger running from a -5V rail and feed the clamped signal to its input. The output from the schmitt trigger will be the PWM signal you want. It needs to be a schmitt trigger so that it only changes state when a spike occurs: -