Hi,
...another example why a schematic is so important for us to help....
******
There are some issues and confusions...
Audioguru is correct with output current. 6mA is the minimum value given in the datasheet. The typical of 16mA is more relaxed. This may be a problem, but i don´t see this as the main problem.
In my opinion there is a problem with wiring and/or power supply.
Do some tests:
Connect the "minus" of a DVM to the GND pin of the 7812 and leave it there for all further voltage measurements (just to have a fixed point to rely on)
Now adjust pot so that the relay just is NOT switched ON. Please note all the voltage measurements (maybe on the schematic paper)
* measure GND leg of R4
* measure VCC leg of RV2
* Measure Pin3 of LM339
* Measure Pin7 of LM339
* Measure Pin6 of LM339
* Measure Pin1 of LM339
* Measure GND leg of RV2
Now adjust pot so that the relay switches ON, then back so it just is NOT switches OFF.
Please measure all the voltages like before and note it (with another color )
In my eyes two problems can cause your problem:
* either it is the power supply that drops voltage when relay is swtiched ON,
* or a wiring problem causes to raise GND voltage on R4.
**************
Althoug there are no errors in ourircuit, i have some suggestions.
* As audioguru mentioned: there is no need for an optocoupler.
* I personally don´t like the connection of R6, U1 and U2. The voltage on U1-pin1 may change from 1.3V when relay is ON, to 0.3V when relay is OFF. R6 is always powered.
* And i´d more like R7 on the right side of R9.
hope that helps
Klaus