strange A2D 5V scaling result - 16F819


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    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

  2. #2
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Default it works now

    Darrel,

    Thanks so much for the insight and the code correction. It works as expected. Now, I can see a light at the end of this tunnel. Thats what I get for saying "that should be an easy project, shouldn't take too much time at all"...mental note: never say that.

    Thanks again.
    Last edited by Max Power; - 7th April 2010 at 15:45.

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


    Did you find this post helpful? Yes | No

    Talking Yes, but just what is that light?

    The end, or the train?
    <img Height=160 Width=212 src="http://www.pbpgroup.com/files/Freight-train-light.jpg" />

    Cheers,
    &nbsp; &nbsp; 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