Math for A/D conversion


Closed Thread
Results 1 to 7 of 7
  1. #1
    Pickplayer's Avatar
    Pickplayer Guest

    Default Math for A/D conversion

    How can I display on PC a leading 0 for example, If I am reading a voltage of 2.0498 how do i display only 2.04? If I use Hseout
    "Voltage="dec2 I get 2.98 same with debug. The only way I can get the leading 0 to dislpay is to read out all 4 digits. I wold like to display only 2 digits .04.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Math for A/D conversion

    If you have 20498 in a variable (representing 2.0498V) and you want 2.04 divide the value by 100 so that the value becomes 204 then HSEROUT[DEC value/100, ".", DEC2 value //100]

    If you want to round off the value (instead of truncating) add 50, then divide by 100.

    /Henrik.

  3. #3
    Pickplayer's Avatar
    Pickplayer Guest


    Did you find this post helpful? Yes | No

    Default Re: Math for A/D conversion

    Thanks Henric
    The values in the variable are after divide// for remainder with 0 as leading bit remainder = 0498

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Math for A/D conversion

    Hi,
    I'm sorry, is there still a question in there somewhere or did you solve the problem?

    /Henrik.

  5. #5
    Pickplayer's Avatar
    Pickplayer Guest


    Did you find this post helpful? Yes | No

    Default Re: Math for A/D conversion

    Henrik: Yes it is still a question The values in the variable are after divide// for remainder with 0 as leading bit remainder = 0498 any time I have a remainder in a calculation of leading bit 0 debug will not read it. for instance if the remainder is 0498 debug reads 498, if I debug dec 4 then it will read all four digits. If I debug dec2 then it reads 98. I hope I made myself clear enough as to understand my delema.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Math for A/D conversion

    And the answer is the same as before. Divide by 100 then use DEC2 to display the result.

    If the variable contains 498 and you want that to display as 04 after a decimal point divide by 100 (result = 4) use DEC2 to display with a leading 0. And, again as before, if you rather round than truncate add 50, then divide by 100, then use DEC2. HSEROUT[DEC2 (498+50)/100] will display 05.

    /Henrik.

  7. #7
    PickPlayer's Avatar
    PickPlayer Guest


    Did you find this post helpful? Yes | No

    Default Re: Math for A/D conversion

    Henrik: The light finally turned on thanks!!

Similar Threads

  1. Help with the conversion math
    By Ramius in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 14th December 2014, 18:58
  2. AD conversion
    By CipiCips in forum mel PIC BASIC
    Replies: 8
    Last Post: - 19th May 2011, 01:09
  3. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 10:22
  4. conversion
    By pramodsinha in forum Forum Requests
    Replies: 2
    Last Post: - 19th January 2006, 15:58
  5. ºC -> ºF Conversion
    By CocaColaKid in forum General
    Replies: 6
    Last Post: - 15th March 2005, 09:42

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