This is a follow on to my previous two posts Power managment on Beaglebone AM335x platform part 1 and Power management on Beaglebone part 2-Battery for the community IoT BSP at BeagleBone BSP.
The first two parts I discussed the background of battery support and some of the hardware modifications that are needed for the BeagleBone Black platform. I also talked about the AM335x’s on chip analog to digital converter (A/D or ADC) and how it can be used to measure voltage signals like battery voltage. We developed an A/D converter driver and test program and integrated it into the BSP.
The next step in the process is to pull it altogether by developing a battery driver. The battery driver will, of course, be dependent on the A/D driver so we must make sure the A/C driver is loaded first. We can do this by modifying the drivers “Order” setting. For example here are the ADC registry setting:
IF BSP_AM33X_ADC [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\ADC1] "Prefix"="ADC" "Dll"="am33x_adc" "Index"=dword:1 "order"=dword:9 ; Should be loaded before battery or touch ENDIF BSP_AM33X_ADC
And here are the battery drivers:
; @CESYSGEN IF CE_MODULES_BATTDRVR ; @CESYSGEN IF PM_PMSTUBS ! IF BSP_BATTERY
; HIVE BOOT SECTION [HKEY_LOCAL_MACHINE\System\Events] "SYSTEM/BatteryAPIsReady"="Battery Interface APIs" ; END HIVE BOOT SECTION [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery] "Prefix"="BAT" "Dll"="battdrvr.dll" "Flags"=dword:8 ; DEVFLAGS_NAKEDENTRIES "Index"=dword:1 "Order"=dword:13 "Ioctl"=dword:290418 ; IOCTL to use for PostInit callback ; "PollInterval"=dword:7d0 ; Battery poll interval (ms) ..default 5 sec if not specified ; "BatADCchannel"=dword:6 ; CHANNEL_6 ..default if not specified "BatHigh"=dword:dac ; 3500 mv "BatLow"=dword:d48 ; 3400 "IClass"="{DD176277-CD34-4980-91EE-67DBEF3D8913}" ; WM7 only BATTERY_DRIVER_CLASS
; do not show low battery dialog ;[HKEY_LOCAL_MACHINE\Software\Microsoft\Power] ; "ShowWarnings"= dword:0
; @CESYSGEN IF PM_PM_DEFAULT_PDD [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\Timeouts] "ACUserIdle"=dword:0 ; in seconds "ACSystemIdle"=dword:0 ; in seconds "ACSuspend"=dword:0 ; in seconds "BattUserIdle"=dword:0 ; in seconds "BattSystemIdle"=dword:0 ; in seconds "BattSuspend"=dword:0 ; in seconds
; Make sure the system power management thread runs at a higher priority than ; driver ISTs (PWRKEY) that may call SetSystemPowerState(). This is to avoid race conditions ; between the PM and drivers or applications that may want to update the system power ; state. Most drivers don't run above THREAD_PRIORITY_HIGHEST (249); if any that ; might call SetSystemPowerState() have a higher priority than this, adjust ; the PM's SystemPriority256 value accordingly. ; [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power] "SystemPriority256"=dword:F8 ; 248 - THREAD_PRIORITY_TIME_CRITICAL ; @CESYSGEN ENDIF PM_PM_DEFAULT_PDD
ENDIF BSP_BATTERY ; @CESYSGEN ENDIF PM_PMSTUBS ! ; @CESYSGEN ENDIF CE_MODULES_BATTDRVR
We can also set different timeouts, based on state as you can see.
You can down load the source from the Codeplex site and study the actual implementation.
When done correctly the UI shell in WEC2013 or the taskbar in WEC7 should look like the following depending on battery state.
WEC2013 running on battery:
WEC2013 charging:
WEC2013 fully charged AC still plugged in:
WEC2013 AC only, no battery:
And the equivalent WEC7 taskbar icons:
Charging:
Running on AC:
WEC7 Control Panel power status:
I also wrote a simple managed (C#) test program which shows the charger status and measured system voltages:
Re: Windows Embedded Compact 2013 on Beaglebone gets IoT sample
Please contact me regarding a full installation of this BSP for WINCE2013, and what is necessary for...
-- Aaron Peterson
Re: BeagleBone BSP code clean up
Hi David, Interest in the fully version of the image. Please let me know the commercials. I need clarification...
-- CB
Re: BeagleBone BSP gets several improvements
Hi David, How can I get a full version (without reboot) of your image available for demonstration?
-- Marco Aurélio Braun
Re: Low power operation on the community IoT Beaglebone BSP (Part 1)
Hello , dvescovi . Because of Job , I use your Beaglebone black BSP which is helpful for me . I want...
-- KevinHsu
Re: Yet Another Gotcha: Compact 7 Update
Hi David, Would you please contact me regarding the wince7 BSP for the BBB? I have a few LCD Capes...
-- trialsrideraz
Seems MS may have posed a new updated ISO on MSDN. For those without a subscription, you are still out...
-- dvescovi
Re: Power management on the Beaglebone part 2–Battery
Hi David, First of all thanks for this, blog it's been very useful. Before I go ahead and solder anything...
-- Juanes1220
Re: More improvements for Beaglebone BSP
Thank you for the fixes. The latest version builds under WEC7! Yay! Next .. have to try deploying it...
-- OzFlipper
Of course, I meant the WEC2013 SDK ... see what happens when you work with too many bits at the same...
Hi David. First, thank you for what must have been a huge amount of work. I have been trying to install...