Menu

Possible error in bmp.h

Help
MBB
2025-03-02
2025-03-04
  • MBB

    MBB - 2025-03-02

    I've been looking at the bmp.h include file and noticed a possible error.

    In lines 527 to 531 it says:

      'Press = Press + ((var2 + var1 + dig_P7)/16)
      BME280_LongTemp = var1 + var2 + dig_P7
       Press = BMPshiftR(Press,4) + Press
      BME280_CalcPress =  Press - BME280_AltitudeAdjustment   ' 3240  ' altitude adj
    

    end function

    Based on the first line 'Press = Press + ((var2 + var1 + dig_P7)/16)

    It seems that this line Press = BMPshiftR(Press,4) + Press
    should read:
    Press = BMPshiftR(BME280_LongTemp,4) + Press

     i.e replace   Press,4   with    BME280_LongTemp,4)
    

    Am I correct?

     
  • Anobium

    Anobium - 2025-03-03

    Yes, your change makes sense.

    But, does the BMPshift() function support Long?

     
  • mmotte

    mmotte - 2025-03-03

    It has been a long time since i made this.

    Yes, there are routines for long shift left and long shift right and signed multiplies at the end of the library.

    Your change sounds logical. try it out!

    This library could be rewritten now that you have floats working. I don't know if i have the energy to do that. The present library took a year (long winter ) to do.

    GL
    Mike

     
    • Anobium

      Anobium - 2025-03-03

      I would recommend keeping with integers. It is portable code, as the AVR does not currently support floats, and it will be faster.

       
  • MBB

    MBB - 2025-03-03

    mmotte,

    I have a question, if you can remember the answer.

    In Data Sheet Section 4.2.3 Compensation formulas, it says:

    "Both pressure and temperature values are expected to be received in 20 bit format,
    positive, stored in a 32 bit signed integer. Humidity is expected to be received in 16 bit format,
    positive, stored in a 32 bit signed integer."

    But Table 16 shows the dig_xx compensation values as one or two bytes.
    Table 18 shows the pressure and temperature data is three bytes and humidity is two bytes.

    So, what does " stored in a 32 bit signed integer" mean?

     
    • Anobium

      Anobium - 2025-03-03

      Does it mean iEEE format ?

       
  • mmotte

    mmotte - 2025-03-03

    Egg on my face. I can't find the demo code and I lost the laptop that I developed it on. There is a back up somewhere...argh ...not in demos

    " stored in a 32 bit signed integer" mean?
    It talks about fixed point math. So is that why all the shifting is done? i am not sure

    So the compensation, are they doing curve fitting?

    That is my 2 guesses.

    mike

     
  • MBB

    MBB - 2025-03-04

    Thanks!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.