strange A2D 5V scaling result - 16F819


Results 1 to 4 of 4

Threaded View

  1. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    While it is incorrect, the results are not strange at all.

    The Modulus operator only returns a decimal number if you are dividing by a factor of 10 (10,100,1000).

    When you // 1024, the result will be from 0 to 1023.
    The numbers at 201, 202 are where the value goes over 1000, but you are displaying the lowest 3 digits.

    For 3 decimals, the easiest way to do it is ...
    Code:
    W0 = A2Dvalue * 5000
    W0 = DIV32 1023
    
    DEBUG REP $00\8,13,10, "Voltage = ",DEC W0/1000,".",DEC3 W0, "   A2D value = ",DEC A2Dvalue
    Last edited by Darrel Taylor; - 7th April 2010 at 03:40. Reason: removed //
    DT

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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