Announcements

Sign up for the EV Webinar for FREE and find out how you can best apply Pressure Sensors to EVs.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Pressure Sensors Forum Discussions

kirtansoni13
Level 1
Level 1
First like received 5 sign-ins First reply posted

Hello everyone,

My name is Kirtan Soni and I am trying to interface the infineon's KP253 pressure sensor with the arduino mega. So far I have been able to get the output readings from the sensor (not what I need) and I think that I am using the correct SPI protocol as per give data sheet.

I am getting a diag1 error (As per datasheet) in my readings. I will explain what I did in depth below:image.png

This is my circuit diagram. According to the datasheet the KP253 has a 16bit SPI transfer register the protocol is MSB first, 0.1 - 5 MHz clock speed, model 1. I have used the SPI.transfer16() to read and write to the register of the sensor, I am getting the readings and the readings are also changing with the rise and drop of temperature.

To check whether my connection and program is right I also write the identifier code and it gives me proper response as indicated in the datasheet.

This is the output I get by converting it to binary, I get - 0101000100110111 which is correct.

But when I write the temperature read command it gives me - 0101001011000110

So according to the response structure I get Diag1 error - 010

Here is my code:

 

#include<SPI.h> //Library for SPI

const int CS=4;
volatile int Response;

void setup (void)
{
Serial.begin(115200);
pinMode(CS,OUTPUT);
digitalWrite(CS,HIGH);
}

void loop(void)
{
digitalWrite(CS,LOW);
SPI.begin();
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE1));
Response = SPI.transfer16(0b0100000000000000);
SPI.end();
digitalWrite(CS,HIGH);
Serial.println(Response);
}

 

I tried everything that I knew but I don't know what am I doing wrong?
Thank you for your time.

kirtansoni13_0-1668024862723.png

 I really appreciate your efforts.
To make your efforts a bit easy I am attaching the link to the datasheet as well.

https://www.infineon.com/dgdl/Infineon-KP253-DS-v01_01-EN.pdf?fileId=5546d46254e133b40155731edd7563d...

0 Likes
1 Solution
GeorgeT
Moderator
Moderator
Moderator
50 solutions authored 25 likes received 5 likes given

Hi @kirtansoni13,

The calculations are correct, but the temperature is not as expected.

Could you please verify whether you are using KP256 pressure sensor instead of KP253?

In the case of KP256 the diagnosis code is 5-bit and with the data shared there is no error.

In this case the temperature data is 10-bit and on calculation the temperature is around 29 degree Celsius, which is room temperature, as expected.

The remaining bit is the parity bit.

Thanks and regards,

George

View solution in original post

7 Replies
GeorgeT
Moderator
Moderator
Moderator
50 solutions authored 25 likes received 5 likes given

Hi @kirtansoni13 ,

Sorry for the delay in the reply.

We are working on the query and will get back soon.

Thanks and regards,

George

Hello George,

Thank you for your consideration. I hope we will have this solved.

0 Likes
GeorgeT
Moderator
Moderator
Moderator
50 solutions authored 25 likes received 5 likes given

Hi @kirtansoni13,

As seen in the screenshot from the product datasheet (page-16) attached: "This diagnosis code is not valid until a self diagnosis is triggered by sending the Trigger diagnosis command" 

kp253_diagnosis_command.png

So could you please repeat the measurement after ignoring this diagnosis codes?

Please let me know if you are getting the correct values after measurement.

Thanks and regards,

George

0 Likes
kirtansoni13
Level 1
Level 1
First like received 5 sign-ins First reply posted

Hello George,

Thank you so much for your reply and extremely sorry for replying a bit late.

If I understood your advice correctly you are telling me to ignore the diagnosis error and measure the temperature, correct?

So if I measure the output from the sensor, it is still around 21190 if we convert into binary we have 0101001011000110

As per the response structure mentioned in the datasheet the above response will be:

Diag error - '010'

Sensor data - '100101100011'

Parity bit - '0'

Now if we convert the sensor data bits to decimal we get 2403 and it is mentioned in the datasheet

aCisMdGDWiwA.png

The ADC range is 0 - 4095 respectively the temperature should be -40C - 160C. If we convert our sensor data 2403 -> then the temperature is 56C which is not correct 😅

Am I doing the calculations correctly?

I also soldered a capacitor as per datasheet but the results are still the same and also tried with multiple sensors😕

Waiting for your response.

Thank you,

Kirtan Soni

0 Likes
GeorgeT
Moderator
Moderator
Moderator
50 solutions authored 25 likes received 5 likes given

Hi @kirtansoni13,

The calculations are correct, but the temperature is not as expected.

Could you please verify whether you are using KP256 pressure sensor instead of KP253?

In the case of KP256 the diagnosis code is 5-bit and with the data shared there is no error.

In this case the temperature data is 10-bit and on calculation the temperature is around 29 degree Celsius, which is room temperature, as expected.

The remaining bit is the parity bit.

Thanks and regards,

George

Hello @GeorgeT 

Yes that was the issue! I was working with the wrong datasheet all along, that is silly 😅

Thank you so much for your time and help!

kirtansoni13
Level 1
Level 1
First like received 5 sign-ins First reply posted

Hello @GeorgeT ,

I saw the datasheet of KP256 and both looks similar just the structures are different so,  yes that makes sense! Please give me some days to revalidate if the sensor is KP256 or not.

Finally I have a new lead to follow thanks to you!

Thank you, 

Kirtan Soni

0 Likes