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

    Thank You so much for reply !
    The rest of code is :
    Code:
    main:
    pause 200
     ADCON0.1 = 1
     WHILE ADCON0.1 = 1 : WEND
     adval.HighByte = ADRESH
     adval.LowByte = ADRESL
     if k=0 and adval > 10 and adval < 750 then
     k=1
     pause 250
     endif
    
     while k=1
     gosub start
     wend
     goto main
    
    
    start:
    
     ADCON0.1 = 1
     WHILE ADCON0.1 = 1 : WEND
     adval.HighByte = ADRESH
     adval.LowByte = ADRESL
    if adval > 10  AND adval < 103 then gosub VolDn     
    
    return

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    Hi,

    >The rest of code is :

    Is it? You're calling VolDn but I don't see that in the code but I guess there's nothing to do with the ADC there?

    Anyway, have you tried using ADCIN just to see if the message from ISIS goes away then?
    I'm asking beacuse the DEFINE ADC_SAMPLUS 50 is for use with the ADCIN command I don't think it does anything for you when you run the ADC "manually". Alternativaly, whenever you're doing a converstion try:
    Code:
    ADCON0 = %10001001    ' Right justify, VRef=Vdd, select AN2, enable ADC.
    PAUSEUS 100     
    ADCON0.1 = 1          ' Start conversion
    WHILE ADCON0.1 = 1 : WEND
    adval.HighByte = ADRESH
    adval.LowByte = ADRESL
    In this case I don't think anything of it really matters since you're always sampling the same channel but it might be worth a try just to see if ISIS stops generating the message.

    Finally, you're doing DEFINE ADC_CLOCK 3 but then you're overriding that by manually setting ANSEL to %00010100 which will set the ADC Clock to FOsc/8 instead of FRC. I don't think that's a problem in this case though.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: Again ADC with 12F675 ...

    Thank you verry much !
    Indeed, my mistake was the overriding of defines ...I didn't know until today the things You've posted. Hm ... so much to learn ! I'm glad I met people like You and other kindly members of this forum !
    Best regards !

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

    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: 2409
Size:  98.3 KB Name:  not_working.jpg
Views: 2408
Size:  125.8 KB

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

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    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.

  7. #7
    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 ?!?

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    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: 1897
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: 1815
Size:  143.0 KB
    Last edited by flotulopex; - 17th April 2015 at 23:28.
    Roger

  9. #9
    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, 23: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, 21:22
  3. 12f675
    By mystified in forum mel PIC BASIC
    Replies: 6
    Last Post: - 10th September 2007, 03:47
  4. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 02:55
  5. ADC on 12f675?
    By peu in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 16th March 2005, 18: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