Floating point math


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Not the whole answer, but..

    This works fine, and I get a value that varys between 11 and 90. (When just outputting it to an LCD)

    BUT, now I want to know what the real value is, not this representation of the actual voltage.
    Assuming an ADCIN of 10bits:
    The displayed value comes from Vdd/10bit or 5V/1024= 4.88mv per bit. So 11* 4.88mv= 53.7mv and 90*4.88mv= 439.5mV. I would measure with a DMM to confirm or use a known good voltage at say 2.5V to see a reading of 512 on your display.
    Knowing this, you might be able to multiply the ADCIN value to another for your desired display.
    Louie

  2. #2
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LinkMTech View Post
    Assuming an ADCIN of 10bits:
    The displayed value comes from Vdd/10bit or 5V/1024= 4.88mv per bit. So 11* 4.88mv= 53.7mv and 90*4.88mv= 439.5mV

    Aaah.. ofcourse, stupid me, if I had stopped looking for answears in the manual and instead been thinking of how a DA-converter works this would have been obvious.

    Still, how do I handle decimals ? ..if I just want to display the voltage on the LCD to begin with ? ..and then cobnvert it to a real value with the formula ?

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Make'm whole

    I usually take my decimal numbers and multiply them up to make it an integer. Take this simple equation as an example:
    15 * 3/5 = 9
    Since 3/5=.6
    I mulitiply .6 by 10 to get 6. And divide the whole thing by 10 afterwards.
    (15*6)/10=9
    I know this is kinda simple but with calculator in hand along with trial and error to check my math (I'm a little weak) I eventually get there.
    Louie

  4. #4
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Over zealous

    Forget that lame suggestion, here's a better one from the experts:

    http://www.picbasic.co.uk/forum/showthread.php?t=712
    Louie

Similar Threads

  1. Strugling without floating point
    By pjsmith in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 27th March 2011, 06:29
  2. Replies: 5
    Last Post: - 28th May 2008, 10:20
  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. Floating Point
    By jrudd in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th May 2005, 14:19
  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 : 0

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