Transformerless PSU for PIC

Including mains INTE IRQ source

!!!!!!!!! Use an isolating transformer when working on or testing mains circuits !!!!!!!!!

WARNING - In transformerless circuits such as this one ALL components including the equipment powered should be treated as being at full mains voltage at all times. While the output circuit is designed to be nominally at earth potential, changes in the manner of connection or incorrectly wired mains power outlets may result in the whole circuit being "live". Failure to treat the circuit as live at all times may result in death

The circuit has components to increase resistance to spikes and surges. Notably the 220 ohm 10W resistor, the 10n 630V caps, and input chokes. An LDO regulator (eg LP2950, Seiko S81250 ) can be substituted for the 78L05. Some LDOs have a 12V max input, so decrease the zener to 9V1. A 5V1 zener with dropper resistor could be used instead of the regulator if you have power enough to spare. 1uF as a mains voltage dropper will pass around 70mA of current at 50Hz. Note that the main dropping cap must be X2 rated. These can be found in discarded switch-mode power supplies, as can the chokes and 630V caps

Height and width of zero-crossing pulses will depend on the opto used, the pull-up resistor and V+
Adding a (weak) pull-up or pull-down to the optotransistor's base may help response time

Note that the zero-crossing point is at the peak of the pulse, but the micro's pin threshold is just before that

The 555 arranged as a 38kHz modulator allows the use of a standard 3-pin IR receiver to strip the data out for the micro

For loads other than simple resistive ones a snubber network may be needed