CCS does not monitor this forum on a regular basis. Please do not post bug reports on this forum. Send them to support@ccsinfo.com
 BMP085 Pressure Sensor Goto page 1, 2  Next
Author Message
ajt

Joined: 07 Sep 2003
Posts: 110

BMP085 Pressure Sensor
Posted: Fri Aug 17, 2012 12:25 pm

After spending a lot of time trying to convert integer arithmetic Arduino driver code for this device to CCS, I gave up and wrote my own integer based driver. Both of these exercises were basically a waste of time because there are too many issues in data type differences and overflow, etc. problems with the integer based math.

The following driver is all floating point and works well. Usage is shown in the opening comments. A test program follows.

Please post any improvements or corrections.

(Use any of this work as you wish but you assume all risk in doing so.)

Al Testani

 Code: //************************************************ //  BMP085 Barometric Pressure Sensor // //  - Datasheet: http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf // //  - Written in CCS PCH C using floating point math //  - Several integer math versions of this driver exist but the speed improvement is //    not warranted in typical weather station type applications //  //  - Based on a paper posted to thebackshed.com by DuinoMiteMegaAn //    http://www.thebackshed.com/forum/forum_posts.asp?TID=4768&PN=9  // //  - Usage: //     Call once: bmp085Calibration(); //     P_mBar_float = BMP085Pressure(true);  //  calls for temperature first //     P_mBar_float = BMP085Pressure(false);  // skips temperature reading, assumes done previously //     T_Cent_float = BMP085Temperature(); //     t_reading = _Temp;  _Temp set on every temperature reading //        Note:   pressure reading is temp compensated so call for temp reading prior to pressure reading periodically or on each reading // //  Al Testani //  08/17/12 //************************************************ // place a #use i2c statement in the main program and comment this out if not applicable #use i2c(master, sda=PIN_C4, scl=PIN_C3, FAST, FORCE_HW) #include const int8 OVS_S = 3; // Oversampling Setting (0,1,2,3 from ultra low power, to ultra hi-resolution) #define BMP085_ADDRESS 0xEE          // I2C address of BMP085 #define P_CORRECTION   1.5           // in mBars - factor to adjust for elevation to match local weather station pressure                                      // this value for 14' above sea level (in Boca Raton, Florida) // Calibration values signed int16 ac1; signed int16 ac2; signed int16 ac3; int16 ac4; int16 ac5; int16 ac6; signed int16 b1; signed int16 b2; signed int16 mb; signed int16 mc; signed int16 md; // floating point cal factors float _c3; float _c4; float _b1; float _c5; float _c6; float _mc; float _md; // polynomomial constants float _x0; float _x1; float _x2; float _y0; float _y1; float _y2; float _p0; float _p1; float _p2; float _s;     // T-25, used in pressure calculation - must run temperature reading before pressure reading float _Temp;  // set after every temperature or temperature/pressure reading //---------------------------------------------- int8 BMP085ReadByte(int8 address) //---------------------------------------------- { int8 data;    i2c_start();    i2c_write(BMP085_ADDRESS);    i2c_write(address);    i2c_start();    i2c_write(BMP085_ADDRESS | 0x01 );    data=i2c_read(0);    i2c_stop();    return(data); } //---------------------------------------------- int16 BMP085ReadInt(int8 address) //---------------------------------------------- { int8 msb, lsb; int16 temp;    i2c_start();    i2c_write(BMP085_ADDRESS);    i2c_write(address);    i2c_start();    i2c_write(BMP085_ADDRESS | 0x01 );    msb = i2c_read();    lsb = i2c_read(0);    i2c_stop();    temp = make16(msb, lsb);    return ( temp ); } //---------------------------------------------- void BMP085WriteByte(int8 address, int8 data) //---------------------------------------------- {    i2c_start();    i2c_write(BMP085_ADDRESS);    i2c_write(address);    i2c_write(data);    i2c_stop(); } //---------------------------------------------- void bmp085Calibration() //---------------------------------------------- {    // read BMP085 EEPROM cal factors    ac1 = bmp085ReadInt(0xAA);    ac2 = bmp085ReadInt(0xAC);    ac3 = bmp085ReadInt(0xAE);    ac4 = bmp085ReadInt(0xB0);    ac5 = bmp085ReadInt(0xB2);    ac6 = bmp085ReadInt(0xB4);    b1  = bmp085ReadInt(0xB6);    b2  = bmp085ReadInt(0xB8);    mb  = bmp085ReadInt(0xBA);    mc  = bmp085ReadInt(0xBC);    md  = bmp085ReadInt(0xBE);     // calculate floating point cal factors    _c3 = 0.0048828125 * ac3;            // 160 * pow2(-15) * ac3;    _c4 = 0.000000030517578125 * ac4;    // 1E-3 * pow2(-15) * ac4;    _c5 = 0.00000019073486328125 * ac5;  // (pow2(-15)/160) * ac5;    _c6 = (float)ac6;    _b1 = 0.00002384185791015625 * b1;   // 25600 * pow2(-30) * b1;    _mc = 0.08 * mc;                     // (pow2(11) / 25600) * mc;    _md = (float)md / 160;        // calculate polynomial constants    _x0 = (float)ac1;    _x1 = 0.01953125 * ac2;             // 160 * pow2(-13) * ac2;    _x2 = 0.000762939453125 * b2;       // 25600 * pow2(-25) * b2;    _y0 = _c4 * 32768;                  //_c4 * pow2(15);    _y1 = _c4 * _c3;    _y2 = _c4 * _b1;    _p0 = 2.364375;     _p1 = 0.992984;    _p2 = 0.000004421;    } // Read the uncompensated temperature value //---------------------------------------------- int16 BMP085ReadUT() //---------------------------------------------- { int16 ut;     // Write 0x2E into Register 0xF4   BMP085WriteByte(0xF4, 0x2E);   delay_ms(5); // Wait at least 4.5ms   // Read two bytes from registers 0xF6 and 0xF7   ut = BMP085ReadInt(0xF6);   return((float)ut); } // Read the uncompensated pressure value //---------------------------------------------- int32 bmp085ReadUP() //---------------------------------------------- { int8 msb, lsb, xlsb; float p;     // Write 0x34+(OSS<<6) into register 0xF4   // Request a pressure reading w/ oversampling setting   BMP085WriteByte(0xF4, (0x34 + (OVS_S<<6)) );     // Wait for conversion, delay time dependent on OSS   switch (OVS_S)   {      case 0: delay_ms(5);  break;      case 1: delay_ms(8);  break;      case 2: delay_ms(14); break;      case 3: delay_ms(26); break;   }        // Read register 0xF6 (MSB), 0xF7 (LSB), and 0xF8 (XLSB)    msb  = BMP085ReadByte(0xF6);    lsb  = BMP085ReadByte(0xF7);    xlsb = BMP085ReadByte(0xF8);    p = (256*msb) + lsb + (xlsb/256);    return(p); } //---------------------------------------------- float BMP085GetTemp(float _tu) //---------------------------------------------- { float alpha, T;    alpha = _c5 * (_tu - _c6);    T = alpha + (_mc/(alpha + _md));    _s = T - 25;    return(T); }    //---------------------------------------------- float BMP085GetPressure(float _pu) //---------------------------------------------- { float x, y, z; float P;    x = _x2*_s*_s + _x1*_s + _x0;    y = _y2*_s*_s + _y1*_s + _y0;    z = ((float)_pu - x) / y;    P = _p2*z*z + _p1*z + _p0;    P += P_CORRECTION;    return(P); } //---------------------------------------------- float BMP085Pressure(boolean getTemp) //---------------------------------------------- {    if (getTemp)       _Temp = BMP085GetTemp(BMP085ReadUT());  // creates _s required for pressure calculation    return(BMP085GetPressure(BMP085ReadUP())); } //---------------------------------------------- float BMP085Temperature(void) //---------------------------------------------- {    _Temp = BMP085GetTemp(BMP085ReadUT());    return(_Temp); }

A test program using the driver follows:

 Code: #include <18LF2420.h> #device adc=16 #FUSES NOWDT, WDT128, H4, NOFCMEN, NOIESO, NOBROWNOUT, NOPBADEN, NOLPT1OSC, NOSTVREN, NOLVP, NOXINST // 4MHz crystal #use delay(clock=16000000) #use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N, stop=1, errors) #include "./BMP085.c" // Pin Definitions #define YEL_LED         PIN_B3 #define SCL             PIN_C3  #define SDA             PIN_C4  #define TX              PIN_C6 #define RX              PIN_C7 // Macros #define set(x) output_high(x) #define clr(x) output_low(x) //---------------------------------------------- void main() //---------------------------------------------- { float Tf, P_inHg; float T_Cent; float P_mBar; int16 tp, tt;    setup_timer_0(T0_INTERNAL|T0_DIV_4); // 1 usec resolution    bmp085Calibration();    while(true)    {       set(YEL_LED);       set_timer0(0);             T_Cent = BMP085Temperature();       tt= get_timer0();       P_mBar = BMP085Pressure(false);   // skips required temp reading since already done above       tp = get_timer0() - tt;       printf("Temperature (C):  %.1g\r\n", T_Cent);       printf("Pressure (mBar):  %0.2g\r\n\n", P_mBar);       Tf = ((9.0/5.0)*T_Cent) + 32.0;       printf("Temperature (F):  %.1g\r\n", Tf);       P_inHg = (0.0295301) * P_mBar;       printf("Pressure (inHg):  %.2g\r\n\n", P_inHg);       printf("Processing time: \r\n");       printf("  Temperature = %Lu  (usec)\r\n", tt);       printf("  Pressuure   = %Lu (usec)\r\n", tp);       printf("------------------------------\r\n");             clr(YEL_LED);       delay_ms(1000);    } }

_________________
Al Testani
Lykos1986

Joined: 26 Nov 2005
Posts: 68

 Posted: Wed Apr 17, 2013 4:54 am Hi! Have you got any update about this driver? I am trying to use it but without success! It always replies back with -9 for the temperature and 247.6 for the pressure. At my code I am using: ... #include "./BMP085.c" ... bmp085Calibration(); ... T_Cent = BMP085Temperature(); P_mBar = BMP085Pressure(false); ... And then I am printing the values. The I2C pins are the correct ones but I am always having the same values Any help?
ajt

Joined: 07 Sep 2003
Posts: 110

 Posted: Wed Apr 17, 2013 7:45 am The code is the latest revision and from the code snippet you sent should work. However... I can't help at all since I don't know what PIC you are using, what the hardware schematic looks like, or what version of the compiler you are using. Does the code (unmodified) I provided including the test program work properly on your hardware? I will gladly try to help but you will have to provide much more information._________________Al Testani
Lykos1986

Joined: 26 Nov 2005
Posts: 68

 Posted: Wed Apr 17, 2013 10:48 am Actually I am using a PIC24F32KA304 #include "24F32KA304.h" and for the fuses I have: #FUSES NOWRTB, NOBSS, NOWDT, NOBROWNOUT, NOLVR, NOPUT, MCLR, ICSP2, NODEBUG, NODSWDT, NOWRT, NOPROTECT, NOIESO, PR, HS, NOCKSFSM, ALTI2C Otherwise my code is almost the same. As for the hardware part, I am using 4.7K Pull-Up resistors at the I2C pins, EOC and XCLR pins unconnected and power pins connected to the power with 100nF decoupling capacitors I was trying also to use the SLOW configuration of I2C incase that the speed was the problem but still nothing... Do you thing it is a problem with the Fuses? I will try your code without any modifications as well and I will let you know
ajt

Joined: 07 Sep 2003
Posts: 110

Posted: Wed Apr 17, 2013 11:04 am

Make sure you have a #use i2c statement in your code in one place. The following is the default in the BMP085.c file. Obviously, change it to the pins you are using:

 Code: #use i2c(master, sda=PIN_C4, scl=PIN_C3, FAST, FORCE_HW)

If you are not using the I2C peripheral then you don't want the FORCE_HW switch but I don't know if my code and/or the BMP085 would would work with software I2C. It should but I never tested it.

In terms of fuses, I don't use that PIC so don't know but you might want to check if your oscillator is set up properly.
_________________
Al Testani
Lykos1986

Joined: 26 Nov 2005
Posts: 68

 Posted: Wed Apr 17, 2013 12:11 pm Hmmm, I am using your example and I am having a few interesting results. If I use the: #use i2c(master, sda=PIN_B2, scl=PIN_B3, FAST, FORCE_SW) it replies back with: Temperature (C): 12.7 Pressure (mBar): 544347.31 If I use the: #use i2c(master, sda=PIN_B2, scl=PIN_B3, FAST, FORCE_HW) it replies back with: Temperature (C): -9 Pressure (mBar): 247.6 Of course, the results are not changing even if I gently try to heat the sensor. I've use also the SLOW instead of FAST as well but I am having exactly the same results. Probably is something wrong with the sensor...
ajt

Joined: 07 Sep 2003
Posts: 110

 Posted: Wed Apr 17, 2013 12:30 pm Maybe you should use the ICD1 or ICD2 switch in your #USE i2c statement since your PIC has two I2C hardware peripherals. I don't know if the compiler sets the correct hardware by specifying the pins only. You could look is the LST file to see what is really getting set up._________________Al Testani
Lykos1986

Joined: 26 Nov 2005
Posts: 68

 Posted: Thu Apr 18, 2013 3:10 am It is not about the I2C1 or I2C2. I just connect a USB logic analyser and it seems that the communication is more than perfect! I am having good timings, ACT conditions and everything else related to a good I2C master-slave communication. Furthermore I was checking with the datasheet and everything are as suppose to be! In other words your driver if OK! I am 99% sure that the problem is with the BMP085 sensor itself! You have to read two register values for the temperature and three register values for the pressure (plus the 11 calibration coefficients from the EEPROM only at the beginning). And then you perform the calculations at the code/driver It seems that the two temperature registers are giving back always 0xFF and 0xFF and the three pressure registers are giving back always 0x00, 0x00 and 0x00. No matter if I heat the sensor etc So, I think it is a problematic sensor and nothing more! What to expect when this sensor is from eBay for 3.5\$ with free shipping!!!
ajt

Joined: 07 Sep 2003
Posts: 110

 Posted: Thu Apr 18, 2013 10:20 am I received a notification in mid-Feb. that the BMP085 is at EOL and now obsolete. There are still some left in distribution and places like eBay. The BMP085 is not recommended for new designs. The Bosch-Sensortec website no longer lists the BMP085, just the BMP180 and BMP280. According to the BMP180 datasheet it is the replacement for the BMP085. Unfortunately, it has a different footprint so cannot go into existing designs. From a quick review of the registers and operation of the interface I believe the BMP085 driver code will work as it is except there is now a 5th resolution mode that isn't supported in my code. I need to get some samples of the BMP180 and test them out._________________Al Testani
Lykos1986

Joined: 26 Nov 2005
Posts: 68

 Posted: Thu Apr 18, 2013 12:47 pm Good to letting me know ajt! I will try to get samples from the BMP180 as well...
ajt

Joined: 07 Sep 2003
Posts: 110

 BMP180 Driver Posted: Mon May 20, 2013 3:18 pm I tested the BMP180 with the exact driver code and example for the BMP085 previously posted and it works fine._________________Al Testani
Lykos1986

Joined: 26 Nov 2005
Posts: 68

 Posted: Wed May 22, 2013 2:17 am Good news!!! I will try to source a BMP180 and make some experiments with it!
lazuribicci

Joined: 06 Feb 2010
Posts: 10

integer library
Posted: Tue Jul 30, 2013 2:00 am

Dear friends,

I have tested above library, but I cannot read pressure, however temperature seems good. I have researched step by step and I found faulty in calibration coefficient routine. First value, ac1, comes wrong. It should be 7000-8000 but it gives 12. So I read it again after md coefficient. It seems everything good.

BTW, I prepare a new integer library for BMP085.

I hope it helps some people.

Fatih GENC

 Code: //************************************************ //  BMP085 Barometric Pressure Sensor // //  - Datasheet: http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf // //  - Written in CCS PCH C using floating point math //  - Several integer math versions of this driver exist but the speed improvement is //    not warranted in typical weather station type applications //  //  - Based on a paper posted to thebackshed.com by DuinoMiteMegaAn //    http://www.thebackshed.com/forum/forum_posts.asp?TID=4768&PN=9  // //  - Usage: //     Call once: bmp085Calibration(); //     P_mBar_float = BMP085Pressure(true);  //  calls for temperature first //     P_mBar_float = BMP085Pressure(false);  // skips temperature reading, assumes done previously //     T_Cent_float = BMP085Temperature(); //     t_reading = _Temp;  _Temp set on every temperature reading //        Note:   pressure reading is temp compensated so call for temp reading prior to pressure reading periodically or on each reading // //    Revision - integer algotihm //    Fatih GENC //    07/30/2013 // //  Al Testani //  08/17/12 //************************************************ // place a #use i2c statement in the main program and comment this out if not applicable #use i2c(MASTER, fast=400000, I2C1, RESTART_WDT) #include const int8 OVS_S = 3; // Oversampling Setting (0,1,2,3 from ultra low power, to ultra hi-resolution) #define BMP085_ADDRESS 0xEE          // I2C address of BMP085 // Calibration values static signed int32 ac1; static signed int16 ac2; static signed int16 ac3; static int16 ac4; static int16 ac5; static int16 ac6; static signed int16 b1; static signed int16 b2; static signed int16 mb; static signed int16 mc; static signed int16 md; static float b5; static float _Temp;  // set after every temperature or temperature/pressure reading //---------------------------------------------- int8 BMP085ReadByte(int8 address) //---------------------------------------------- { int8 data;    i2c_start();    i2c_write(BMP085_ADDRESS);    i2c_write(address);    i2c_start();    i2c_write(BMP085_ADDRESS | 0x01 );    data=i2c_read(0);    i2c_stop();    return(data); } //---------------------------------------------- int16 BMP085ReadInt(int8 address) //---------------------------------------------- { int8 msb, lsb; int16 temp;    i2c_start();    i2c_write(BMP085_ADDRESS);    i2c_write(address);    i2c_start();    i2c_write(BMP085_ADDRESS | 0x01 );    msb = i2c_read();    lsb = i2c_read(0);    i2c_stop();    temp = make16(msb, lsb);    return ( temp ); } //---------------------------------------------- void BMP085WriteByte(int8 address, int8 data) //---------------------------------------------- {    i2c_start();    i2c_write(BMP085_ADDRESS);    i2c_write(address);    i2c_write(data);    i2c_stop(); } //---------------------------------------------- void bmp085Calibration() //---------------------------------------------- {    // read BMP085 EEPROM cal factors    ac1 = bmp085ReadInt(0xAA); //read wrong value    ac2 = bmp085ReadInt(0xAC);    ac3 = bmp085ReadInt(0xAE);    ac4 = bmp085ReadInt(0xB0);    ac5 = bmp085ReadInt(0xB2);    ac6 = bmp085ReadInt(0xB4);    b1  = bmp085ReadInt(0xB6);    b2  = bmp085ReadInt(0xB8);    mb  = bmp085ReadInt(0xBA);    mc  = bmp085ReadInt(0xBC);    md  = bmp085ReadInt(0xBE);    ac1 = bmp085ReadInt(0xAA); // read ac1 again. comes true value this time        //fprintf(debug,"b1:%5Ld,b2:%5Ld,ac1:%5Ld,ac2:%5Ld,ac3:%5Ld,ac4:%5Ld,ac5:%5Ld,ac6:%5Ld,\r\n",b1,b2,ac1,ac2,ac3,ac4,ac5,ac6);    //fprintf(debug,"mb:%5Ld,mc:%5Ld,md:%5Ld\r\n",mb,mc,md);   } // Read the uncompensated temperature value //---------------------------------------------- int16 BMP085ReadUT() //---------------------------------------------- { int16 ut;     // Write 0x2E into Register 0xF4   BMP085WriteByte(0xF4, 0x2E);   delay_ms(5); // Wait at least 4.5ms   // Read two bytes from registers 0xF6 and 0xF7   ut = BMP085ReadInt(0xF6);         return(ut); } // Read the uncompensated pressure value //---------------------------------------------- int32 bmp085ReadUP() //---------------------------------------------- { int8 msb, lsb, xlsb; int32 UP;    // Write 0x34+(OSS<<6) into register 0xF4   // Request a pressure reading w/ oversampling setting   BMP085WriteByte(0xF4, 0x34+(OVS_S<<6) );     switch (OVS_S)   {      case 0: delay_ms(5);  break;      case 1: delay_ms(8);  break;      case 2: delay_ms(14); break;      case 3: delay_ms(26); break;   }              i2c_start();       i2c_write(BMP085_ADDRESS);       i2c_write(0xF6);             i2c_start();       i2c_write(BMP085_ADDRESS | 0x01);             // Read register 0xF6 (MSB), 0xF7 (LSB), and 0xF8 (XLSB)             msb = i2c_read();       lsb = i2c_read();       xlsb = i2c_read(0); // NACK on last read       i2c_stop(); //*/             UP = make32(0,msb,lsb,xlsb);       UP >>=(8-OVS_S);           //fprintf(debug,"UP:%5Lu,msb: %02x,lsb: %02x,xlsb: %02x\r\n",UP,msb,lsb,xlsb);        return(UP); } //---------------------------------------------- signed int32 BMP085GetTemp(signed int32 ut) //---------------------------------------------- { signed int32 X1,X2, T;        X1 = (ut - ac6)* ac5 / 32768;    X2 = mc;    X2 *= 2048;    X2 /= (X1 + md);        b5 = X1+X2;        T = (b5+8)/16;        //fprintf(debug,"X1:%5Ld,X2:%5Ld,mc:%5Ld,md:%5Ld,ut:%5Ld\r\n",X1,X2,mc,md,ut);        return(T); }    //---------------------------------------------- int32 BMP085GetPressure(signed int32 up) //---------------------------------------------- { signed int32 B3,B6,X1,X2,X3,a; signed int32 P; int32 B4,B7,P2;        switch (OVS_S)   {      case 0: a=1;  break;      case 1: a=2;  break;      case 2: a=4; break;      case 3: a=8; break;   }         //CCS C gives wrong values when shifting bits in signed integers    //so, we need arithmetic operation for signed integer variables        B6 = (signed int32)b5-4000;    X1 = ((B6*B6)/4096)*b2/2048;    X2 = B6*ac2 / 2048;    X3 = X1 + X2;    B3 = ((X3 +(ac1*4))*a + 2)/4; // sint32        //fprintf(debug,"UP:%5Ld,X1:%5Ld,X2:%5Ld,X3:%5Ld,b5:%5Ld,B3:%5Ld,B6:%5Ld,\r\n",up,X1,X2,X3,(signed int32)b5,B3,B6);                X1 = (ac3)*B6/8192;    X2 = ((B6*B6)/4096)*b1/65536;    X3 = (X1 + X2 + 2) / 4;    B4 = (int32)(X3+32768)*(ac4)/32768;        B7 = (int32)(up-B3);        B7 *=50000>>OVS_S; //unsigned        //fprintf(debug,"X1:%5Ld,X2:%5Ld,X3:%5Ld,B4:%5Lu,B7:%5Lu,\r\n",X1,X2,X3,B4,B7);    //fprintf(debug,"b1:%5Ld,b2:%5Ld,ac1:%5Ld,ac2:%5Ld,ac3:%5Ld,ac4:%5Ld,\r\n",b1,b2,ac1,ac2,ac3,ac4);    P2 = (B7/B4)<<1; //unsigned        X1 = (P2>>8)*(P2>>8); //unsigned    X1 = (X1*3038)>>16;   //unsigned    P=P2;    X2 = (-7357*P)/65536;        //fprintf(debug,"X1:%5Ld,X2:%5Ld,p:%5Lu,\r\n",X1,X2,P2);        P = P + (X1+X2+3791)/16;        return(P); } //---------------------------------------------- float BMP085Pressure(boolean getTemp) //---------------------------------------------- {    if (getTemp)       _Temp = BMP085GetTemp(BMP085ReadUT());     return(BMP085GetPressure(BMP085ReadUP())); } //---------------------------------------------- float BMP085Temperature(void) //---------------------------------------------- {    _Temp = BMP085GetTemp(BMP085ReadUT());    return(_Temp); }
ajt

Joined: 07 Sep 2003
Posts: 110

Re: integer library
Posted: Tue Jul 30, 2013 10:06 am

 lazuribicci wrote: I have tested above library, but I cannot read pressure, however temperature seems good. I have researched step by step and I found faulty in calibration coefficient routine. First value, ac1, comes wrong. It should be 7000-8000 but it gives 12. So I read it again after md coefficient. It seems everything good.

This library has been successfully used for some time. Your "fix" for the ac1 coefficient error indicates a hardware problem in your setup or something in your other code that is causing the first read of the device to be in error. I suggest you find the root cause of the problem and fix that vs adding a second read as you have.

Thanks for the integer version of the library.
_________________
Al Testani
waynewy

Joined: 16 Sep 2013
Posts: 4
Location: United States

 Posted: Mon Sep 16, 2013 9:23 am Just a quick question, where did you get the i2c library in order to use i2c_start(), i2c_write(), etc? Thanks!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 6 HoursGoto page 1, 2  Next Page 1 of 2

 Jump to: Select a forum Software----------------General CCS C DiscussionCode LibraryEZ App LynxBest OfKnown Issues Hardware----------------CCS ICD / Mach X / Load-n-Go
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group