Capacitor discharging.
If you are using capacitors (like X2) in the supply mains (e.x. 230VAC/50Hz) or elsewhere, there might be a need for a resistor to make a controlled discharge the capacitors. This resistor is typically called a bleeder resistor.
The following formulas describe the Voltage over the capacitor (Vc) and the current through it (Ic).
$$Vc=V\times e^{-t/Tau}$$
$$Ic=-V\times R\times e^{-t/Tau}$$
Vc: Capacitor voltage.
V: Start voltage on capacitor.
Ic: Capacitor current.
R: Resistor.
τ: Tau is the time constant τ = R x C in seconds.
t: time in seconds from V to Vc.
A = Charging curve for the capacitor and B = discharging curve for the capaciter.
By rewriting the formulas we get:
$$t=-ln (\frac{Vc}{V})\times R\times C$$
$$R=\frac{t}{-ln (\frac{Vc}{V})\times C}$$
Here is a example of calculating the bleeder resistor for discharging.
When disconnecting the main supply, the voltage over the capacitors can be very high. If disconnecting at the top of a of the 50 hertz sinus the max. voltage (starting voltage Vstart) will be 253V x √2 = 360V. This voltage need to be discharged to about 60V (End voltage Vend) within max. 0,75 second. Let us say C = 1,32uF in this case.
We want to discharge the capacitor to 60V in max 0,75s. by using the formula above:
$$R=\frac{t}{-ln (\frac{Vc}{V})\times C}= \frac{0,75}{-ln (\frac{60}{360})\times 1,32u}=317Kohm$$
I choose 220K
Remember to calculate the power in the resister, when it’s not discharging:
$$P=U*I=\frac{U^{2}}{R} =\frac{230^{2}}{220Kohm}=0,24W$$
So use at least a 1W resistor.