Maximum value of ADCIN


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582

    Default Maximum value of ADCIN

    I try to find myself the answer on this question, but I am not sure if I understand correct. Please, help me ! I read, for 7 seconds, the value of ADCIN, using 12F675 ; I need to memorize
    the maximum (the highest) value of reading. It's like this OK ?
    Code:
     for cnt=1 to 70       			
    	adcin 3, v_cal
      	v_cal=v_cal * 5000            ' I use VDD as Vref
      	v_cal=div32 1023
     ' 	vmax=0 max v_cal             ' it's this
          or
     '    vmax=vmax max v_cal         ' or this correct ?
      	pause 100
     next cnt

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Why not using a simpler way?

    Code:
    for cnt=1 to 70       			
    	adcin 3, v_cal
      	v_cal=v_cal * 5000            ' I use VDD as Vref
      	v_cal=div32 1023
    
    If cnt = 1 then
    vmax = v_cal  
    else
    If v_cal > vmax then vmax = v_cal
    endif
    
    pause 100
     next cnt
    Cheers

    Al.
    Last edited by aratti; - 12th November 2010 at 14:02.
    All progress began with an idea

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Fratello,

    The result should be in mVolts.
    Last edited by rsocor01; - 12th November 2010 at 16:36. Reason: Incorrect statement
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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


    Did you find this post helpful? Yes | No

    Default

    You almost had it right Fratello.
    And the timing will be more accurate if you don't do the math on each loop.
    Code:
    vmax = 0
    for cnt=1 to 70       			
        adcin 3, v_cal
        vmax=vmax max v_cal
        pause 100
    next cnt
    v_cal=vmax * 5000            ' I use VDD as Vref
    v_cal=div32 1023
    DT

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thank You all for reply !
    Both variant (mine = 0 max v_cal and variant of Mr.Robert ) give me the same results : 24 .
    According of my math, I think this is the value of 24 mVolts. I am right ?
    Now I try the variant of Mr.Darrel (remember ? My guardian angel in PBP problems ...).
    I post the results.
    LE : Something strange...with this variant, I read only 5 mV ?!
    Maybe the schematic help...
    Attached Images Attached Images  
    Last edited by fratello; - 12th November 2010 at 16:16. Reason: schematic added

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Oops, disregard my comment. Yes, you should get your result in millivolts.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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