Im trying to design a control circuit for charge a battery, for this i will be controlling the battery charge by a 40tps ( SCR ), phase control. So my little understanding for what i read is that i need a zero crossing detector, so i can send the pwm signal in the phase that i want. I searched and find this circuit, that i think that maybe works, i want to know what you think and if you will change something. Im using a pic16f15223, i not decided what optocoupler i will use yet. I was thinking about a pc817 because is cheap and i dont need anything more. ( i know that in the circuit the optocoupler used has a triac output, its only the schematic ). This circuit teorically will be always turning the emitter from the optocoupler ON, so the R2 its always connected to GND, therefore, the input low. When the signal crosses 0, the emitter turns off, and accordingly the R2 connects to VCC, so input high. I saw also circuits with transistors instead of optocouplers, im new in this so i want your opinion! Thanks in advance!!! (U1 its a Bridge Rectifier) enter image description here


1 Answer 1


Your optocoupler is connected to the rectified and filtered DC output of the bridge rectifier, and it will never have a zero crossing. Put the opto and resistor on the 9 VAC input, and connect a diode in anti-parallel across the input of the opto to avoid reverse biasing the LED. There will be some delay between the zero crossing and the logic level transition.

Here is a simulation showing about 1 ms delay on rising zero-crossing:

ZC detector

You might add a capacitor across the resistor to get a leading phase angle, which can reduce the delay to about 200 us:

ZC detector with capacitor

  • \$\begingroup\$ Oh, right, the circuit i saw the circuit without the filter capacitor... So if i want to make the circuit that you propose, the R1 will be [ Vin( of the transformer)-Ve(emitter) ] / Ie(current of emitter). and what value of the capacitor i should use? and the diode can i put a 1n4007 or i need a fast response one? Thanks \$\endgroup\$ Commented May 20, 2023 at 14:52
  • \$\begingroup\$ Ordinary 1N4001 diodes would be fine, but consider 1N5817 Schottky so you won't lose so much voltage in the bridge, but if the DC voltage is at least 7 V for the 5 V regulator, you might as well lose the extra voltage in the bridge instead of heating up the 7805. The resistor should provide about 2-5 mA for the opto, so 1k is about right. You can try different values for the phase shifting capacitor, but be aware that higher values will drive more current, and possibly harmful spikes if the AC input is noisy, so perhaps a 47 ohm in series would be wise. \$\endgroup\$
    – PStechPaul
    Commented May 20, 2023 at 21:43
  • \$\begingroup\$ I understand... The input voltage is not a problem, i can put whatever i want, so i will choose like 8v, like that i think that will function properly... I posted the "final circuit" in the post, i think thats what you mean when you said a 47 Ohm resistor in series. So i was thinking about a 47 ohm resistor and a 1uF capacitor, what do you think? Thank you for your help! \$\endgroup\$ Commented May 22, 2023 at 1:28
  • 1
    \$\begingroup\$ (continued) Your edit of your question to replace the schematic, is also the wrong etiquette here, since there was already an answer - this one - responding to the original (now missing) schematic. Instead, either respond using the technique linked above, in a comment with linked new schematic, asking for advice on it (but only this site member is likely to see it) or add a newer schematic into the question (so it's seen by everyone), explain what you have changed and why, and then leave a comment here asking for advice. || Evolving questions don't fit Stack Exchange very well :( \$\endgroup\$
    – SamGibson
    Commented May 22, 2023 at 3:51
  • 1
    \$\begingroup\$ @SamGibson Sorry, i'm new in this, i will try to make it better for next time! \$\endgroup\$ Commented Jun 6, 2023 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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