Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => iMX233 => Topic started by: kbenni on January 16, 2014, 02:37:47 PM

Title: Battery management from User space
Post by: kbenni on January 16, 2014, 02:37:47 PM
Hi.
Im developping an application on olinuxino nano. I have problems with battery charging.
How can I get information about battery charging and voltage from user space?
I found that it is possible to configure battery handling in power_prep.c, but how can i acces these functions from program?
thanks
Title: Re: Battery management from User space
Post by: lambda on January 16, 2014, 04:59:48 PM
The battery voltage is available as channel 7 of the LRADC.

AFAIK currently there is no driver for controlling the actual
charging. You schould be able to enable/disable charging via
/dev/mem, but the right thing to do would be writting a proper
kernel driver.

HTH,
Harald
Title: Re: Battery management from User space
Post by: f2zubac on January 23, 2014, 12:26:21 AM
Hello

Search Google for 'raspberry usb ups' or similar key word.
There are project acting as 'usb ups' appliances which can provide a lot of infos via GPIO or similar interfaces.

Sincerely

Dragan Zubac
Title: Re: Battery management from User space
Post by: kbenni on January 23, 2014, 11:23:31 AM
I searched a litte bit, but i cant find any LRADC driver, or even power management driver.
They realy doesnt exist or can somebody help to me.
I found some attemps of porting imx28 LRADC driver to imx23 but they are not completed.
I need it for kernel 3.12.1

to Zubac: I dont understand, why i need to search about ups ups? imx23 has battery charge circuit and everything for baterry management
Title: Re: Battery management from User space
Post by: lambda on January 23, 2014, 11:17:23 PM
The LRADC driver is called mxs-lradc and is in staging. In the
kernel source tree you should find it in
drivers/staging/iio/adc/mxs-lradc.c

There have been some recent improvements, but everything you
need should work in 3.12 - I'm using it in my projects all the
time and am familiar with the code, so if you need some
yet unsupportet feature: Feel free to ask. (I won't backport
new features to 3.12 though ...)

You are right that the power managment driver is still missing.
I don't know if somebody is working on that already - probably
not. Maybe you can write one? (For kernel development you will
want to switch to very new kernels.)

HTH,
Harald
Title: Re: Battery management from User space
Post by: f2zubac on January 25, 2014, 09:17:15 PM
Hello

Yes,imx233 has LiPo charger and battery socket,but how to do the following :

1. How to be alerted when you battery is 'dying' ?
2. How to be alerted when the board power switch from power to battery and vice verse ?
3. How to monitor battery voltage and have a chance to react in time ?

Sincerely

Dragan Zubac
Title: Re: Battery management from User space
Post by: lambda on January 26, 2014, 12:06:33 AM
Quote from: f2zubac on January 25, 2014, 09:17:15 PM
3. How to monitor battery voltage and have a chance to react in time ?

The battery voltage is available as channel 7 of the LRADC.