Calculating Dropper resistors for Opto on Mains - Page 1
Forum section: electronics / projects

author: kolbep
author_rank: Frequent Contributor
timestamp: May 18, 2015, 06:34:23 pm
content: Good Day All.I have changed the optocoupler I am using on my Generator Controller.I am now going to use a SFH6206-3 (http://www.vishay.com/docs/83675/sfh620a.pdf), which is a high CTR, 4 Pin SMD Package, with Back to Back LED Diodes for ACI want to use it to detect 230vac mains and feed it into my PIC.The circuit I intend to use is attached.I am trying to work out what resistors I will need on each side of the opto.If I take the worst case of 250vac,IF of 60MAVf of 1.25V,then the resistors should beR=Vt-Vf/IR=(250-1.25)/0.06AR=4145.8 OhmsR10~2.2KR11~2.2KNow I need to work out the Power Rating for the Resistors.Pr=Vr(sq)/RPr=14WattsDoes that mean that I can use 2x7 watt resistors (minimum) in series??Or am I driving this too hard. What does the high CTR (Min 34%, Typ 70%) mean. does it mean that I can run the input to the LEDs at say 30mA, then I can use say 2 x 4.7K Resistors, with a power rating of 4W Each?Or can I go even higher with the primary resistances, and lower the power resistors that I need even more.With all this trying to work out I feel likeRunning around in circlesOh, and the output side of the circuit basically keeps the pin pulled low. When there is a mains waveform present, it gives a sawtooth waveform to the Microcontroller pin (always above the threshold of the pin).If I wanted, is it ok to remove the cap and its resistor, and then the pic will then get a positive sinewave input at 100hz, which I can then monitor line frequency, etc? I know I am being stupid by asking this, but it cant do any harm to the pic having the 100hz from this continuously 24/7/365 (if I did remove the cap)? I already know that answer is that it won't do any damage....P

author: ajb
author_rank: Super Contributor
timestamp: May 19, 2015, 04:09:46 am
content: CTR is the ratio of LED current to phototransistor current. Essentially it's the gain of the optocoupler. 70% isn't actually much to write home about, photodarlington devices can hit 500% or more.Remember that 250V is the RMS voltage, peak voltage will be closer to 350V. So if you size your resistor for 60mA at 250V, peak current through the LED will be 85mA. And in any case, 60mA is the absolute maximum rating of the optocoupler. You should never design for absolute maximums under normal conditions; it leaves you no margin for error.What you need to figure out is how low you can make the nominal current through the LED while maintaining reliable detection over your operating conditions. Since you're only driving a logic level input to a microcontroller, you can minimize the output current requirement. I'd make R13 50-100K to start, and C10 something like 10nF. Now you only need a few dozen microamps to pull up against R13, so if you have an opto with a CTR of 50% you only need a milliamp or so of LED current. Since you're only trying to detect the presence or absence of mains, you don't really care how much of each AC half cycle the opto conducts for, so you can aim to hit your target current at something like Vpeak/2, or around 175V for 250Vrms. That means you need 175V/0.001A = 175K, and the resistor will dissipate only 250Vrms2/175000 = .357W under normal conditions. You also have only 2mA peak through the LED, giving you margin for a 30X line voltage transient before you hit absolute max current.That said, you'll need to take a look at the CTR graphs for your optocoupler and do some testing to ensure that you'll be able to have reliable detection over your required operating conditions--in particular temperature.Now if you were doing something like zero cross detection for phase angle dimming, you'd likely want to be a bit more careful with the design since timing skew and spurious triggers would be much more problematic, but the bottom line is that for a logic input you don't need nearly the amount of current you're trying to put through that LED.

author: ajb
author_rank: Super Contributor
timestamp: May 19, 2015, 04:24:36 am
content: Also, 14W is a shitload of power to dissipate on a PCB. For perspective, I have a couple of Lightronics dimmer packs here for repair. These can have one or two mains inputs, and the control electronics do zero cross detection on the primary phase via the low voltage transformer that also powers the controls, which is a handy way to do it, if your device has to be line-powered anyway. The secondary phase, however, is detected directly via a 10K 5W resistor, which on our 120VAC mains dissipates 1.44W. Note that the two PCBs in the picture have become well toasted after ~25 years of such service--and on our 120VAC mains, that resistor's only been dissipating 1.44W!The dimmers are actually pretty interesting, since they predate DMX they use a variant of Microplex, which was a self-clocked addressable analog multiplex protocol, so the whole board is analog with a couple of 4000 series parts for address decoding.

author: kolbep
author_rank: Frequent Contributor
timestamp: May 19, 2015, 06:25:49 am
content: The Cap was used to smooth out the waveform, so that the pin only sees a continuous high level when there is a mains input.This design was from an existing Generator Controller (except I am using a different opto), they used 2 of it to detect when mains had failed, as well as when the generator had started giving output (and hence they can drop out the starter motor).Other generator controllers I have read up on, check the frequency of the generator output (ie, it can stop cranking when the output is at 20hz. Then it waits about a second, then continually checks the frequency. If the frequency is 14% above the nominal, or 20% below the nominal, then it shuts down the generator, and gives an alarm.So what I am thinking is that just by eliminating the cap, I can then use a counter in the PIC to count the cycles (not really worried about phase angles, etc), just need to count the cycles, work out the frequency roughly using the PIC's internal oscillator, and do the same thing.I guess the best thing to do, as soon as I receive the OPTO's, is to play around with it (and the Resistor values)....P

author: kolbep
author_rank: Frequent Contributor
timestamp: May 25, 2015, 07:30:23 pm
content: Hi AJBI tried your suggestions, namelyI made R13 100kI left the capacitor off to test (in case I wanted count the pulses to work out roughly what the frequency is)I then put 2 x 150k 1/4 watt in series, and got a decent waveform on the scope.I even went and put 4 x 150k 1/4 watts in series (now 600k 1/4w) and my waveform was still decent (see attached pic)Strange thing is it does not look like the voltage is going all the way to zero [it looks like it goes from 5v down to 1.2v (remember I do not have the capacitor in),Maybe the PIC micro has some capacitance on that pin (or my scope is just not seeing it right),any comments on this??Also, now that I am using 6k, that means that at the current line voltage, I have350v/600000 = 0.58mA (or half a miliamp...)And current through the resistors then is 0.134wIs that fine, or am I pushing the lower limit there.Maybe I should have 2 x 150r in series, so that I can have it at 1.2mAand then the current through the resistors would then be 0.26w, and I can then use 1 watt resistors (or should I rather go 2 watts, just to be safe)Again this is just to detect when the Mains is no longer present, and when the Generator is giving output (and possibly frequency, if I can figure out why the waveform does not go to zero??? If I can sort that, then I can count frequency.My thinking is this:Mains phase etc doesn't really matter, if it drops substantially (basically to zero volts), then the PIC must acknowledge it.If the pic is cranking the generator, it needs to see as soon as the generators alternator is giving off mains, and stop cranking.A nice feature I saw on another generator controller is that it monitors the frequency the generator is giving out. If it is -15%<Nominal>+15% then it must shut down and give an indication of what went wrong. It also stops the cranking (releases the starter motor) as soon as it sees the output frequency of the genset is >40hz.. That is why I am thinking of leaving the caps off, and counting the cycles...Quote from: ajb on May 19, 2015, 04:09:46 am

author: SeanB
author_rank: Super Contributor
timestamp: May 25, 2015, 08:04:51 pm
content: Make R13 10k and it will pull down to 0V better, and as well use 0.5W ( or 0.6W metal film) resistors in the mains side, as they will withstand the spikes that Eskom delights to give on the return of power. The power rating here is irrelevant, as the resistor rating is determined by the voltage, not the power. As well check that the port you are using is not also programmed as a weak pull up as well as an input, as that will add a 100k or so resistor to 5V inside the PIC.

author: SeanB
author_rank: Super Contributor
timestamp: May 25, 2015, 08:13:49 pm
content: Quote from: ajb on May 19, 2015, 04:24:36 amI fixed a 3 phase timer, that uses a similar resistor power supply, using 2 series resistors to drop the 220/400v supply ( you choose the voltage by using a coloured supply wire), which used 5W resistors run at 4W to drop the unwanted voltage. After 10 years or so they had pretty much toasted the board and the DIN rail housing as well, and cooked the supply capacitors as well. When I fixed it I used new capacitors, 1W zener diodes ( as opposed to the original 12V 400mW ones), and I managed to fit 3 10W ceramic resistors in there in place of the 2 5W units, along with dropping the standing current down to barely enough to drive the CMOS timers and drive the TRIAC switch for the relay. This then was only dissipating 3W in total across the 3 resistors, keeping them at barely warm. Been working ever since then, and as it is an obsolete unit ( replacing will mean a new controller and controls) it was well worth the day of reverse engineering the cooked unit and getting new parts, along with replacing the wiring on it that was brittle and cracking.