Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I want to use an phototransistor interfaced with microcontroller to detect absence of 118 dc voltage.The problem is how to calculate the right resistor value of the input(LED) circuit as well as output circuit(collector emmiter cct) thanks.

share|improve this question

3 Answers

A simpler approach would be using a digital isolator such as the ADuM3210. Use a voltage divider to create a 5V input to side 1 of the isolator when the 118V supply is present. This will be communicated across the isolation barrier as a "1" on the output. When the 118V supply is absent the voltage will drop to 0V and a "0" will be observed on the output. You can power the isolator from a supply derived from the 118V supply if necessary. If the input supply is lost, the outputs will default to "0" by default and maintain the correct sense.

You won't have to worry about CTR temperature variation or degradation over time in the optocoupler, and the power consumption will be much lower. You can learn more about digital isolator solutions here:

An Alternative to Optocouplers

share|improve this answer

If you use the following circuit you'll get a high output voltage is the 118V is absent. Swap transistor and load resistor if you want a low output voltage.

enter image description here

Let's take a look at the CNY17 (though many other optocouplers will do). The CNY17 is available in different CTR (Current Transfer Ratio) classes. CTR tells us how much collector current there will flow in the phototransistor for a given LED current.

Let's assume a 5V \$V_{CC}\$, that we draw \$200\mu\$A from the output and that the output voltage for a high level should at least be 4V. Then the maximum value for the load resistor should be

\$ R = \dfrac{5V - 4V}{200 \mu A} = 5k\Omega \$

Then the collector has to sink 5V/5k\$\Omega\$ = 1mA to drive the output down to 0V.
The CNY17-3 has a CTR of 100-200, that means that for the 1mA out you'll need between 0.5mA and 1mA in. Worst case is 1mA.
Then R1 should be 118V/1mA = 120k\$\Omega\$ (rounded to the nearest E12 value. I'm ignoring the 1.65V across the LED). That's it.

118V across a resistor is a lot, so let's see if it can handle that. Power = 118V \$\times\$ 1mA = 118mW, so a standard 1/4W PTH resistor is OK. This can also handle the voltage. If you want to use an SMT resistor you'll need at least an 0805.

The load resistor determines the current, and we can't use a value higher than 5k\$\Omega\$, otherwise the output voltage level will be too low. If that means that you have to drive the LED with a too high current (for instance in an optocoupler with a low CTR, CTRs much lower than 100% are common), you can use a voltage follower to limit the load current, so that you can use a larger resistor value.

enter image description here

share|improve this answer
118mW in a 1/4 W resistor will run pretty hot - nominal resistor power ratings should be treated with several pinches of salt. I'd go to at least a 1/2 or 1W in TH, with plenty of copper on the pads to spread the heat, and for SM, 2-4 series 0805s – mikeselectricstuff Apr 14 '12 at 9:16
1  
@mikeselectricstuff - 118mW isn't anywhere near the maximum, it's only half the rated value. Why wouldn't it be safe? Why would they rate a resistor at 250mW if even 118mW would be too much? – stevenvh Apr 14 '12 at 9:26
The rated value works the other way round - if you put more than 250 mW into the resistor, it will blow up. It also assumes that you're operating the resistor in a nice cool environment with excellent heat removal. – Optimal Cynic Apr 19 '12 at 6:26
@Optimal - No it won't. Just as an experiment I tried 1/4W resistors at 1W for tens of hours. They didn't fail. – stevenvh Apr 19 '12 at 6:49
@stevenvh: That was pedagogical hyperbole. If you exceed the maximum rating, you are essentially voiding the manufacturer's guarantee that the resistor will be X ohms +/- Y%. It could also explode in a spectacular fireball and your colleagues will say "Well, it's your own silly fault". The real point is that it's extremely bad engineering practice to run a component too close to its maximum rating. – Optimal Cynic Apr 19 '12 at 21:29

Rectify line voltage with Diode , Cap and then use zener in series with opto input so voltage range max to zener / input current determines R. Then find worst case CTR ( current transfer ratio) and load threshold voltage. to ensure load current will drive the appropriate logic level. Tolerances are poor though.and consider Zener diodes around 100V or whatever you consider near a drop out.

share|improve this answer
It's 118V DC, so the rectifier isn't needed. The zener isn't required either: the resistor will take the difference between the 118V and the LED voltage. – Federico Russo Apr 14 '12 at 8:31
Federico, pls ignore my diode rectifier, but re-think my other comments, they are critical to the solution. – Tony Stewart Apr 16 '12 at 12:30
A detector requires high gain, or at least a discriminator threshold for low voltage. Since opto isolators have poor gain control, you have two simple choices 1) use a zener to block the input current below threshold 2) use a resistive divider to scale the threshold say 100V down to 1.2V or the input diode voltage and waste a lot of power. CTR is a major factor for worst case variation on the threshold in 2) If you agree add points for significance in a passive solution. – Tony Stewart Apr 16 '12 at 12:38
2  
It's exactly the calculation of those resistors that OP ask about! – Federico Russo Apr 16 '12 at 14:19
1  
As I understand it it's either 118V or 0V at the input. Then the threshold created by the zener is unnecessary. – Federico Russo Apr 16 '12 at 14:22
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.