There was a really nice program that someone, (Bruce I think) linked to somewhere in this forum. Ive been searching for it for about half an hour now, but I can't seem to re-find it. Anyway, it was very useful because it could change a fraction into numbers that the PIC can handle. For instance, if you entered .00396 it would show you a couple options like, 2/505, with some options being more accurate than others. Hopefully someone will chime in here and show us the light.
What you have to do (without the fraction calculator tool) is try to convert your decimal into a fraction. What I did was take 1 and divide it by .00396. The result was 252.52525. So, if you multiply both side by 2, you get 505.0505/2 or pretty close to 505/2. So 2/505 = .00396
Since you need to divide by .00396, that is the same as multiplying by 505/2
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.
((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.
![]()
Bookmarks