4

I've wrote a small piece of code that reads the current battery charge/discharge on my laptop. I followed the example code on this MSDN page.

My program updates the information every 100ms (by calling the DeviceIoControl function with IOCTL_BATTERY_QUERY_STATUS as control code) but the read value changes only after 5-10 seconds. For example if I change the screen brightness from the minimum value to the maximum the rate is updated only 5-10 seconds later. I've used Visual C++ 2010 on Windows 7 32-bit.

Does anybody knows how to get a real-time reading of the charge/discharge rate?

user472507
  • 75
  • 1
  • 4
  • Why do you think it is not correct? Th delay could be because of buffering of charge somewhere in the hardware (some capacitor) and it only causes larger draw on the battery when this charge is depleted. – Martin York Oct 11 '10 at 18:12
  • The values that I get are correct, I was asking a way (if there is one) to see these changes sooner. I don't think that there is a capacitor because with an increase of power consumption of 20W the delay is about 8 seconds, this would require a very big capacitor! – user472507 Oct 11 '10 at 19:09

1 Answers1

4

Depending on the accuracy of the sensor, it is likely that the status is only updated by the power device driver every 5-10 seconds or when significant changes take place.

Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
  • 3
    A relatively recent blog post ( http://blogs.msdn.com/b/oldnewthing/archive/2010/09/24/10067119.aspx ) by Raymond Chen seems relevant even though it happens to be in the context of a different API call: "These battery levels come from the hardware itself, so you are at the mercy of whoever manufactured your motherboard. Some laptops update the values at 1-second intervals; others can take 5 seconds or more." – TheUndeadFish Oct 11 '10 at 19:42
  • I run the program on another laptop and there I get updates every 2-4 seconds. I've also discovered that some new HP laptop doesn't have that sensor. – user472507 Oct 12 '10 at 14:14