How to calculate the charge and discharge frequency of a capacitor