SMBus, SBS, I2CWrite, I2CRead


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default Re: SMBus, SBS, I2CWrite, I2CRead

    i am happy to share what i have learned and delighted as well about PBP3 doing what needed to be done
    pictures and pcbs are probably off the table due to being the property of the customer but things learned along the way in PBP are fine
    i don't know about cars, isn't that CAN ?
    my project has a 4 cell (4S2P) Li-ion pack with an integrated 'pcb' which contains the protection stuff and the aforementioned fuel gauge, about 80W/hr so closer to a laptop than a car
    the battery 'pcb' is by the vendor
    i had many concerns about the thresholds and possible protocol issues which i feared may necessitate using the I2C hardware but at the end of the day the I2CWRITE worked fine, voltage thresholds and levels were well beyond points to cause worries
    in fact the i2c buss is shared with several other chips, a DAC and phillips LED blinker and all are playing nicely together
    the main hurdle that cost the most time was discovering the address ('control') (dec 22), discovering how to set batt as slave (as it could be master) which 22 also accomplished

    next the battle over corrupt SMBus data was won by good old trial and error, i found that i needed to slow way down (by means of OSCCON (is intosc)) to 2MHz** and then all was rock steady
    trouble was that 2MHz turned out to be impractical overall (and BTW PBP does not have DEFINE OSC 2 and i needed DEFINE for many things) so i wasted a bunch of time compensating for that until i simply made everything 8Mhz and then in the GOSUB to ReadSMBus switched the OSC to 2 at the start and back to 8 before RETURN,
    worked a treat!
    now i just send
    i2CREAD pSDA, pSCL, bFGAddr, bSMBC, [bTemp0, bTemp1]
    where bFGAddr is dec 22, bSMBC is hex 11 (sorry about mixed types) and the 2 bytes get put into a word which gives me ...
    RunTimeToEmpty
    this word contains minutes which are dynamic and based on all the historic goes inna goes outta so as i vary the load the minutes go up and down, how cool is that ?

    i can read the batt temperature, current in, current out, voltage, remaining runtime at an arbitrary current by writing something to another register, theoretical total capacity as per original setup and on an on

    way more stuff than i need and kudos to TI for all this tech and kudos to MEL for these great tools that make it simple

    **PS
    as i recall, contrary to my expectation slower than 2Mhz was not better it started to get flaky again at 1, so 2 was the sweet spot, the I2CREAD routine is not a speed demon so i suspect the data rate is in the 10's of kHz, i did not scope it and measure it

  2. #2
    Join Date
    Nov 2008
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: SMBus, SBS, I2CWrite, I2CRead

    dsicon, sorry for replying to an old thread but I just wanted to get a bit of clarification. The bit of code you posted works as is when the clock runs at 2Mhz? I'm starting a project that involves interfacing to a smart battery pack via the SMBus and there wasn't much in the way of examples.

  3. #3
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default Re: SMBus, SBS, I2CWrite, I2CRead

    Hi astouffer, this project is still alive for me!
    i run the main loop at 8Mhz RC clock
    when i call a gosub to do the SMBus via I2CREAD I2CWRITE in the gosub at the top i switch to 2MHz RC OSC on the fly and just before the RETURN i switch it back to 8MHz
    this was VERY hard won for me at least, it was all proven empirically, 1 & 4MHz did not work, at least not reliably, 2Mhz seems quite solid
    if there is anything else let me know
    what is your operating voltage for the PIC ?
    what is the batt voltage and Watt hours? (shouldn't matter much unless maybe is only one cell, just curious)
    what is the fuel gauge chip in the battery?

  4. #4
    Join Date
    Nov 2008
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: SMBus, SBS, I2CWrite, I2CRead

    The PIC will be a power supervisor in this application and we're going with two of these battery packs http://www.cell-con.com/pdf/D90494_DataSheet_BP.pdf.

    What voltage does the SMBus use? If its 5 volts then that will be the PIC voltage. The PIC is going to monitor the battery time remaining and have some status LEDs and probably watch the temperature as well. If the batteries get too low then its going to disconnect the equipment. Nothing real fancy. I'm not sure what fuel monitor chip the batteries have but they do have 24 possible values to read from.

Similar Threads

  1. i2cRead i2cwrite very frustrating
    By bradb in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th September 2011, 21:48
  2. I2cwrite - I2cread
    By savnik in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 5th July 2006, 02:12
  3. I2Cwrite and I2CRead speed!
    By Najim in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 2nd November 2005, 11:54
  4. I2Cwrite and I2CRead speed!
    By Najim in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 2nd November 2005, 11:50
  5. I2CWRITE and I2CREAD
    By Tomas in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd April 2004, 03:30

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts