ADCIN giving inconsistent results


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    My guess is that if you clear V_total, you won't need anything else.

    Consider:

    If the A/D returns a value of 410

    1st time through the loop

    V_Total = 200

    Second time through the loop

    V_Total = 202

    Third time through the loop

    V_Total = 204

    ....

    And it goes through those loops pretty fast. I can see how the results would look inconsistent
    Charles Linquist

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    Quote Originally Posted by triton99 View Post
    What I was wanting to know, is there a better way of reading the voltage using an ADC on the 16F675.
    fwiw I've come to the conclusion that using the picbasic 'ADCIN' command = much badness (unstable ADC readings for me at least)

    Nowadays, if I've a spare CCP module going free, I always use the PIC's special event trigger - it's a very tidy effiicient way of collecting ADC samples in the background - Once it's setup (it's not hard to do this), whenever you want a sample - it's already therefore you ...just go and grab the contents of ADRESH. Job done, eg...

    Code:
    v_in  = ADRESH
    'now go do cool stuff with v_in
    

    The 16f675 has a special event trigger option ...it uses CCP4 for it, so...if you're not intending utilising CCP4, then seriously consider dedicating it to the special event trigger....
    Last edited by HankMcSpank; - 25th September 2011 at 00:50.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    Add one line and most of your problems will go away.


    Code:
    fans_off:
        low low_fan
        low high_fan
        return
        
    read_v:
    
        V_Total = 0    <--------------------------------------------------------------
    
        for i = 1 to sample_size
           pauseus 50
           ADCIN 3, v_in                ' Read channel 3 to V_in (0-1023)
           V_Total = (V_In + V_total)
        next i
        
        V_total = V_total/sample
    Charles Linquist

  4. #4
    Join Date
    Jun 2011
    Location
    St. Louis, MO
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    mister-e: Thanks for the document on reducing system noise. I dont know how I missed that one.

    Charles Linquist: Thanks for pointing out reseting the V_Total variable. My brain sometimes gives me flawed logic...

    HankMcSpank: I orginally tried to use the ADC directly using ADRESH. For some reason I could not get it to work. Once I get back home I will mess with it again. It seemed like a better approach.

    Thanks again everyone, and I will be testing this again today on the car, so I will post the results when finished.
    "Reality is merely an illusion, albeit a very persistent one." , Albert Einstein

  5. #5
    Join Date
    Jun 2011
    Location
    St. Louis, MO
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    After a few weeks of work and family things, I finally found the time to complete the project. The ACDIN results were inconsistent at first, but I etched a new board and instead of SMD components I used thru-hole. The new board worked perfect on the bench but failed on the car...until I realized I had used a NPN transistor instead of an PNP. Before I realized this I made a small relay board that the transistor would switch, which would then turn on the cooling fans. I salvaged the relay from an old TRS-80 motherboard that was ruined. Once the transistor was swapped out and the relay board added, everything worked perfect. We took some test runs, and the cooling fans turned on/off as expected. When the transistors were switched I also had to reverse the high/low settings on the relay outputs on my board. My personal blog has a little more info. http://triton9.wordpress.com/
    Thanks again to everyone for all the help!!
    Name:  FanRelay1.jpg
Views: 2625
Size:  123.3 KBName:  FanController_3.jpg
Views: 2637
Size:  138.7 KBName:  FanController_v2.jpg
Views: 2995
Size:  142.5 KBName:  FanController_4.jpg
Views: 2657
Size:  163.5 KB
    Last edited by triton99; - 23rd October 2011 at 01:02.
    "Reality is merely an illusion, albeit a very persistent one." , Albert Einstein

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    I specialy like the custom MicroChip enclosure.....
    Dave Purola,
    N8NTA
    EN82fn

  7. #7
    Join Date
    Jun 2011
    Location
    St. Louis, MO
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    Yeah...cant beat free!! I have a few of those sitting around gathering dust so it seemed like a perfect reason to get rid of one. First we cut a small rectangle in the top for the relay, then my friend drilled some holes for airflow.
    "Reality is merely an illusion, albeit a very persistent one." , Albert Einstein

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