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
(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);
}
<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);
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);
<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);
<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.
