All Forums
 Hardware
 General Hardware, ADSmartIO, Digital I/O and A/Ds
 Monitoring BitsyX battery level
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

masseyi

20 Posts

Posted - 06 Mar 2006 :  10:42:43  Show Profile  Email Poster
Hi,

Is is possible to progmatically check the battery level and notify the main application when the level is below a certain threshold ? I want my application to respond when the level gets close to zero.

Regards,
Steve

bsamuels

53 Posts

Posted - 06 Mar 2006 :  10:44:40  Show Profile  Email Poster
Hi,

What system are you using?
Go to Top of Page

masseyi

20 Posts

Posted - 06 Mar 2006 :  10:46:43  Show Profile  Email Poster
Hi,

BitsyX on windows CE.
Go to Top of Page

masseyi

20 Posts

Posted - 07 Mar 2006 :  05:37:41  Show Profile  Email Poster
I've found some notification code which handles notifications from RequestPowerNotifications. It uses a message queue, the problem is, this message queue just blocks all the time after I get a PBT_POWERINFOCHANGE message within the queue. Any ideas why this is the case ?

Thanks,
Steve
Go to Top of Page

akidder

1519 Posts

Posted - 07 Mar 2006 :  16:25:44  Show Profile  Email Poster
Thanks for your note.

For battery monitoring, most applications implement a thread that regularly reads the battery voltage. You can do this with very little overhead (e.g. put a Sleep(1000) in the reading loop).

Let us know if you have trouble implementing this.
Go to Top of Page

masseyi

20 Posts

Posted - 08 Mar 2006 :  01:56:03  Show Profile  Email Poster
Hi,
Have you got an example of reading the battery voltage, like I said previously, I used RequestPowerNotifications but my message queue just sits and blocks.

Thanks,
Steve
Go to Top of Page

kurtwl

28 Posts

Posted - 08 Mar 2006 :  03:20:18  Show Profile  Email Poster
GetSystemPowerStatusEx is usefull, which you can check whenever you need.
CeSetUserNotificationEx can be used for the WAKEUP events,
"VDDPWROFF" and "PWROFF" can be caught with CreateEvent.
There is little mileage in waiting for suspend, as the OS is 'off' shortly after that happens.

No idea why your MsgQueue is blocking, are you requesting only one message in MSGQUEUEOPTIONS, and is cbMaxMessage big enough for the stucture to be received?
If you are using one of the WaitFor functions, are you resetting the event?
Go to Top of Page

masseyi

20 Posts

Posted - 08 Mar 2006 :  06:18:07  Show Profile  Email Poster
Thanks for that.

GetSystemPowerStatusEx -> I keep getting an error when calling this, I did try this yesterday, error is something about service not being recognised ?

Using WaitForSingleObject but this doesn't block, just the ReadMsgQueue, in fact, it does eventually come out of the loop after about 2 minutes ?

Allowing three messages in MSGQUEUEOPTIONS structure and cbMaxMessage is the sizeof the structure + 200.

if ( !ReadMsgQueue(hMsgQ, &buf, QUEUE_SIZE, &iBytesInQueue, INFINITE, &dwFlags))
{
}

Thanks again,
Steve
Go to Top of Page

kurtwl

28 Posts

Posted - 08 Mar 2006 :  06:58:56  Show Profile  Email Poster
On the BitsyX system we have, there are 'no' batteries.
Battery power comes in (don't quote me on this) as External DC.
It is either On or Off. Thats it.

We have SuperCaps fitted (to allow some small (ms) time) to panic before the system dies.
A background app loads at startup, and 'guesses' the charge of the supercaps based on a charging constant and time.
It then 'fills' in the power sturucture and updates a 'dummy battery driver'. Any of our applications on the BitsyX can then wait for the Bitsy to power down, check that the 'charge' in the 'battery' is OK for any last minute processing, and decided what to do from there.

Again, don't quote me on this, but in other CE based devices that we have used, the battery can be a pretty clever thing, and can furnish the pwr.dll (bat.dll etc) drivers with information that they require. I think that the OEM is responsible for that driver and interface (using the Microsoft api).

I'm guessing that you are plugging a battery into your bitsy and assuming that the OS will handle the rest?
Go to Top of Page

masseyi

20 Posts

Posted - 08 Mar 2006 :  08:43:18  Show Profile  Email Poster
You guess correct ! Does this mean we need to do write a low level driver ?
Go to Top of Page

kurtwl

28 Posts

Posted - 08 Mar 2006 :  09:07:57  Show Profile  Email Poster
That all depends on your hardware and what you need by the way of battery info etc. As mentioned, I kludged (no, hacked!) together a solution that met our needs.
Go to Top of Page

masseyi

20 Posts

Posted - 10 Mar 2006 :  03:32:21  Show Profile  Email Poster
Hi,
Going to try and hook up to one of the A/D inputs and set an interrupt up on IRQ1 to trigger when the voltage is low, possibly use a comparetor chip which will signal the interrupt when the condition occurs.

This sound like a good idea ?

Regards,
Steve
Go to Top of Page

akidder

1519 Posts

Posted - 10 Mar 2006 :  10:13:07  Show Profile  Email Poster
Hi Steve. For the benefit of other readers, here's what I wrote you earlier today:

Using a level-detecting chip to trigger an interrupt will work fine. It won't give you any information about the state of charge, but you're right that it can serve as a critical-level trigger.

Polling isn't nearly as bad as it sounds, especially in a multi-threaded environment. The overhead is negligible (ADSmartIO takes about 14ms per reading), especially if you're reading it only every couple of seconds, you can track trends over time, and you can send notifications/events to other threads as different states arise. All this with little or no external hardware. It's usually a win-win.

Topic 2057 also includes another response on this topic.

Go to Top of Page

rdall

16 Posts

Posted - 24 Jul 2007 :  18:48:13  Show Profile  Email Poster
Using Bitsy Xb with recent CE Kernel Image version 5.00.32.

We want to power the Bitsy at close to its minimum specified voltage of 5VDC. We find that voltages as low as 9VDC applied to VBATTPOS cause misbehaviour, failure to wake up from sleep or vice-versa.

Is there any way to get around this? Are these behaviours caused by power fail interrupt behaviour or the like?

The main internal rail of the system is 5VDC, so it seems that a DC supply above the input regulator drop out voltage should be able to do the job.

Thanks,

Rick Dall, Senior Electronic Engineer
QRS Diagnostic LLC
Email [removed]
Go to Top of Page

akidder

1519 Posts

Posted - 25 Jul 2007 :  19:48:20  Show Profile  Email Poster
Since this is a bit of a different thread, I've responded at new topic topic 2422.

p.s. I've removed your email address from your last post, as it's too easy for bots to crawl a site and use your address for spam. If you set up your forum user account with a valid email address, other users can contact you if necessary.
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.05 seconds. Snitz Forums 2000