View previous topic :: View next topic |
Author |
Message |
maka05
Joined: 22 Jul 2011 Posts: 6
|
HELP!! BMP085 barometric/pressure sensor |
Posted: Sat Jul 23, 2011 2:38 am |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Sat Jul 23, 2011 4:21 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
maka05
Joined: 22 Jul 2011 Posts: 6
|
|
Posted: Sat Jul 23, 2011 12:30 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
maka05
Joined: 22 Jul 2011 Posts: 6
|
|
Posted: Sun Jul 24, 2011 3:35 pm |
|
|
Please...could somebody help me?
I'm desperate! |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jul 24, 2011 7:06 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Jul 25, 2011 3:08 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
maka05
Joined: 22 Jul 2011 Posts: 6
|
|
Posted: Mon Jul 25, 2011 12:17 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
![](templates/subSilver/images/spacer.gif) |
maka05
Joined: 22 Jul 2011 Posts: 6
|
|
Posted: Mon Jul 25, 2011 12:25 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 25, 2011 12:28 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Mon Jul 25, 2011 12:30 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
maka05
Joined: 22 Jul 2011 Posts: 6
|
|
Posted: Mon Jul 25, 2011 12:30 pm |
|
|
oh the idea that i said is soo stupid XD a voltage dividir...stupid!
forgiveness |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Mon Jul 25, 2011 12:32 pm |
|
|
I use the MOSFETs detailed in the document I listed and they work great... _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
venusar
Joined: 25 Jul 2011 Posts: 2
|
|
![](templates/subSilver/images/spacer.gif) |
|