Today 09:04
Forum: Website / Forum Issues
Starter: Lester
Views: 0
Replies: 1
Today 08:48
Forum: Proton Plus Compiler v3
Starter: IstvanK
Views: 0
Replies: 6
Go to last post By: Lester
Today 08:44
Forum: Test Postings
Starter: Lester
Views: 0
Replies: 3
Yesterday 22:15
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 0
+ Reply to Thread
Page 4 of 4 FirstFirst ... 234
Results 31 to 39 of 39
  1. #31
    Junior Member superdat's Avatar
    Join Date
    Nov 2017
    Posts
    9
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    0

    1 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    Quote Originally Posted by Les View Post
    Floating point is Floating point, regardless if it is a PIC16F887 or a PIC18F25K20 or an AVR etc....

    The compiler's underlying asm code is better than 99% of all compilers out there. Both I2C and SPI do not require huge speeds and if the compiler uses too much RAM or flash code space within the device, it will inform the user with an error message.

    I noticed in your code, you have huge expressions, with will eat up a lot of space within the flash, as it will with all devices and compilers, regardless. This is because a compiler must take the worst case scenario with each piece of the expression, which is also the highest use of both RAM and flash. This is a back throw of C, which is normally simply copy and pasted from PC applications, regardless of the fact that it is now running on a small microcontroller that does not have gigabytes of RAM. This will cause problems with both speed and size on any microcontroller. That's always been the problem with C and C++. Copy and pasting from a very large platform to a tiny platform causes so many issues, but most "programmers" simply do not understand the complexities anymore. Unfortunately, we live in a copy and paste world, without much actual learning going on anymore :-(

    Bottom line, is that the compiler is very much capable of interfacing to the peripheral and calculating the expressions, but a 16F887 device is very tiny and very old now, so even when completed, it will not have a lot of room left for any other code inside it. That's also one of the big problems with the internet these days. The vast majority of information on it is many years old, so the general user is stuck with very old code on old devices. Always remember, on any microcontroller, always think low level, but write high level. This way you will get the most out of any device.

    I don't have a BME peripheral, but if I did, I would create some simple code that would show you it working on 99% of all 14 and 18F PIC devices, as it is a simple interface, with straightforward maths behind it, even though it is actually far too much maths for a simple peripheral device that doesn't actually do a lot. :-) Bob Already showed that an interface to it is actually quite straightforward to do. Adapting Bob's code for a 14-bit core 16F887 devie requires approx 6K of flash memory, on a device that only has 8K of it. The RAM usage is approx 180 words from the device's 368 words available, so it will still fit. All that is required is a subroutine to do the Pow.
    Hi Les
    Firstly my comment "it must be something to do with the compiler" is in no way a criticism of Proton Basic. Ignoring the differences between I2C and SPI in the code supplied by Bob Marshall, it doesn't work with a 16f887.
    The part that doesn't work is what I call equations and I'm assuming these are what you refer to as Expressions, I'm not a mathematician or an expert programmer so my use of terminology my not be absolutely correct. As stated by Bosch the BME280 is designed for use in mobile phones and the code they supply in the data sheet appears to C. Expressions/Equations are so complex that unless you are a mathematician, Cut and Paste is the only option. The Humidity version in Bob's code is (I think) for 64 bit floating point, I've changed this for the slightly simpler 32 bit version. The other 2 compilers I tried can't handle this in one bite so it had to be broken down. Beacause of
    the masses of parenthesis, this was not an easy task. The 2 compilers mentioned don't even have the level of variables offered by Proton and they don't work 100% with this MC. Since there was an example of the code for Proton, I decided to try.
    So back to my comment about the compiler, all I meant was, there is something happening between the compiler and the MC that prevents the experssion/equation being completed. The "weak link" seems to be the 16f887.
    The BME works perfectly on an Arduino but that of course is C/C++ & M328P so not easy to convert to PIC
    You might ask why I'm using 16f887? Because I have some and I'm familiar with them.
    I've spent a lot of time trying to get this to work and have come to the conclusion it isn't worth any more effort. Either get an 18f or learn how to program the Arduino for my needs. I'm not keen on the Arduino because I prefer to develop my own code (regardless of how good or bad, it is a hobby). So unless I want to learn C/C++ which I don't, it will be cut and paste + a bit of tinkering to make the bits work together.

    I've only been using Proton for a few weeks and once I'd got over the differences between IDEs, I was very impressed by the programming tools and options

  2. #32
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,271
    Thumbs Up
    Received: 24
    Given: 4
    Total Downloaded
    331.30 MB

    1 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    Hi Superdat,
    I am no mathematician but this is how I think the complex lines for humidity can be broken down, unfortunately I do not have a device and the ones I have ordered I have now been told are BMP280.
    It compiles so hopefully I have got it right, it could probably be broken down even more/better but it should be a start.
    Hopefully it is commented enough.
    Code:
    '---------------------------------------------  
    'Create some temporary variables
    Dim    Temp_H As Float                           
    Dim    TempFloat_1 As Float
    Dim    TempFloat_2 As Float                           
    Dim    TempFloat_3 As Float  
    Dim    TempFloat_4 As Float   
    'As required
    Dim    TempFloat_5 As Float  
    Dim    TempFloat_6 As Float  
    '---------------------------------------------  
      
    
    
    
    'Humidity Calculations.
          H = T_fine - 76800
          
    'This line can be broken down into more manageable lines      
    '         <----------TempFloat_1---------->      <TempFloat_2>    <----TempFloat_3---->        <-----TempFloat_4------->
    '   H  = (UH - (H4 * 64.0 + H5 / 16384.8 * H)) * (H2 / 65536.0 * (1.0 + H6 / 67108864.0 * H * (1.0 + H3 / 67108864.0 * H)))
          Temp_H = H
          TempFloat_1 = H4 * 64 + H5 / 16384.8 * Temp_H
          TempFloat_2 = H2 / 65536
          TempFloat_3 = 1 + H6 / 67108864
          TempFloat_4 = 1 + H3 / 67108864 * Temp_H
    'Try this line or the ones below marked '*'      
           H  = (UH - (TempFloat_1)) * (TempFloat_2 * (TempFloat_3 * Temp_H * (TempFloat_4)))
    
    'And possibly even more
    '            <--TempFloat_5-->                     <-----------TempFloat_6------------> 
    '      H  = (UH - (TempFloat_1)) * (TempFloat_2 * (TempFloat_3 * Temp_H * (TempFloat_4)))
    
    'Try either the line above or comment it out and uncomment these 3
    '*'      TempFloat_5 = UH - TempFloat_1
    '*'      TempFloat_6 = (TempFloat_3 * Temp_H * (TempFloat_4)) 
    '*'      H  = TempFloat_5 * (TempFloat_2 * (TempFloat_6))
    Bob
    Last edited by RGV250; 5th December 2017 at 12:43.

  3. #33
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,361
    Thumbs Up
    Received: 49
    Given: 124
    Total Downloaded
    2.37 GB

    0 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    Over a year or so, they can be worth a hundred pounds or so, because up to 30 free devices can be ordered every month.
    I have signed up and placed my first sample order (I hope). It seems you can order 2 devices per order and place 3 orders in a month (those numbers are for Ireland YMMV). Not sure what happens after that. Even at that its 6 free devices so give it a spin.

    BTW the signup response was real quick so I guess it's automated with a email address blacklist.
    Last edited by towlerg; 5th December 2017 at 20:08.
    George

  4. #34
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,247
    Thumbs Up
    Received: 234
    Given: 87
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    Always make sure you increase the amount of devices in each sample and update the cart George. Otherwise, it defaults to a single device per sample. It ranges from up to 3 devices per sample to 5 devices per sample, and you can have 6 samples.

    New samples can be ordered every 28 days.

    Over a year that is a lot of absolutely free devices, with some of the devices costing up to 7 or more. That's where I get all of my dsPIC devices because they are actually quite expensive units unfortunately. Microchip seem to be increasing the price of the devices they eventually want to dump :-(
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  5. #35
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,361
    Thumbs Up
    Received: 49
    Given: 124
    Total Downloaded
    2.37 GB

    0 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    Thanks for the tip.
    George

  6. #36
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,247
    Thumbs Up
    Received: 234
    Given: 87
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    I forgot to say. It's called "Manage Cart" to increase the amount of devices per sample. Then don't forget to update cart or they won't be altered. Then go to the checkout to confirm the samples.

    You will receive emails very soon afterwards to confirm your sample order, then a couple of days later, you will receive an email saying they are in transit.

    I've gotten samples from all the semiconductor manufacturers for many years now, without any business emails. I eventually had to dump a huge box full of them when we moved back up north, unfortunately.

    One of the best is maxim. They have some wonderful devices and a lot are available for sampling. Many years ago, all of the devices were available for sampling from maxim and linear and Texas etc... However, they seem to be clamping down somewhat, but some are still available. Also go to the more obscure semiconductor manufacturers, create a sign in, and try for samples. Over time, you'll get hundreds of devices from LEDs, MOSFETS, transistors, cases, to the more complex chips like accelerometers etc...

    I got a load of FRAM chips a few years ago, even though I wouldn't even think of using them in a project because they are so expensive, but I wanted to see if I could interface with them etc...
    Last edited by Les; 6th December 2017 at 17:09.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  7. #37
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,361
    Thumbs Up
    Received: 49
    Given: 124
    Total Downloaded
    2.37 GB

    0 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    I forgot to say. It's called "Manage Cart" to increase the amount of devices per sample
    Thanks for the tip, I got 2 x 3 devices this time
    George

  8. #38
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,271
    Thumbs Up
    Received: 24
    Given: 4
    Total Downloaded
    331.30 MB

    0 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    Hi Les,
    Thanks for reminding me of this, I used to get them and then they said that it had changed for Europe and you had to request them from the local distributor.
    I have just tried and it seems to work for me again.

    Bob

  9. #39
    Member Henk57's Avatar
    Join Date
    Jan 2014
    Posts
    212
    Thumbs Up
    Received: 12
    Given: 21
    Total Downloaded
    192.60 MB

    3 Not allowed!

    Default Re: BME280 Humidity/Pressure/Temperature code

    In message #4 I wrote;
    Quote Originally Posted by Henk57 View Post
    Yesterday, I become my BME280 (Adafruit), next week I 'll try it out.....
    That was in July 2016.
    Until now I was so busy, and I finisched yesterday.

    If you use the Adafruit PCB then you must connect SDO to (Dig.) GND, otherwise the I2C Adress is $EE and not $EC.
    (Symbol BME280 = $EC 'BME280 I2C address)

    Otherwise you have not any readings

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 2
    Last Post: 6th December 2014, 15:58
  2. Replies: 2
    Last Post: 6th December 2014, 15:58
  3. [SOLVED !] Temperature & Humidity Data Recorder Project
    By oldspring in forum The Lounge
    Replies: 0
    Last Post: 9th July 2008, 18:02
  4. I2C Sensors - Humidity and Barometric Pressure
    By picnaut in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 1st November 2007, 22:57

Members who have read this thread : 56

Actions :  (Set Date)

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

Tags for this Thread

Posting Permissions

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