View previous topic :: View next topic |
Author |
Message |
joseph
Joined: 14 Jun 2010 Posts: 16
|
Omron Pressure Sensor 2SMPB-01-01 problem... |
Posted: Wed Jan 07, 2015 10:00 am |
|
|
Hi everybody !
I'm trying to talk with a I2C pressure sensor (Omron 2SMPB-01-01) but i have some problems....
I use a development board Explorer16 from Microchip with a pic24f, a breakout board with the sensor.
I'm able to access to the register, write a value and read after. For have the pressure value, you have read the internal raw temperature, raw pressure, and calibration value.
My problem is the values are too big for to be true...
So, I look for someone who has already used this sensor for assistance.
Please tell me what !
thanks ! ![Very Happy](images/smiles/icon_biggrin.gif) |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Wed Jan 07, 2015 11:16 am |
|
|
You should post your code so we can see how you're 'doing the math'. It could be reading the wrong register, improper casting and wrong braces...
Also post which PIC and compiler version...might be a bug in compiler.
jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Wed Jan 07, 2015 12:14 pm |
|
|
The obvious thing that might well give silly results is how you convert 24bit data to 32bit.
Are you attempting the temperature compensation or just looking at raw data?.
What power mode is the chip in?. This changes the returned value by 4*.
Remember the MSB arrives first, if you are using a sequential read to access the bytes.
In high accuracy mode each count, is 0.06pA. So 16.66 counts per Pascal. Remember atmospheric pressure is over 100000 Pascals. Large counts....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
joseph
Joined: 14 Jun 2010 Posts: 16
|
|
Posted: Thu Jan 08, 2015 2:57 am |
|
|
For beginning, thanks a lot for your reply..
So as you asked me, i share my code :
Code: |
//-------Read 8bits register----------------------------
int8 read_data8(adress)
{
int8 data;
i2c_start();
i2c_write(write_adress);
i2c_write(adress);
i2c_start();
i2c_write(read_adress);
data=i2c_read(0);
i2c_stop();
return data;
}
//-------Read 16bits register---------------------------
int16 read_data16(adress)
{
int16 data;
i2c_start();
i2c_write(write_adress);
i2c_write(adress);
i2c_start();
i2c_write(read_adress);
data=i2c_read();
data=data<<8;
data=data+i2c_read(0);
i2c_stop();
return data;
}
|
Code: |
//----Read raw temperature------------------------------------
int32 data;
write_data8(I2C_SREQ,sensor_PTAT);
delay_ms(10);
data=make32(0,read_data8(I2C_TXD0),read_data8(I2C_TXD1),read_data8(I2C_TXD2));
printf("Raw Temp: %ld\n\r",data);
|
Ttelmah, i'm little surprise about your comments about the power mode... i will read a other time the datasheet. |
|
![](templates/subSilver/images/spacer.gif) |
|