So, I got to a code, that 
works, https://github.com/chintanp/i2c-charger/blob/master/charger.c 

It updates the voltage delivered by the charger every few seconds, 
similarly other parameters like the charging current can be tweaked. 

Thanks a lot to all the folks, ;) 






On Wednesday, September 23, 2015 at 10:01:36 AM UTC-7, Chintan Pathak wrote:
>
> Whoever said - reading the datasheet goes a long way, was not lying. :)
>
> So I read it, twice, and found it quite enlightening. To summarise: I 
> found out how to set the Battery Regulation voltage and charge current, 
> thanks to register descriptions on page number 33-35, which use the formula
>                                          
>                                        VBATREG = 3.5 V + VBREGCODE × 20 mV 
>
>                                 and     ICHARGE = 500 mA + ICHRGCODE × 100 
> mA
>
>
> Also, I found the address of the EVM for referring in my BBB I2C code as : 
> 0x6B 
> (1101011 in binary) . 
>
> Now, I am left with two, seemingly non-trivial questions, 
>
> 1. * How to do I write to the registers* like the Status/Control Register 
> with a memory location of 00, Control/Battery Voltage Register with a 
> memory location of 02, etc. I learnt direct register manipulation (DRM) but 
> then experts suggested that using API function calls is a safer method to 
> use than DRM (I dont think such API functions are available for BQ-24261, 
> there was a mention of a public library here 
> https://lkml.org/lkml/headers/2015/9/6/91 but I couldnt locate the actual 
> header file) , so I am not as thorough with the process. A two line snippet 
> would really help in clarifying the concepts. 
>
> 2.  *Choice of functional mode*:Section 9.4 of datasheet, lists details 
> about 19 possible functional modes for operating the EVM. Which of these is 
> the suggested one ? I understand that this might be application specific, 
> but any pointers on this selection, or this is done implicitly by setting 
> the appropriate registers through the above step. 
>
>
>
> - Thanks 
> Chintan Pathak 
>
>
>
>
>
>
> On Tuesday, September 22, 2015 at 8:55:43 PM UTC+5:30, Ron B. wrote:
>>
>> Your source for all things bq24261 will be the datasheet 
>> <http://www.ti.com/lit/ds/symlink/bq24260.pdf>.  It describes the 
>> registers, how to use them, and gives you the I2C address at the bottom of 
>> page 27.  The bq24261 will work fine with a 3.3V I2C interface.  It will 
>> get it's own internal power from the DC source used for battery charging 
>> (on eval board J1).  Eval board documentation is here 
>> <http://www.ti.com/lit/pdf/sluuab0>.
>>
>> My drawing would probably look more like:
>> BBB SCL  <-->  SCL (J15)
>> BBB SDA  <-->  SDA  (J15)
>> BBB GND  <-->  GND  (J15)
>>
>> Add pull-ups between SCL <-> BBB 3V3, and SDA <-> BBB 3V3.  I'd probably 
>> use 10k.  Then, it's all software.
>>
>> -Ron
>>
>>
>>
>>
>> On Tuesday, September 22, 2015 at 8:52:41 AM UTC-5, Chintan Pathak wrote:
>>>
>>> Hey Ron, 
>>>
>>> You have been super-helpful, and I believe together we have nearly 
>>> cracked it. 
>>>
>>> I am beginning to get a feel for I2C and I have come up with a schematic 
>>> for connection, which I present below for review and comments. 
>>>
>>>
>>> <https://lh3.googleusercontent.com/-DLOTnkK_ihU/VgFbQtMxLZI/AAAAAAAABMk/FvQO-ctXTbw/s1600/i2c_interface_schematic.png>
>>>
>>>
>>> I plan to use pull-ups of 47k each and a supply of 3.3V from BBB. 
>>>
>>>
>>> I have also requested help from TI-E2E, but I wanted to know, if this 
>>> voltage is sufficient / proper for our charger ? 
>>>
>>>
>>> Also, how can I get the address of our EVM (charger) for use in the code 
>>> as in your # define statement in this example 
>>> http://andicelabs.com/2013/06/linux-using-i2c-from-user-land/  ? 
>>>
>>>
>>> Will let you know how this goes. 
>>>
>>>
>>> - Thanks
>>>
>>> Chintan Pathak 
>>>
>>>
>>> On Tuesday, September 22, 2015 at 5:29:45 AM UTC+5:30, Ron B. wrote:
>>>>
>>>> Your original question seemed to be more about I2C code examples. 
>>>>  Anyway, I don't see any reason why you can't do what you're asking.  The 
>>>> eval board's I2C interface is brought out to a header and you'd just hook 
>>>> that up to the bone's I2C bus (be sure to also connect the boards' grounds 
>>>> together).  The eval board doesn't make any assumptions about power so 
>>>> there are no I2C pull-ups on it.  If you need to add pull-ups to the I2C 
>>>> lines, be sure to use 3v3 from the bone's header.
>>>>
>>>> While not 100% relevant, I have two I2C posts here 
>>>> <http://andicelabs.com/2013/06/linux-using-i2c-from-user-land/> and 
>>>> here <http://andicelabs.com/2013/07/adafruit7segment/> with simpler 
>>>> examples.
>>>>
>>>> -Ron
>>>>
>>>> On Monday, September 21, 2015 at 12:13:27 PM UTC-5, Chintan Pathak 
>>>> wrote:
>>>>>
>>>>> Hey Ron, 
>>>>>
>>>>> Your work at andicelabs.com seems fantastic. Long live Open source :)
>>>>>
>>>>> Just to be clear about my question, I want to power a battery using 
>>>>> the TI battery charger board, BQ24261 and I want to control (program) the 
>>>>> charger  board using a Beaglebone black. Reading the datasheet of the 
>>>>> charging board, I found that, it can be controlled via a GUI, that can be 
>>>>> accessed by interfacing the charging board to a PC using a USB-GPIO 
>>>>> interface board. 
>>>>>
>>>>> In absence of the said board, and with the need to programmatically 
>>>>> set the charging voltage for my battery, I plan to use the BBB. 
>>>>>
>>>>> Your code in powercape.c is quite exhaustive, I wanted to further 
>>>>> know, whether I will need any additional hardware to connect the charging 
>>>>> board to BBB, and any other information / source relevant to this topic. 
>>>>>
>>>>> - Thanks 
>>>>> Chintan Pathak 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Monday, September 21, 2015 at 8:26:08 PM UTC+5:30, Ron B. wrote:
>>>>>>
>>>>>> Hi Chintan,
>>>>>>
>>>>>> I don't use I2C to control the charger, but I do use it to talk to 
>>>>>> the power monitor and the supervisor.  Our code for the host-side I2C 
>>>>>> utilities are on Github 
>>>>>> <https://github.com/AndiceLabs/PowerCape/tree/master/utils> and 
>>>>>> should make a reasonable example.
>>>>>>
>>>>>> -Ron
>>>>>>
>>>>>> On Monday, September 21, 2015 at 2:58:12 AM UTC-5, Chintan Pathak 
>>>>>> wrote:
>>>>>>>
>>>>>>> I have a battery charger : 
>>>>>>> http://www.ti.com/tool/BQ24261EVM-079?keyMatch=bq24261evm-079&tisearch=Search-EN-Everything
>>>>>>>
>>>>>>> and I want to program it using the BBB I2C. Can I get any code 
>>>>>>> sample to proceed or any guidance ?
>>>>>>>
>>>>>>>
>>>>>>>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to