Friday, 11 August 2017

schematics - Would this lazy zero cross detector work?


Task: Design a ZCD for 230VAC to be interfaced to an atmega168, 5VDC.



enter image description here


The pictured optocoupler is SFH620A-3. I have on hand 1/4W E24 resistors. I am extremely lazy and want to go away with as little soldering as possible (thank God the opto has only four leads).


Let's suppose the line voltage varies from V_{min} = 200VAC to V_{max} = 250VAC rms.


$$ P_{input resistors} = \frac{V_{max}^2}{R_1 + R_2}$$ $$ R_1 + R_2 \geq \frac{V_{max}^2}{P_{input resistors, max}} = \frac{250^2}{0.25+0.25} = 125Kohm$$


We select R1 = R2 = 68Kohm. $$ i_{in, min} = \frac{V_{min} - 1.65}{2 * R_1 *1.05} = \frac{198.35V}{142.8Kohm} = 1.39mA$$


From here on, using these or these calculations, we select 10Kohm or 15kohm for the output resistor.


Conclusion: minimum component count and price, borderline reliability, should work for a couple of years at least.


Would the schematic work? Would it be reliable for a couple of years of constant operation?




The output stage:



$$ i_C \geq i_{in, min} * CTR_{min} \approx 1.39 mA * 0.34 \approx 0.47mA $$


atmega168, page 302


$$ i_{leakage} \leq 1uA $$ $$ V_{IL} = 0.3 Vcc = 0.3 * 5V = 1.5V $$ $$ V_{IH} = 0.6 Vcc = 0.3 * 5V = 3V $$


If we strive to be below 1V for logic zero: $$ i_C * R_{output} = 1V $$ $$ R_{output} = 1V / 0.47mA = 2.13Kohm$$


We select 2.4Kohm.




EDIT: implemented and tested. The input resistors get warm, but not hot.


enter image description here



Answer



Make sure your resistors are rated for the voltage you are applying. Some resistors are only rated at 100V peak so watch this one.



With a total LED resistance of 125 kohm and the specified input capacitance of 50pF you are going to get a basic time error of 6 us - this is equivalent to a low pass filter at the input of fc 25 kHz.


As for the output stage of the opto-coupler, if you use a collector resistor of 75 ohms you might get another delay of about 5 us (turn on time + rise time or turn off time + fall time). In total you might be looking at a total time error of about 11 us.


With a 2k resistor in the collector the delay/rise/fall times are going to extend significantly in proportion to 2k/0.075k i.e. increase maybe 27 times so this takes you to a time-error of 6 us + 27*5 us = 141 us.


You haven't specified what supply you are running the collector resistor at. If 5V then the figures above stand but if 3v3 you could add another 20 to 30% time delay. Read the data sheet - it's got the information in there and I've tried to make the best use of this information in my answer although I was disappointed that the data sheet didn't contain more information on rise/fall times.


BTW 141 us represents a phase error in 50 Hz of about 2.54 degrees. Is this acceptable?


Bear also in mind that the opto's delay/rise/fall times are specified when the device is NOT in saturation. If the transistor goes into saturation you will find the time errors are significantly increased (i.e. doubled or tripled). To avoid saturation you have to use a low value collector resistor and ensure that the current driven into the LED does not produce an output voltage that goes much below 1V on the collector (maybe limited at 0.5 volts). If the timing is critical then you will have to abide by this and maybe use a comparator after the opto to produce a decent logic signal. Opto's can be a bit tricky!


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...