# measuring frequency with opto-isolator

I have a circuit where 220VAC mains is stepped down by transformer to 48V and through an 5k1 resistor I'm activating optocoupler that drives a LED through a resistor on the other side. I am measuring frequency at this side and when I use one-diode optocoupler I see 50Hz which I expect.

schema:

scope:

now, when I replace the optocoupler with the one that has another diode in the reverse to the first one in it:

I would expect to get double frequency, becouse as my thinking goes, the transistor gets activated twice as much.

so as you can see, it's still 50Hz. a even tried to hook it on the arduino and count for trigering the interruption, I get 50 in both cases. and that's what I don't get. in this case I' using H11AA1 opto-coupler module. EDIT: as advised I put pullup resistor over LED terminals to compensate it's forward voltage drop and signal gets readable and 100Hz-ish!

can you explain what going on here, where I make an error in my estimations or measurements?

thank you! EDIT: adding full diode bridge before optocoupler is really getting me to 100Hz altho...would be nicer to have it simpler. the signal that I measure is still kind of strange to me; I wouldn't say it's doubled 50Hz:

• yes it is, it's just badly put in the schematic tho Jul 12 at 17:20

At the bottom end of the LED you are measuring 3.3V - LED forward voltage. You need a resistor that pulls up to 3.3V. Now measure from C to E of the isolator.

• that was the piece needed; now it's 100Hz. thank you! scope shot added to the question Jul 12 at 17:52

You will get almost no output from it since your LED is reverse biased. Look at the direction of the NPN arrow and the LED arrow.

Not what you asked, but if you want to use bog standard optocouplers but need to trigger on each zero crossing, you may get by with just a diode bridge before your optocoupler.

• thanks for commenting; if you meat D1 on my schematics, it was just badly drawn; i have corrected it in question Jul 12 at 17:54

That null-comparator should have little bit more complicated high voltage side circuit because of big variation of input current. There is a minimum current to open transistor and maximum, restricted by optocoupler max parameters. For instance, two resistors in series and two zenners in series, connected between two resistors and another AC input, voltage restriction on optocoupler input. Or PTC in series with input. But if you do not need to get impulse close to zero crossing, just decrease the resistor value. Difference in your two schematics is optocouplers, they may have different transfer ratio.

• thank you for input, can you suggest values for additional components please? Jul 12 at 17:55