Contribute
Register

x220 Lenovo AppleSmartBatteryManager DSDT

Joined
Feb 22, 2013
Messages
21
Motherboard
lenovo x220
CPU
i5
Graphics
hd3000
Mac
Classic Mac
Mobile Phone
hello, 62,17 Wh is my battery designed capacity and my full charge is 59,12 Wh

right now it says that is 79% (in windows is 89%) , maybe the all values of capacity reading is wrong by 10%?

with ioreg its correct to show 79% with these values , but are they correct?

ioreg -n AppleSmartBattery -r AppleSmartBattery | grep -y capacity
"MaxCapacity" = 5366
"CurrentCapacity" = 4251
"LegacyBatteryInfo" = {"Amperage"=0,"Flags"=5,"Capacity"=5366,"Current"=4251,"Voltage"=12507,"Cycle Count"=39}
"DesignCapacity" = 5600
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
190,989
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
MacBook Air
Mobile Phone
iOS
hello, 62,17 Wh is my battery designed capacity and my full charge is 59,12 Wh
Not sure where you got those numbers from, but they *do* correlate (close) with the mA displayed in your ioreg output.
Your battery is 5% degraded then (eg. able to reach .95 of its original capacity)

right now it says that is 79% (in windows is 89%) , maybe the all values of capacity reading is wrong by 10%?

with ioreg its correct to show 79% with these values , but are they correct?

ioreg -n AppleSmartBattery -r AppleSmartBattery | grep -y capacity
"MaxCapacity" = 5366
"CurrentCapacity" = 4251
"LegacyBatteryInfo" = {"Amperage"=0,"Flags"=5,"Capacity"=5366,"Current"=4251,"Voltage"=12507,"Cycle Count"=39}
"DesignCapacity" = 5600
I guess OS X displays percentage as CurrentCapacity/MaxCapacity (I never knew because with my battery MaxCapacity still is equal to DesignCapacity -- no degradation yet). Because 4251/5366 == .79. I don't know how Windows can come up with 89% assuming it is seeing the same numbers.

You might want to add some debug output (if you have the ability) to the battery manager, because it could be that there is a problem converting from watts -> amps (if your DSDT reports in watts)?? Most DSDTs report battery information in amps, not watts, so the code to convert hasn't been well tested... It would be nice to see the raw data coming from DSDT before watts -> amps conversion.

But given the data displayed there in ioreg, I don't see anything wrong... Your batter is currently charged at 79% of max capacity, has degraded 5% of design capacity, and is charged at 75% of design capacity. Math doesn't lie.
 
Joined
Feb 22, 2013
Messages
21
Motherboard
lenovo x220
CPU
i5
Graphics
hd3000
Mac
Classic Mac
Mobile Phone
so the display of 79% is right then :) , i got Wh from lenovo battery manager in win, you have the option there to tell the battery when to start charging (i have it below 40%) and when to stop (i have it at 90%) . These orders are kept in battery memory, and when i switch to osx it does the same, only stops and shows 79% instead of 89 or 90% but it isnt much of a problem just confusing when you see it first time , thank you for explanation i didnt knew that either , its not that its totally wrong.
 
Joined
Feb 22, 2013
Messages
21
Motherboard
lenovo x220
CPU
i5
Graphics
hd3000
Mac
Classic Mac
Mobile Phone
RehabMan if you want and can tell me how, i can add debug output , i'll try :)
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
190,989
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
MacBook Air
Mobile Phone
iOS
RehabMan if you want and can tell me how, i can add debug output , i'll try :)
Depends on how much dev experience you have...

If you install the debug version (the one that is already built for you), you'll get more information. Including whether or not your DSDT is reporting in watts or amps. But for some reason, debug output for _BIF method was never added which might be useful.

Can you build my kext using Xcode? If so, I'll be glad to add some extra debug info and push it to github... Actually... I already did (add the debug info). So, if you can build my project from sources, you can try it.
 
Joined
Feb 22, 2013
Messages
21
Motherboard
lenovo x220
CPU
i5
Graphics
hd3000
Mac
Classic Mac
Mobile Phone
ok i dont have much experience but had done some pascal programming when i was a kid :p , i dont mind to learn again some things... now i have got the git of OS-X-ACPI-Battery-Driver and execute make , inside build/debug dir is the kext you want me to install? then what?
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
190,989
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
MacBook Air
Mobile Phone
iOS
ok i dont have much experience but had done some pascal programming when i was a kid :p , i dont mind to learn again some things... now i have got the git of OS-X-ACPI-Battery-Driver and execute make , inside build/debug dir is the kext you want me to install? then what?
Install the debug kext using Kext Wizard (or if you have xcode command line tools installed, you can just type 'make install' from terminal...)

Then, reboot.

Then run Console.app and view system.log. You will see the debug output from the battery manager as it calls the methods in the DSDT (approx every 30 seconds). So, you see the data coming straight from DSDT before being converted into something OS X likes to see in ioreg...
 
Joined
Feb 22, 2013
Messages
21
Motherboard
lenovo x220
CPU
i5
Graphics
hd3000
Mac
Classic Mac
Mobile Phone
from console (like i said i have the battery not charge beyond 90%) (is there any command to start/stop the logging at will?)

3/26/13 11:38:56.000 PM kernel[0]: AppleSmartBattery::constructAppleSerialNumber called
3/26/13 11:38:56.000 PM kernel[0]: AppleSmartBattery::rebuildLegacyIOBatteryInfo called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::pollingTimeOut called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x2
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x1
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatterySTA called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatterySTA: battery_status = 0x1f
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatteryBIF called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatteryBIF: validateObject return 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: acpibat_bif size = 13
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fPowerUnit = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fDesignCapacity = 0xf2d0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fMaxCapacity = 0xe8b2
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fBatteryTech = 0x1
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fDesignVoltage = 0x2b5c
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fCapacityWarning = 0xba2
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fLowWarning = 0xc8
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fDeviceName = 'MODEL-1234'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fSerialNumber = '24427'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fType = 'LIon'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fManufacturer = 'Lenovo'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatteryBST called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0xcfa8
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage = 0x30e0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: Calculating for WATTS
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 4248
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: adjusted fCurrentRate = 0xa7b
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0xa7b
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery: Battery is charged.
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
190,989
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
MacBook Air
Mobile Phone
iOS
from console (like i said i have the battery not charge beyond 90%) (is there any command to start/stop the logging at will?)

3/26/13 11:38:56.000 PM kernel[0]: AppleSmartBattery::constructAppleSerialNumber called
3/26/13 11:38:56.000 PM kernel[0]: AppleSmartBattery::rebuildLegacyIOBatteryInfo called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::pollingTimeOut called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x2
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x1
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatterySTA called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatterySTA: battery_status = 0x1f
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatteryBIF called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatteryBIF: validateObject return 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: acpibat_bif size = 13
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fPowerUnit = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fDesignCapacity = 0xf2d0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fMaxCapacity = 0xe8b2
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fBatteryTech = 0x1
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fDesignVoltage = 0x2b5c
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fCapacityWarning = 0xba2
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fLowWarning = 0xc8
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fDeviceName = 'MODEL-1234'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fSerialNumber = '24427'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fType = 'LIon'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBIF: fManufacturer = 'Lenovo'
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBatteryManager::getBatteryBST called
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0x0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0xcfa8
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage = 0x30e0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: Calculating for WATTS
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 4248
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: adjusted fCurrentRate = 0xa7b
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0xa7b
3/26/13 11:39:26.000 PM kernel[0]: AppleSmartBattery: Battery is charged.
Well, you can see there it is calculating for watts. So, now is the time for you to get your calculator out and start trying to make sense of the numbers. Numbers that are 0x are hex so you need to convert to decimal.

And in the above scenario you can tell that your DSDT is saying your battery is not charging (currentStatus = 0x0). If it was charging you'd see status at 2, and discharging status 1.
 
Joined
Feb 22, 2013
Messages
21
Motherboard
lenovo x220
CPU
i5
Graphics
hd3000
Mac
Classic Mac
Mobile Phone
the data is correct , it seems in windows (lenovo battery manager) there is a factory capacity value (new battery) just for info, and these values are the same based on current battery wear fDesignCapacity = fMaxCapacity like you said...
how your battery has no wear ? :) anyway ok if we want the % to display like windows there must be other calculation in smartbattery manager.
maybe an option for the future?



 
Top