Anyone used the Bosch BMP085 I2C baro sensor yet ?


Closed Thread
Results 1 to 40 of 52

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mr.sneezy View Post

    PS. Is there a simple to use utility, MCS add-on or method that will show me the amount of RAM space my code is using when compiled (as well as program space) ?
    Nice work on the sensor code!

    MCS shows you how much code is being used at the bottom of the page after compliling. (Note it does need a successful compile to be able to tell you this.)

    Name:  size.png
Views: 4366
Size:  17.1 KB

    You can also peek in the .lst file, and find code used vs left.

    Code:
    MEMORY USAGE MAP ('X' = Used,  '-' = Unused)
    
    
    0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0140 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0180 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXX-------
    0200 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0240 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0280 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    02C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX ---------------- ----------------
    2000 : -------X-------- ---------------- ---------------- ----------------
    
    All other memory blocks unused.
    
    Program Memory Words Used:   665
    Program Memory Words Free:   359
    Then there is also Darrel's CodeSpace utility here:
    http://www.picbasic.co.uk/forum/showthread.php?t=2418
    Last edited by ScaleRobotics; - 28th May 2010 at 15:21.

  2. #2
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Nice work on the sensor code!
    Thanks, although it's not complete just yet. I'll show you the main sensor code snip in case you are interested. It complies now (if selecting a bigger PIC) and I know the result of the lCTemp section is 100% correct (+ & - Deg C ). The UPres calculations are as of right now untested.
    If you see any blindingly obvious code bloat in the calculations let me know...
    I will post the complete code as soon as I know it works fine.

    I did know what the code size used was telling me in MCS, I was more curious about RAM (variables etc) as I have been caught before going to a PIC with more code space, only to be quickly stumped by running out of variables...

    All variables are signed Longs, except MD, AC5 and AC6 which are Words.
    Code:
    'Calculate temperature in 1/10ths of Deg C  from lUTemp     ' Note 2^15 = 32768 Dec or $8000
            X1 = ((lUtemp - AC6) * AC5) / $8000     'find X1 
            X2 = (lMC << 11) / (X1 + MD)            'Find X2
            B5 =  X1 + X2                           'Find B5 from X1 and X2
            lCTemp = (B5 + 8) / 16                  'Hey presto, lCTemp appears... 
              
    'Calculate pressure in Pa from lUpres (1/100th's of hPa's)        
            B6 = b5 - 4000
            x1 = (b2 * (B6 * B6 / $1000)) / $800 
            x2 = (lac2 * B6) / $800
            x3 = x1 + x2
            B3 = ((lac1 * 4 + x3) << 5) / 4         'My OSS = 3 (might need to * here not <<)
            x1 = (lac3 * b6) / $2000
            x2 = (b1 * (b6 * b6 / $1000)) / $10000
            x3 = ((x1 + x2) + 2) / 4
            B4 = (lac4 * (x3 + 32768)) / $8000
            B7 = (lUPres - B3) * 50000
            If B7 < $80000000 then 
                lPres = (B7 * 2) / B4
            Else
                lPres = (B7 / B4) * 2
            Endif
            X1 = (lPres / 256) * (lPres / 256)
            X1 = (X1 * 3038) / $10000
            X2 = (-7357 * lPres) / $10000
            lPres = lPres + ((X1 + X2 + 3791) / 16)
    
            Serout2 SO,16780,["T=",DEC lCtemp,"    "]       'Send Word size number to LCD
            Serout2 SO,16780,["P=",DEC lPres,"     "]      'Send Word size number to LCD

Members who have read this thread : 0

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

Posting Permissions

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