An apparatus and method for providing electrical energy to an electrical device by deriving the electrical energy from motion of the device. A PWM circuit generates a PWM signal from an n-bit pulse code modulation data. Based on the first and second measurements, a set of parameters is generated.