Arduino digital input, 80Vdc

wow thanks so much for your answers !
the idea of the diode is great, I dont expect to get reverse voltage but better to be save. if i finally use 2 resistors, I guess i can put the diode in also,right? just at after the 2 resistors meet.
So i could just get a 1k and 16k resistor and if the input is 80V I get 5V. I like the idea but...

I might get some voltage surges and would not like to fry my arduino, also its a good oportunity to use them for the first time. Can you help me out on how to choose the appropiate one?

thank you so much for the help, hope to be heading the electronic shop this afternoon to buy the stuff I need. Just need to figure out which optocoupler I could use.
I guess 1N4148 as diode is as good as 1N4001 or 1N4007 which I already have at home?

thanks a lot

The 2 resistors solution proposed by fungus was for use if you don't want optical isolation between the 60-80V and the Arduino. If you are using an optoisolator, then a single series resistor is all you need.

1N400x as the protection diode will be fine.

How can I find one that meets this requirements?

The answer depends on what your requirements are. If you simply want to detect the presence of a 80vdc signal (either it is or it is not), a simpler resistor + opto-coupler will do. If you want to detect the presence of a 80vdc signal vs. a 60vdc signal, a simpler resistor + zener + opto-coupler will do. If you want to detect if it is 80vdc or 80.1vdc, etc., you will need some really fancy stuff.

thank you all !

I need to detect 0Vdc or >60Vdc (system on).

You say using a optocoupler I only need one resistor in series? I guess just like you would light up a led right? great ! I need to build 10 of this in a board so the fewer the parts the better.

so how can I choose the optocoupler? as I say, the system should have 0 V when OFF and around 60 or more Vdc when it is ON. I just need to dectect if its ON or OFF.

I will need for each subcircuit:
1 x 1N400x diode (to protect reverse voltage)
1 x Resistor to feed the optocoupler. Dont know which one as I dont know the optocoupler
1 x Optocoupler

Any additional help on selecting one for this particular use, bearing in mind the input voltage can go from 60 to 80Vdc and with surges.

once again, thanks a lot, this is a really important proyect.

I need to detect 0Vdc or >60Vdc (system on).

Assuming that you need isolation.

  1. Get the optocoupler's datasheet. Find the current needed to light up the led.
  2. Get a resistor that will generate that current under 60v. You can size that resistor a little bit higher if you want to make sure that there is sufficient threshold.
  3. If you want to protect the opto-coupler for reverse polarity, put a diode on it, or another opto-coupler but reverse the polarity - in that case, you can detect ac as well as dc.
  4. Done.

Any general-purpose optocoupler such as 4N25 or 4N35 will do for that job. Most optocouplers work well with around 10mA forward current, which is why I suggested a 6.8K resistor.

dhenry:

I need to detect 0Vdc or >60Vdc (system on).

Assuming that you need isolation.

  1. Get the optocoupler's datasheet. Find the current needed to light up the led.
  2. Get a resistor that will generate that current under 60v. You can size that resistor a little bit higher if you want to make sure that there is sufficient threshold.
  3. If you want to protect the opto-coupler for reverse polarity, put a diode on it, or another opto-coupler but reverse the polarity - in that case, you can detect ac as well as dc.
  4. Done.

Great thanks !
I want isolation for two reasons, to learn my first optocoupler circuit and to make things saver.

Asuming a 4N35 optocoupler which seems quite famous

Collector-base voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 V
Collector-emitter voltage (see Note 1) 30 V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Emitter-base voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 V
Input-diode reverse voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 V
Input-diode forward current: Continuous 60 mA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Peak (1 µs, 300 pps) 3 A

http://measure.feld.cvut.cz/groups/edu/osv/4N35.pdf

So lets see if I get this right...
lets say 90V as you say.
V = I * R
90V = 0,060A * R
R = 1500 Ohms

so 1,5 Kohms resistor is ok?
P = V * I
P = (90-6)V * 0,06 Amps = 5 Watts ??? this is not right, isnt it?

just saw your message dc42.
let me see if I understand the calculations.

V=IR
80 =0,01 * R
R = 8000ohms
so similar to yours.
about watts of resistor, i think i got it wrong, i guess i need small 1/4W resistors

Sergegsx:
just saw your message dc42.
let me see if I understand the calculations.

V=IR
80 =0,01 * R
R = 8000ohms
so similar to yours.
about watts of resistor, i think i got it wrong, i guess i need small 1/4W resistors

Yes, that's right. You don't need to run the optoisolator anywhere near its maximum current rating. For the 4N35, even 1mA forward current should be enough to pull the digital input pin low, if you are using the internal pullup resistor.

If of 60ma is the max (continuous) current through the diode. You probably want your opto-coupler to work a little below that. Let's say 10ma.

That means a series resistor of about 90v/10ma = 10k.

You will then find the Ic corresponding to 10ma of If. Figure 6 shows a 1:1 current transfer ratio (but at 10v Vce). So assume that's true for 5v Vce as well. Your Ic is 10ma. You want this kind of current to generate a logic '0' on your avr's input. Check the AVR's datasheet and I think anything less than 1v is a logic low (for a ST pin). That means Rc = 4v / 10ma = 400ohm. Pick 330 or 390ohm.

You will then need to calculate at what threshold input voltage that your opto-coupler will product a high -> make sure that it is over the AVR's input threshold for logic '1'.

As you can see, there is a lot of assumptions / guesswork here so you will experiment a little bit.

What you will find is that using a zener will greatly help producing a sharper turn-on.

Sergegsx:
I might get some voltage surges and would not like to fry my arduino, also its a good oportunity to use them for the first time. Can you help me out on how to choose the appropiate one?

You could put in a protection diode for that. Get a 5V Zener diode and connect it in parallel with the lower resistor. If a voltage higher than 5V appears at the resistor junction the diode will short it to ground.

If the resistors have large values (75k, 5k) then there'll hardly be any amps, it should be enough protection.

fungus in parallel? like this... see picture. or maybe as the second option i have drawn?

dhenry thank you so much for the explanation. will reread it a couple of times for fully understanding it.

dc42, you are right, that is max. thanks !

mm...maybe i understood it wrong. maybe like this?
and the internal pullup resistor from the arduino active.

D4 is redundant in this circuit, unless you accidentally short the input of the opto isolator to the output. It might be a useful protection device if you were not using optical isolation. It is also connected the wrong way round.

the internal pullup resistor from the arduino active.

That pull-up "resistance" is too high and you may not be able to turn off the phototransistor and generate a logic 0.

Use a resistor and its value will generally be < 10k.

dc42:
D4 is redundant in this circuit, unless you accidentally short the input of the opto isolator to the output. It might be a useful protection device if you were not using optical isolation. It is also connected the wrong way round.

thanks, i thought this is what fungus ment to be able to give aditional protection in case there is a surge in the 80Vdc.
dont understand what he ment then.

dhenry:

the internal pullup resistor from the arduino active.

That pull-up "resistance" is too high and you may not be able to turn off the phototransistor and generate a logic 0.

Use a resistor and its value will generally be < 10k.

ok i just say the internal pullup resistor of the arduino is 20Kohms.
I will use a 10k then ! thanks for the information dhenry

dhenry:

the internal pullup resistor from the arduino active.

That pull-up "resistance" is too high and you may not be able to turn off the phototransistor and generate a logic 0.

Use a resistor and its value will generally be < 10k.

From the data sheet, the off-state collector current of the 4N35 is 50nA max at 25C. So the internal pullup resistor will be fine unless the OP puts the opto isolator somewhere very hot, or he needs a faster turn-off time (but we're only talking about a few hundreds of microseconds at most).

Thanks dc42, i will try both internal and external pullup resistor and decide. I dont need such a short timing.
The circuit so far...

Thanks, any additional information is welcome.
Still trying to figure out where the zener would be at use, maybe its after the R1 to ground.

dc42:
See attached. The diode in parallel with the input side of the optocoupler is needed only if there is a possibility of the polarity of the 60-80V input reversing. Enable the internal pullup on the digital input pin.

Sorry to bump this up, but I finally need to build this circuit.
I was just wondering, what is the difference between setting the diode in series with positive, or to put it in parellel with the optocoupler?

Please correct me if I am wrong
In series: Acts as a polarity protection. In case + and - are connected the wrong way it will not allow current to flow.

In parallel: Acts as a short circuit in case voltage is over "reverse voltage", but it was suggested that any 1N400x however for example 1N4007 has 700V reverse voltage, and I am just putting in 80V, so any surge will be much lower. however 1n4148 does have a "reverse voltage" of 100V so that makes more sense.

Both? If I am correct, both diodes would be needed for extra security?

Thank you very much

series.JPG