Quote Originally Posted by scalerobotics View Post

[ x8 Alot of interesting stuff cutted 8x ]

Since you need to divide by .00396, that is the same as multiplying by 505/2
Forgive me for being stupid, but how do I do that ? ( value * (505 /2 )) ?

Quote Originally Posted by scalerobotics
The left side of your equation is a little harder. I am going to assume you have a 10 bit a/d converter. So I am going to say your 5v = 1024. So your Pressure will be somewhere between 0 and 1024.
Yes, the input is a pressure sensor and the vref for it is 5v, I also use a 10bit AD, so 5v = 1024 and 0v is 0.

My idea was to first convert this value to voltage, and put that value into the next step.

However this is a bit strange, coz if 5v == 1024, each step is 0.0048828125 . then a reading of 40 == 0.1953125, BUT, if I measure the output pin with a multimeter I get 0.205v ?

Ah, maybe its not really 5v I thought ? ..measured it, and ok, 4.97, that makes each step 0,004853515625, and then the value is 0,194140625 ? Hmm Hmm..

I also tried another multimeter, and that showed 0.20 (at the sensors output pin), so I guess thats not the problem.

But as I understand you I dont have to convert it first at all ?

Quote Originally Posted by scalerobotics
((Pressure * 1024) - 0.04) * (505/2)

now that .04 sure would be nice to get rid of. So we can multiply that by 25, but we will also have to divide it by 25, so we keep the number the same. We will also have to multiply Pressure by 25, since it too will be divided by 25.
Hmm, ok, sounds logical..

To be sure that everything is clear here I'll try to describe what I'm tryiong to do in detail.

Basically I want to read a pressure sensor (Freescale MPX4250D) with my pic (PIC16F877A) using a analog pin (AN5) with a 10bit AD-converter. I want the value in kPa or Bar.

Reading the Pressure sensors datsheet I found:

Vout = Vs* (0.00369*P + 0.04) ± Error

..Wich I thought would be the same as

calcpress = ((( pressure / Vs ) - 0.04 ) / 0.00396 )

..I can be wrong here, I'm not very fond of math, and it was many years ago I used my (nearly not existing) mathskills..

Also, if I understand what you wrote before, I really dont have to convert the output to voltage first ?


..Another thing, its very hard to test this stuff.. how do I create a known pressure ? ..I know that the car repairers have a little thing that they use to create pressure or vaccuum witha meter on it, but I guess they are expensive.