AtariOwl wrote:Could i use optoisolators?
How might i do that?
If you have optoisolators you could connect the input (LED) side across the 22v/sensor rails so when sensor-0v open circuit is closed by the car, it will activate the isolator LED briefly. But you'll need a resistor (at a minimum) to protect the LED from burning out at 22v.
There are neat ways to do any of these circuits properly (opto or magnetic) so you get a fixed pulse length (or just invert the signal on each crossing) - which makes for better detection. But you can start with just a resistor to protect the LED.
Lets say 22v for the supply, 5mA for the LED (but you need to check the optoisolator datasheet).
Use Ohms law:http://www.electronics-tutorials.ws/dccircuits/dcp4.gif
R = V / I (resistance = volts / amps)
R = (22V / 0.005A) = 4400 = 4.4k resistor
So a 4.4k resistor in series with 22v will operate the isolator. However you said that the voltage drops as low as 14v depending on the cars so that no good.
You'll need to find the min and max safe operating current for the isolator from the datasheet, get the middle of that range and then calculate the resistor for that. You'll then need to check that the current is still in range for 14v and 22v extremes with that chosen resistor.
Since the isolator will only be on briefly, for the simplest kind of circuit, your margin will be bigger so you can err towards a smaller resistor to improve detection.
I doubt this is the most reliable circuit to use as-is but it is at least simple. It involves fewer parts than a transformer based one. Obviously you'll need to buy suitable optoisolators first.
An alternate version of this could have the LED on most of the time, with the sensor shorting it out. This would give you more opportunity to regulate the current so the voltage fluctuations don't matter so much. It again involves more bits though (like adding a single 12v regulator, and then a fixed resistor+capacitor pair for each isolator). There are numerous other circuit variations which will also work.
You can improve reliability in similar ways to the transformer circuit - cleaning up the trigger or fixing the pulse length for detection. Just be careful not to toast the LEDs using the wrong resistor values.