In the scheme presented here, judicious use of three single-pole double-throw (SPDT) switches not only compensates for lead resistances but also ensures that discharge happens through a single microcontroller pin in every discharge cycle, thus eliminating the effects due to mismatch in the resistances of port pins.