This circuit is from the 1972 RCA Linear Integrated Circuits Manual, but it can be made based on more modern comparators and the optical coupler can also be of a more common type today. The power source voltage is 5 V.