When designing a power supply it is good to design from 200vac (low line) to 240 or 250 high line. And to design for 50 and 60hz.
60hz increases the current by about 20%
Here is a very strange idea: We were trying to make a supply for 30mA for the relay plus 3.5mA for the micro and IR thing.
Size of the PCB is critical so I want to change the two bigger parts.
I changed things so power to the relay also flows through the micro. So 30mA is all that is needed not 33.5mA.
I changed the 0.68uF cap to 0.47uF to make it smaller.
At first I removed the 220uF cap and things worked BUT a spike on the power line killed the supply!
Then I made the 220uF cap only 22uf and placed a 18V Zener across it. (important)
I made C2 small (25V) and C3 larger (6.3V). R4 is the relay and its current goes through D3 to power the micro.
When the relay is to be off Q2 shorts it out. (no diode is needed)
Q1 is a 1mA current source. probably 0.5mA would work fine.
V2 is the micro.
At low line 50hz D4-18V Zener has not current.
At high line 60hZ D4 eats up the excess current.
In this case, the micro should be run at full speed to help eat up more current. In fact you could add more parts because there is 30mA at 5V that could be used up. R5 is the micro current of about 2.5mA.
This is a very strange design. The goal is to reduce the size of the 220uF cap.
RED trace is the output pin of the micro. (off---on at 150mS---off at 300mS) power goes off at 500mS
BLUE trace is the supply. (12V+5V) Ripple is fine.
GREEN trace is the 5V supply.