How to compute capacitor constant current charge/discharge time using Python
You can easily compute the time it takes to charge or discharge a capacitor using constant current using the UliEngineering Python library:
from UliEngineering.Electronics.Capacitors import *
from UliEngineering.EngineerIO import *
# Compute the discharge of a 1nF storage capacitor connected to
# a LM324 opamp (maximum I_B=50nA), to 2.999V
discharge_time = capacitor_constant_current_discharge_time(
capacitance="10nF", current="10nA", initial_voltage="3.0V", target_voltage="2.999V"
)
# Auto-format & print discharge_time
print(f"Discharge time: {format_value(discharge_time, 's')}")