Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Devices /
Chapter 6 - Power Manager / Power Manager Reference
Power Manager Routines / Reading the Status of the Battery and the Battery Charger


BatteryStatus

You can use the BatteryStatus function to get information about the state of the internal battery.

FUNCTION BatteryStatus (VAR Status: Byte; VAR Power: Byte): OSErr;
Status
On exit, a byte value whose bits encode information about the current state of the battery charger. See the description below for the meaning of each bit.
Power
On exit, a byte whose value indicates the current level of the battery voltage. See the description below for a method of calculating the voltage from this value.
DESCRIPTION
The BatteryStatus function returns the status of the battery charger (in the Status parameter) and the voltage level of the battery (in the Power parameter).

Bits 0 through 5 of the Status parameter encode information about the state of the battery charger. (Currently, bits 6 and 7 are reserved.) The Power Manager recognizes the following constants for specifying bits in the Status parameter.

CONST
   chargerConnBit          = 0;     {1 if charger is connected}
   hiChargeBit             = 1;     {1 if charging at hicharge rate}
   chargeOverFlowBit       = 2;     {1 if hicharge counter has overflowed}
   batteryDeadBit          = 3;     {always 0}
   batteryLowBit           = 4;     {1 if battery is low}
   connChangedBit          = 5;     {1 if charger connection has changed}
Constant descriptions

chargerConnBit
The charger is or is not connected. If this bit is set, the battery charger is connected to the computer.
hiChargeBit
The charge rate. If this bit is set, the battery is charging at the hicharge rate.
chargeOverFlowBit
The hicharge counter overflow. If this bit is set, the hicharge counter has overflowed. When the hicharge counter has overflowed, it indicates that the charging circuit is having trouble charging the battery.
batteryDeadBit
The dead battery indicator. This bit is always 0, because the Power Manager automatically shuts the system down when the battery voltage drops below a preset level.
batteryLowBit
The battery warning. If this bit is set, the battery voltage has dropped below the value set in parameter RAM. The power management hardware sends an interrupt to the CPU once every second when battery voltage is low.
connChangedBit
The charger connection has or has not changed state. If this bit is set, the charger has been recently connected or disconnected.
The Power Manager also defines these bit masks:

CONST
   chargerConnMask         = $1;    {charger is connected}
   hiChargeMask            = $2;    {charging at hicharge rate}
   chargeOverFlowMask      = $4;    {hicharge counter has overflowed}
   batteryDeadMask         = $8;    {battery is dead}
   batteryLowMask          = $10;   {battery is low}
   connChangedMask         = $20;   {connection has changed}
Due to the nature of lead-acid batteries, the battery power remaining is difficult to measure accurately. Temperature, load, and other factors can alter the measured voltage by 30 percent or more. The Power Manager takes as many of these factors into account as possible, but the voltage measurement can still be in error by up to 10 percent. The measurement is most accurate when the computer has been in the sleep state for at least 30 minutes.

When the battery charger is connected to a portable Macintosh computer with a low battery, the battery is charged at the hicharge rate (1.5 amps) until battery voltage reaches its full charge (7.2 volts on most portable Macintosh computers). The Power Manager has a counter (the hicharge counter) that measures the time required to raise the battery voltage to this level.

After the full charge level is reached, the power management circuits maintain the hicharge connection until the hicharge counter counts down to 0. This ensures that the battery is fully charged. At the end of that time, the power management circuits supply the battery with just enough current to replace the voltage lost through self-discharge.

RESULT CODES
noErr0No error
SEE ALSO
For more functions for determining the status of the battery and battery charger, see "Getting Information About the Internal Batteries," beginning on page 6-54.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996