Monitor 12v / 24V, with spikes upto 50V?

Hi,

Can anyone help me with this one please? I want to monitor a DC power source, which can either be 12V or 24V, but which can spike upto 50V. At first I thought of using a 4n25 opto isolator but then realized that it only has a "variable" voltage of upto 70V on the output side, not in the input side. This works well when using an Arduino to "drive" higher voltage electronics, like motors.

But, I need to wire it the other way around, i.e. the Arduino will sit on the "output side", i.e. pins 4 & 5. But how do I protect the input from the large voltage differences.
Or, what else can I use in such a case?

Optoisolators like the 4N25 are meant to transfer digital signals. There are analog optoisolators but they are a bit complicated to set up. If you know that the signal will not go over 50V you could use a 10:1 voltage divider. 12V would be 1.2V and 24, 2.4V. Run to an analog input.

Whan you say "monitor" do you just want to check if it's on/off or do you need to measure the voltage? Do you need isolation?

4n25 opto isolator but then realized that it only has a "variable" voltage of upto 70V on the output side, not in the input side.

On the input side, there's an LED.

LEDs are "constant voltage" devices. That means (like with a standard LED) you use a series resistor to limit the current, and as long as the current stays within spec, the voltage across the voltage remains approximately constant with the remainder of the voltage dropped across the series resistor. You cannot "over voltage" an optioisolator's input unless you exceed the current rating or you exceed the isolation/breakdown voltage.

A quick look at the spec sheet says the 4N25 should work between 10 and 60mA at about 1.5V. With 12VDC that's 10.5V across the series resistor. Choosing 15mA and using [u]Ohm's Law[/u], we get 10.5V/0.015A = 700 Ohms. Boosting the voltage to 24V gives 1500 Ohms. (Or, using the same 700 Ohm resistor, we'd get around 30 mA, and the device would still work.)

60mA at 50V (48.5V across the resistor) gives us 808 Ohms as a minimum safe value.

If you use a 1K resistor, the optoisolator should get more than the required 10mA at 12V and less than the emaximum 60mA at 50V.

DVDdoug:
Whan you say "monitor" do you just want to check if it's on/off or do you need to measure the voltage? Do you need isolation?

I want to know if it's on / off and would prefer isolation due to the high voltages. It's a Diesel engine and from what I understand, one can get short high voltage spikes when the engine is "cut-off". I've measures 50V once but have heard that it could spike upto 70V. So I want to have isolation for protection of the Arduino.

A 12V petrol / diesel engine can produce between 11.8V and 14.6V (and sometimes higher), depending on the the battery's health, and the type alternator. a 24V engine can sometimes produce upto 27V from the alternator.

I need to monitor both types, and would like to build a "universal" type monitor which can be used on either voltages, safely.

There's another threat in the forum about a "car psu" and it sounds to me like a car's electronics is quite "harsh" for an Arduino.

DVDdoug:

4n25 opto isolator but then realized that it only has a "variable" voltage of upto 70V on the output side, not in the input side.

On the input side, there's an LED.

LEDs are "constant voltage" devices. That means (like with a standard LED) you use a series resistor to limit the current, and as long as the current stays within spec, the voltage across the voltage remains approximately constant with the remainder of the voltage dropped across the series resistor. You cannot "over voltage" an optioisolator's input unless you exceed the current rating or you exceed the isolation/breakdown voltage.

A quick look at the spec sheet says the 4N25 should work between 10 and 60mA at about 1.5V. With 12VDC that's 10.5V across the series resistor. Choosing 15mA and using [u]Ohm's Law[/u], we get 10.5V/0.015A = 700 Ohms. Boosting the voltage to 24V gives 1500 Ohms. (Or, using the same 700 Ohm resistor, we'd get around 30 mA, and the device would still work.)

60mA at 50V (48.5V across the resistor) gives us 808 Ohms as a minimum safe value.

If you use a 1K resistor, the optoisolator should get more than the required 10mA at 12V and less than the emaximum 60mA at 50V.

I know the math in Ohm's law, but is that good enough, or is there a better / safer way?

Basically your issue is to protect against spikes. There was a post about that a while back. A combination of diodes and resistors should throw away the spikes and then you are left with a simple voltage measurement.

Some tips here:

Thanx, I'll readup on that post.

See also Zener Diode usage in Voltage Divider - General Electronics - Arduino Forum
You may use R1=22k for 25V max.