5v DC +ve connected to 24v negative is this safe?
What you are trying to do is use a 5 V sensor to drive a 24 V "sourcing" input. What this means is that it will source current and to turn it on you just have to short it to ground - as you have discovered.

In Figure 1 below an external sensor is connected to a PLC sourcing input. The PLC input has an opto-coupler to the internal logic to isolate the sensitive logic circuitry from the outside world. (Whether yours does or not doesn't make much difference to the analysis.) The circuit, as far as external switches are concerned, is an LED with series resistor. If we short the input terminal to the common terminal we should expect about 5 to 15 mA to flow (determined by the internal series resistor).



Figure 1. A sensor with an open-collector output driving a sourcing input powered from a 24 V power source. Note that the negatives are connected.

Whether this will work with your sensor depends on whether it has an open-collector output or not. If it doesn't damage will occur.

Post a link to the sensor datasheet and post a comment below to let me know.





Figure 2. The speed signal output circuit seems to read from right to left. Note the internal pull-up to 5 V. This prevents us connecting directly to the 24 V input as shown in Figure 1 as the 24 V will backfeed into the 5 V supply.







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 3. Addition of an NPN transistor to buffer the signal between the two boards. This circuit reads left to right.

How it works:


With nothing connected to the Speed signal output the line will normally be pulled to +5 V by R1. When OPTO turns on the line will be pulled to 0 V (GND).
By adding Q2, any NPN small signal transistor, we can buffer between the 5 V and 24 V circuits. When OPTO is off R1 will supply current into the base of Q2 turning it on. Q2 will then short INPUT to ground and light the LED.
When OPTO turns on it will steal the current from the base of Q2 which will turn off. This will turn off INPUT and the LED.