element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
RoadTest Forum Fuel Tank BoosterPack With Rechargeable LION Battery and CCS or Energia - I2C issues
  • Blogs
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 26 replies
  • Answers 1 answer
  • Subscribers 2564 subscribers
  • Views 4538 views
  • Users 0 members are here
  • i2c
  • help
  • fueltank
  • boosterpack
  • energia
  • ap:wired_communication-i2c
  • msp430
  • launchpad
  • ti
Related

Fuel Tank BoosterPack With Rechargeable LION Battery and CCS or Energia - I2C issues

Robert Peter Oakes
Robert Peter Oakes over 11 years ago

I am one of the Road testers for the Fuel tank Booster Pack

 

I have 3 issues I am trying to resolve and would appreciate a little help, it is code related, not an issue with the actual evaluation of the product,

 

 

CCS Issues

With the booster Pack are a couple of demo programs, one for the MSP430G, one for a Tivia C. none for the board delivered with the Booster image (MSP430F5529)

 

so away I go testing , getting ready to run the demos, MSP430G demo compiles, uploads to the Board and seems to run but prints garbage on the console as if it had the wrong baud rate set. It is supposed to be set to 9600, N, 8, 1 but I tried that and every other baud rate available to Putty. Nothing worked. here is the code The specified item was not found.

 

so on to the Tivia C demo, this wont even compile so I can not get it to upload and test, missing libraries error etc

 

both Demos are CCS projects, I am not familiar with CCS, although I can make sense of the code, the tool is a struggle to get to know and use... but I was able to compile and upload the MSP430G project but with issues as shown above which are not related to CCS as far as I can tell.

 

any tips regarding either of these two issues would be appreciated.

 

Energia Issue (Or Library ?)

 

So given the issues with CCS I decided to simply write the code in Energia, this would be more useful to many readers as there are no sample code I have been able to see so far...

 

If I send a read to the Fuel Gauge for any one parameter it will work without a problem (See Views below)

If I try to grab a series of values like Volts, Avg Amps, Temp then it all goes wrong, I have tried many variations of code to no Joy, currently I suspect it may be the Wire library

 

below is the start of my demo code for the Energia IDE, compiles ok, uploads ok, works on multiple platforms ok except for the one issue, cant read more than one parameter without going wrong.

 

 

#define bq27510CMD_TEMP_LSB  0x06

#define bq27510CMD_VOLT_LSB  0x08

#define bq27510CMD_AI_LSB    0x14

#define bq27510CMD_SOC_LSB   0x20

#define bq27510_ADR      0x55  // address of the fuel gauge


#include <Wire.h>


void setup()

{

  Wire.begin();        // join i2c bus (address optional for master)

  Serial.begin(9600);  // start serial for output

}

void loop()

{

  int Volts;

  int  Amps;

  signed int  AverageCurrent;

  int  Temp;

  int SOC;

 

// uncommenting any one of these works 100%, as soon as more than one is used, it all goes wrong.

//Temp  = getValue(bq27510_ADR, bq27510CMD_TEMP_LSB )/ 10 - 273;

//Volts = getValue(bq27510_ADR, bq27510CMD_VOLT_LSB );

Amps = getValue(bq27510_ADR, bq27510CMD_AI_LSB);

//SOC = getValue(bq27510_ADR, bq27510CMD_SOC_LSB);

 

  Serial.print("Temp=" );  Serial.println(Temp);

  Serial.print("Volts=" );  Serial.println(Volts);

  Serial.print("AvgI=" );  Serial.println(Amps);

  Serial.print("SOC=" );   Serial.println(SOC);

  Serial.println(millis()); // to know the console actually updating

 

  Serial.println(); 

  Serial.println();

  delay(2000); // only output every 2 seconds

}

 

int getValue(int port, int cmd)

{

  unsigned int tmp1, tmp2, response;

  Wire.beginTransmission(port);

  Wire.write(byte(cmd));

  response = Wire.requestFrom(port, 2);    // request 2 bytes from slave device port, response always gets set to 62 for some reason, should be 2.

  

Serial.print("available1="); Serial.print(Wire.available()); // Debug statement, always returns 2 as expected.

 

  Wire.endTransmission(true);

 

  while(Wire.available())

  {

     // messy I know, should not assume two responses but this is a prototype and it works, will be cleaned up

    tmp1 = Wire.read() ;

    tmp2 = Wire.read() ;

  }

 

  Serial.print("cmd =");Serial.print(cmd);Serial.print(" Value =");Serial.println(transBytes2Int(tmp2, tmp1)); // debug statement

  return transBytes2Int(tmp2, tmp1);

}

 

unsigned int transBytes2Int(unsigned char msb, unsigned char lsb)

{ // this works just fine.

    unsigned int tmp;

    tmp = ((msb << 8) & 0xFF00);

    return ((unsigned int)(tmp + lsb) & 0x0000FFFF);

}

 

 

Fullscreen 4336.contentimage_41091.html Download
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

This is the output from the above code, as you can see the mA reads correctly (Verified with a meter), discharging at a rate of 15mA so -15

 

change code to this

 

//Temp  = getValue(bq27510_ADR, bq27510CMD_TEMP_LSB )/ 10 - 273;

Volts = getValue(bq27510_ADR, bq27510CMD_VOLT_LSB );

//Amps = getValue(bq27510_ADR, bq27510CMD_AI_LSB);

//SOC = getValue(bq27510_ADR, bq27510CMD_SOC_LSB);

image

  Volts working OK, 4.115V and verified with a meter.


now

 

Temp  = getValue(bq27510_ADR, bq27510CMD_TEMP_LSB )/ 10 - 273;

//Volts = getValue(bq27510_ADR, bq27510CMD_VOLT_LSB );

//Amps = getValue(bq27510_ADR, bq27510CMD_AI_LSB);

//SOC = getValue(bq27510_ADR, bq27510CMD_SOC_LSB);

 

Fullscreen 6283.contentimage_41092.html Download
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

Again, correct measurement 22deg C.

 

so why when I do this

Temp  = getValue(bq27510_ADR, bq27510CMD_TEMP_LSB )/ 10 - 273;

Volts = getValue(bq27510_ADR, bq27510CMD_VOLT_LSB );

Amps = getValue(bq27510_ADR, bq27510CMD_AI_LSB);

//SOC = getValue(bq27510_ADR, bq27510CMD_SOC_LSB);

 

Fullscreen 1425.contentimage_41093.html Download
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

does it all go wrong, I can find nothing in the data sheets to say you can not do this, and if you look, the last measurement is actually reflecting the previous request, as in the Voltage reading

I can re-arrange the order of requesting the parameters and the affect is the same, the last one reflects the previous and the others are garbage. Is smells of a memory issue probably in the Wire or TWI library, I look at the wire and could not find anything obvious.


So if any of you Energia experts out there with some I2C knowledge can help, suggest workaround or something it would be appreciated.


  • Sign in to reply
  • Cancel

Top Replies

  • Robert Peter Oakes
    Robert Peter Oakes over 11 years ago in reply to gsgill112 +1
    you should not be seeing 15mA no matter the load on the fuel tank, the fuel tank without modification can draw tht much simply sitting there with a battery connected and nothing else (One of its down sides…
Parents
  • gsgill112
    0 gsgill112 over 11 years ago

    Hi Peter I was testing your energia code but, it just prints some random values, for the current I am getting a 65560 value ? also the sample code from Tiva Ware was working fine until now, where I am getting pretty constant values (-15mA if not charging, for any amount of load i put on the boosterpack and around 130~200mA while charging) any idea why ?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to gsgill112

    you should not be seeing 15mA no matter the load on the fuel tank, the fuel tank without modification can draw tht much simply sitting there with a battery connected and nothing else (One of its down sides I addressed in my later videos). Try connecting a 20-50ohm resistor between 5V and ground on the fueltank board, you should get a reading appropriate to the value or above (Conversion in-inefficiencies)

     

    your indication on charging is about right

     

    I found that I had to fire the command at the fuel gauge twice in order to get a correct response from it (When asking for more than one parameter), i just double checked the code I posted and it still behaves the way shown in the video and written text of the blog entries.

     

    the only values i saw in my testing that where in that range was the est to empty and the est to full

     

    post you energia code and I will happily test it on my board for you. Are the reading you indicating above from when it was working or what you see now

     

    Peter

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to gsgill112

    you should not be seeing 15mA no matter the load on the fuel tank, the fuel tank without modification can draw tht much simply sitting there with a battery connected and nothing else (One of its down sides I addressed in my later videos). Try connecting a 20-50ohm resistor between 5V and ground on the fueltank board, you should get a reading appropriate to the value or above (Conversion in-inefficiencies)

     

    your indication on charging is about right

     

    I found that I had to fire the command at the fuel gauge twice in order to get a correct response from it (When asking for more than one parameter), i just double checked the code I posted and it still behaves the way shown in the video and written text of the blog entries.

     

    the only values i saw in my testing that where in that range was the est to empty and the est to full

     

    post you energia code and I will happily test it on my board for you. Are the reading you indicating above from when it was working or what you see now

     

    Peter

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • gsgill112
    0 gsgill112 over 11 years ago in reply to Robert Peter Oakes

    Hi Peter, Initially when I got this Module, It was working fine after putting a load of quite a lot RGB Led's I was able to get a ~-500mA consumption. and on plugging the power I was getting ~200-250mA charge without any load, but now the Battery Booster Pack gives ~-15/-16(With/Without Load) constant values as discharge current but the charging current varies from 20-100mA(Without load). I am currently using the example code provided by TI (Tiva-C Ware).

    So, my fuel gauge is behaving abruptly ?

     

    I will get some time early next morning and post few screen shorts. Maybe that will help .

     

    thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to gsgill112

    This is the output I am getting right now, no load, then a 10ohm resistor on the 5V rail then removed again (The low quiescent current is due to the modded board I have and also the meter is reading high at this level) A side project is to figure out how to read in the configuration from the fuel gauge in order to see if it is set up correctly from the factory.

    Temp, Volts, mA, SOC, RCAP, DCAP, TTE, TTF
    20, 4138 ,  -7 , 89, 427, 1200, 3660, 65529
    20, 4138 ,  -7 , 89, 427, 1200, 3660, 65529
    20, 4138 ,  -7 , 89, 427, 1200, 3660, 65529
    20, 4138 ,  -7 , 89, 427, 1200, 3660, 65529
    20, 4138 ,  -7 , 89, 427, 1200, 3660, 65529
    19, 3956 , -593 , 89, 426, 1200, 157, 65529
    18, 3948 , -594 , 89, 426, 1200, 88, 65529
    17, 3943 , -592 , 89, 425, 1200, 68, 65529
    16, 3940 , -592 , 89, 425, 1200, 58, 65529
    16, 3936 , -593 , 88, 424, 1200, 53, 65529
    16, 4108 ,  -7 , 88, 424, 1200, 75, 65529
    16, 4108 ,  -7 , 88, 424, 1200, 105, 65529
    16, 4108 ,  -7 , 88, 424, 1200, 146, 65529
    16, 4108 ,  -7 , 88, 424, 1200, 202, 65529
    19, 4121 ,  -7 , 88, 424, 1200, 280, 65529
    19, 4121 ,  -7 , 88, 424, 1200, 380, 65529
    19, 4121 ,  -7 , 88, 424, 1200, 541, 65529
    20, 4125 ,  -7 , 88, 424, 1200, 727, 65529
    20, 4125 ,  -7 , 88, 424, 1200, 942, 65529
    20, 4125 ,  -7 , 88, 424, 1200, 1211, 65529
    20, 4125 ,  -7 , 88, 424, 1200, 1496, 65529
    20, 4127 ,  -7 , 88, 424, 1200, 1817, 65529
    20, 4127 ,  -7 , 88, 424, 1200, 2120, 65529
    20, 4127 ,  -7 , 88, 424, 1200, 2544, 65529
    20, 4127 ,  -7 , 88, 424, 1200, 2827, 65529
    20, 4129 ,  -7 , 88, 424, 1200, 2827, 65529
    20, 4129 ,  -7 , 88, 424, 1200, 3180, 65529
    20, 4129 ,  -7 , 88, 424, 1200, 3180, 65529

     

    and this is the sketch i'm currently using to get this

     

    very simple Energia sketch and it is working as I expect (Including the need to send the commands twice)

     

    I am using this with an msp-exp430F5529LP, and this is the only load except when I attach the 10ohm resistor

    Attachments:
    FuelGaugeApril2014.ino.zip
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • maperales
    0 maperales over 11 years ago in reply to Robert Peter Oakes

    Thanks, Peter, for your post. I am another roadtester surprised by the fact that there is no official support for this combination of launchpad and boosterpack. I have used your code succesfully, and I'm trying to port to CCS.

    I'm using the launchpad in both Energia and Code Composer, and I've found a very annoying problem: each time I switch between Energia and CCS, both programs tell me that I have to update the programmer's firmware. And this operation is sometimes unsuccesful.

     

    Anyway, thanks again for your contribution.

     

    Regards,

    Manuel Perales.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • kas.lewis
    0 kas.lewis over 11 years ago in reply to maperales

    Hello maperales I am also having a "fun" time with this kit. I have finally got the Stellaris Launchpad to work with it but not the MSP430G2. Interestingly the board they ship with this boosterpack (MSP430F) does not appear to be supported natively by the provided code. I have also had no success in getting more information on the battery or the connecter (I emailed Christian DeFeo from Element14).

     

    I have left the battery charging as it appeared to be taking a LONG time and it wont go above 928 mAh even though it says its design capacity is 1200 mAh. When it finally reaches this point it says 100% charged and then decides to start discharging. I will be looking through the sample code later to see if these two issues (design capacity and automatic discharging) are by design or something else is causing these issues.

     

    Another issue I have notice that I am also not sure if its code related or design related is every time the board outputs to the terminal the green LED on the Stellaris blinks, I am curious if that is a power drain issue (bad design) or if the code turns off the LED for that brief moment, I am hoping for the second but only looking through the code will answer that.

     

    I am hoping to get he MSP430G2 working with this boosterpack soon and see how that progresses. I have only tried CCS on these two boards as I have not installed Energia and I would prefer not to. I was hoping to do some other tests with this board but at the rate this is going I think I may stick to the basic usability and overall performance and leave the corner cases for a very rainy day.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • kas.lewis
    0 kas.lewis over 11 years ago in reply to kas.lewis

    doctorcdf27 Robert Peter Oakespeterious was just wondering if any of the other Road Testers had issues with gauge saying the battery was 100% yet the battery was really only 82% charged. Curious if its possibly a battery issue.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 11 years ago in reply to kas.lewis

    Hi Kas,

     

    I've not looked into the details, but could it be that the battery is 100% charged (i.e. the charger went through the CC and CV phases), but only around 80% capacity is recorded as usable, because of some low-power cut-off that has been implemented? Li-Po cells should not be totally discharged, but 20-30% should remain (otherwise it reduces the long-term health of the battery).

     

    This is just a guess though - I don't know if the value that is read and then interpreted/displayed by the microcontroller code takes this into account or not (I didn't check : (.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • kas.lewis
    0 kas.lewis over 11 years ago in reply to shabaz

    Hey Shabaz,

     

    I hear you, that may make sense, I will look into that.

     

    Thank you

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • kas.lewis
    0 kas.lewis over 11 years ago in reply to kas.lewis

    shabaz I thought about your idea and it sounded plausible until I looked at the log this morning. I again see its at 100% but this time remaining charge is only at 860 mAh which would be at ~72% full. I am also seeing the board randomly charging and discharging (it has been plugged in the whole time). It charges to ~100% (or what it thinks is 100%) and then starts discharging I see it hitting 90% one two separate cycles before recharging, but I do not see anything in the code that would prompt this.

     

    I hope to at some point see if I can rest the gauge that is if they have not locked us out. If that does not work I will possibly try just rewriting the code from scratch and see if I get anything better..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to kas.lewis

    Hopefully in the next few days I will upgrade my program I used to talk to the fuel tank to extract the settings for the fuel Gauge.

     

    I suspect that they are not configured correctly

     

    for instance, on discharge it cuts off way to early (About 3.5 volts from memory) and this can be one of the reasons that even when fully charged the algorithm reports a much lower available Amp Hours (mA Hours image ) because the algorithm will know that it will cut off early and will adjust expectations appropriately

     

    mine also gets to 100% charged but only reports around 85% (960mA or something close to that) available charge

     

    it charges to the correct voltage no issues and if you look at the graphs I posted in my review you will see exactly what I am referring to. I validated the charge and discharge voltage cut off using a 4.5 Digit DMM so I know the Fuel Gauge was accurate

    see Pop Quiz and 50Pts for the first right answer

     

    don't forget the excessive discharge rate of the booster even when not attached to a load too, I have also detailed modifications to remedy this.

     

    See Reparing a Suicidal Boost regulator on the Fuel Tank TI Booster pack Pt1 - Removal

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • kas.lewis
    0 kas.lewis over 11 years ago in reply to Robert Peter Oakes

    Hey Peter,

     

    Had a quick look at the I2C lines (very quick) and from the brief look it appears as if the lines are not behaving predictably. I see sometimes the line is left pulled high and other times it is left pulled low, I also do not see any repeated commands on the logic trace. I have attached the trace for anyone else to go over, you will need to download the Saleae software though.

     

    I will try look into this more when I get time today and report back on this. I also know I still need to write my review (thank you for the reminder Element14) but, I am hoping to write more than got one of 3 demo codes working, so it may take still a few more days to get there. Hopefully as a community we can get this board working well and iron out all the bugs so they can come up with a better revision sometime soon.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube