ABSTRACT

In this chapter, the authors measure the unknown capacitance of a capacitor by first charging it, then turning off the charging supply and discharging through a parallel resistor, while repeatedly measuring the voltage drop across the capacitor. Thus, from linear least-squares fit to the logarithm of the voltage, they can determine the time constant, and from the known resistor value, also the unknown capacitance. The data samples are stored in the sample_buffer once every timestep milliseconds. The authors also declare the resistance of the resistor used to discharge the capacitor. They include the MsTimer2.h header file and library, which provides the functionality to repeatedly call a function without user intervention. The MsTimer2.h listens to an internal clock and then calls the function after the specified time interval has elapsed. The function it calls is normally referred to as the interrupt-service routine, and it is called timer_action() in readers sketch.