Strugling without floating point


Results 1 to 16 of 16

Threaded View

  1. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Glenn View Post
    In my current program I would like to do:

    calcpress = ((( pressure / Vs) - 0.04 ) / 0.00396 )
    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.

    Attached Images Attached Images  

Similar Threads

  1. Getting out of floating point
    By jcb344 in forum General
    Replies: 3
    Last Post: - 5th August 2008, 21:18
  2. floating point numbers
    By n qwerty in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th April 2008, 04:18
  3. Floating Point Display Problem (serial string out)
    By Cash Olsen in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th December 2007, 02:03
  4. Microchip Floating Point Routines
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th October 2006, 19:51
  5. DIV32 instead of floating point routines?
    By Tomasm in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd April 2004, 07:50

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts