CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

HELP!! BMP085 barometric/pressure sensor
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
maka05



Joined: 22 Jul 2011
Posts: 6

View user's profile Send private message

HELP!! BMP085 barometric/pressure sensor
PostPosted: Sat Jul 23, 2011 2:38 am     Reply with quote

Hi, last day i bought a barometric pressure sensor in a shop. I thought that it was easy to use because it have a I2C interface.

I do many proves but i never have a good result. Can somebody help me, please? I'm desperate!!

I'm using 16f876 PIC and her C3 and C4 pins. I put pull up resistor.

There is the datasheet.

http://www1.futureelectronics.com/doc/BOSCH/273300144.pdf


Thanks!!
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jul 23, 2011 4:21 am     Reply with quote

Well right off the datasheet I see it's designed for '3 volt' operation. What is the PIC power supply ? If 5 volts, then you'll need level translators between the chips OR get a low voltage PIC.
Do you properly configure the XCLR pin of the sensor ?
Do you have the correct value pullups based on speed, Vcc, etc. ?
Also show us your code. Can't tell what is wrong there without seeing it
The datasheet clearly shows and tells how to effect the I2C communications, registers, etc. so until we see your code we can't tell what is wrong.
maka05



Joined: 22 Jul 2011
Posts: 6

View user's profile Send private message

PostPosted: Sat Jul 23, 2011 12:30 pm     Reply with quote

I like to said that i don't have any idea in i2c bus. it's a new technology communication for me because i usually use USART communication.

I have connected the sensor to 3.3 volts and i put pull up resistors for 4k7.

I do a lot off proves but this is the only that a have a reply.
Code:

#include <16F876.h>
#fuses XT,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)


#use i2c(Master, SDA=PIN_C4, SCL=PIN_C3)



void main(void)
{
   int a,b,c;
   i2c_start();
   while(1)
   {
      a=i2c_read(0xAA);
      printf("%i",a);
   }
}
 
 

With this code, I have the all time the same result. The hyperterminal show -1 data all the time.

I hope you could help me because I'm starting to learning it.

Thanks!!
maka05



Joined: 22 Jul 2011
Posts: 6

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 3:35 pm     Reply with quote

Please...could somebody help me?
I'm desperate!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 7:06 pm     Reply with quote

You are trying to use I2C, you have no clue as to what it is but want us to give you some answer that you can copy/paste and be ready with it? Sorry, that is not how we do it in this forum. Writing an answer for you takes time from us, so we like to see you have spent some time finding the answer first. This way you will learn something from it.

Hint: in I2C it is possible to connect many devices to the same two wires. How do these devices 'know' the Master wants to talk to them?
Hint 2: are you using that command?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 8:08 pm     Reply with quote

Hint 3: read the I2C spec http://www.nxp.com/documents/other/39340011.pdf
_________________
The search for better is endless. Instead simply find very good and get the job done.
Ttelmah



Joined: 11 Mar 2010
Posts: 19333

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 3:08 am     Reply with quote

Look at section 4.4 of the data sheet.
This is the sequence needed to be sent to the chip, to start a conversion.
Then look at section 4.5. This is the sequence needed to _read_ the conversion.
You have to start with a 'start' (you have this), followed by the _device address_ (you don't have this), which then includes a direction 'flag' to say what way the following data is to transfer.
I2C, is only 'half duplex'. You send data in one direction at a time, so your command where you try to send the register address, and read the data at the same time, is never going to work.

Separately though, there is still the issue of voltage. The I2C input of the PIC, _requires_ a signal that goes up to 0.8* the supply rail. So 4v, for a 5v PIC. A 3.3v chip is not going to do this. Hence you _will_ need voltage level translators, or to switch to a PIC that can run at a lower voltage.

Best Wishes
maka05



Joined: 22 Jul 2011
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:17 pm     Reply with quote

Thanks a lot for all.

Now I'm doing proves to understand the I2C communication.

I have a question about the voltage output of the PIC and the input of the sensor. Can i put a voltage divider in the exit of pic to translate her 5 volts to 3 volt? Can it work?

Thanks!!
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:25 pm     Reply with quote

Take a look at this:
http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf
_________________
Google and Forum Search are some of your best tools!!!!
maka05



Joined: 22 Jul 2011
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:25 pm     Reply with quote

Hi, i have an other question.

Can the sensor broke if i put 5 volts inte suply voltage and 5 volts in the sda and scl pins?

Thanks!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:28 pm     Reply with quote

You can eliminate this problem if you use software i2c on PortA or PortB.
Those two ports have TTL input voltage levels on all their pins (except pin
RA4). This means that you can use 3.3v pull-up resistors, and the voltage
levels will meet the requirements of the PIC's i/o pins. It's only PortC
pins that have the higher input voltage level requirements. Look at this
table in the data sheet to see the input types (look in the Buffer Type column):
Quote:

OVERVIEW

TABLE 1-1: PIC16F873 AND PIC16F876 PINOUT DESCRIPTION


To do this, change your #use i2c statement to use pins on PortB or PortA:
Code:

#use i2c(Master, SDA=PIN_B0, SCL=PIN_B1)
 

And also move your circuit connections over to those new pins.
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:30 pm     Reply with quote

According to the datasheet the absolute max supply voltage is 4.65 volts so yes, you may have blown it...
_________________
Google and Forum Search are some of your best tools!!!!


Last edited by dyeatman on Mon Jul 25, 2011 12:30 pm; edited 1 time in total
maka05



Joined: 22 Jul 2011
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:30 pm     Reply with quote

oh the idea that i said is soo stupid XD a voltage dividir...stupid!

forgiveness
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:32 pm     Reply with quote

I use the MOSFETs detailed in the document I listed and they work great...
_________________
Google and Forum Search are some of your best tools!!!!
venusar



Joined: 25 Jul 2011
Posts: 2

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 12:43 pm     Reply with quote

Hi, i find a library for BMP085 but it don't works in ccs. It makes compile error and i can't fix because i'm new with this compiler.

If somebody could fix it, we could have a library for this sensor.

http://www.bosch-sensortec.com/content/language1/downloads/API_BMP085.zip
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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