Again ADC with 12F675 ...


Closed Thread
Results 1 to 30 of 30

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    Me, again ...with something strange (at least for me) !
    I try to use ADC for reading a couple of buttons. I have two situations :
    - three buttons, with 82 ohms, 164 ohms, 1448 ohms resistors ; ADC reading = 1023 nothing pressed ; 78 with button 1 pressed ; 144 with button 2 ; 605 with button 3 ;
    - three buttons, with 300 ohms, 1300 ohms, 3110 ohms AND 100 Kohms in parallel ; ADC reading = 1013 nothing pressed ; 236 with button 1 pressed; 575 with button 2 ; 768 with button 3.

    I tried with 2 version of code (for both situations):
    Code:
     ADCON0.1 = 1
     WHILE ADCON0.1 = 1 : WEND
     adval.HighByte = ADRESH
     adval.LowByte = ADRESL
    if adval > 10  and adval < 300 then  gosub LED1
    ...etc....
    and

    Code:
    ADCIN 3, adval
    if adval > 10 and adval < 300 then gosub LED1
    ...etc...
    For first situation everything works fine, with both version of reading ADC !
    BUT ... for second situation, NOTHING HAPPENS !!! I really not understand what I do wrong ... Can me point to the right direction ? Thanks in advance !

    Name:  working.jpg
Views: 1890
Size:  98.3 KB Name:  not_working.jpg
Views: 1875
Size:  125.8 KB

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


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    Note : In Proteus both schematic work, so I made it on PCB. First variant works just fine, second none ...

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    For the code using ADCIN, is the left/right justification set correctly? I can never remember which way around it wants it so whatever you have it set to, try changing it. And, do you have DEFINE ADCBITS 10 in there?

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    Thanks for reply !
    Code:
    CMCON = 7
    OPTION_REG  = %10000110
    TRISIO      = %00001100	  		
    GPIO        = %00000001
    ANSEL       = %00010100   
    ADCON0      = %10001001
    I don't change anything in code (except values for actions) ... just the resistors from "chain" command.
    With first chain work ; with second not. It's because of 100 kOhms ?!?

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    In your very first post, I couldn't find any clear description of your problem or goal....

    Quote Originally Posted by fratello View Post
    Quote Originally Posted by fratello View Post
    Resistor coupling is apparently not the same in those two posts - is this okay?



    Try this:
    Name:  resistor.jpg
Views: 1458
Size:  49.2 KB
    Button 1 = 0 Volt => ADC 8 bits = +/-0 , ADC 10 bits = +/-0
    Button 2 = 1,25 Volts => ADC 8 bits = +/-64 , ADC 10 bits = +/-320
    Button 3 = 2,5 Volts => ADC 8 bits = +/-128 , ADC 10 bits = +/-640
    Button 4 = 3,75 Volts => ADC 8 bits = +/-192 , ADC 10 bits = +/-960

    I didn't built the circuit above; if ADC values are not stable, try with all R values ( :10) => 10k becomes 1k, 3k3 becomes 300Ohms and so on.



    As an alternative, you may want to have a look here "Compiled Tips ‘N Tricks Guide".Name:  RC ramp.jpg
Views: 1531
Size:  143.0 KB
    Last edited by flotulopex; - 17th April 2015 at 22:28.
    Roger

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


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    Thanks for info !

Similar Threads

  1. ADC values above 4095 for 12 bit ADC
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st February 2015, 22:24
  2. ADC problem on 18F46K22 device using all 28 ADC pins
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:22
  3. 12f675
    By mystified in forum mel PIC BASIC
    Replies: 6
    Last Post: - 10th September 2007, 02:47
  4. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55
  5. ADC on 12f675?
    By peu in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 16th March 2005, 17:44

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