Start debugging the circuit point to point, checking measured value against expected value. Since it implements a cut/saturation logic, it is easy to confirm if some node is close to Vcc or GND, as you switch Vin from 5v to 0v. BTW, is U1 really necessary ? I would inject the signal accross R1 directly on the pin U2:1.could be the problem?
Oh yes. I didn't see that. Good point.R3 is required to absorb leakage to prevent Q1 from turning on when opto is off.
Okay.Yeah, it is the strange behavior. any other insights. Relay coil resistance is around 1k, measured resistance across the coil.
Possible reasons have been already mentioned. Generally, it's possible due to high opto coupler current gain and noise superimposed to the power supply or opto common mode voltage. Optimal solution would be a RC filter and relays driver with hysteresis.I do not quite understand why relay should chatter, when input is driven low?
With this I guess you're referring to contact bounce which is a normal thing for electromechanical relays and occur as a result of the impact of their collision and is more of a transient response, and dies out with time. This is often taken care of by connecting an RC snubber across the contacts just like FvM mentioned....
I do not quite understand why relay should chatter, when input is driven low?
The situation is much clearer now.Observation. When IN is connected to gnd, relay chatters. When IN is connected to 5V, relay gets properly energized and switches ON.