A/D converter fails?


Results 1 to 15 of 15

Threaded View

  1. #1
    egberttheone's Avatar
    egberttheone Guest

    Default A/D converter fails?

    I'm building a system to monitor a few powerlines it works well but some times the conversion results into a 0; i took the data sheet of the pic i use (16f88) read the whole chapter about it over and over and i finished up changing my code(snippets; of course the enable bit and so are set) from this:
    Code:
    'GO/DONE: A/D Conversion Status bit
    'If ADON = 1:
    '1 = A/D conversion in progress (setting this bit starts the A/D conversion)
    '0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D
    'conversion is complete)
    symbol AD_Progress = ADCON0.2
    
    
    ADCON0.5 = 0
    ADCON0.4 = 0
    ADCON0.3 = 0
    AD_Progress = 1
    while AD_Progress = 1: wend
    Sound_Level.lowbyte = ADRESL
    Sound_Level.highbyte = ADRESH
    to this:

    Code:
    'GO/DONE: A/D Conversion Status bit
    'If ADON = 1:
    '1 = A/D conversion in progress (setting this bit starts the A/D conversion)
    '0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D
    'conversion is complete)
    symbol AD_Progress = ADCON0.2
    
    ADCON0.5 = 0
    ADCON0.4 = 0
    ADCON0.3 = 0
    pause 50
    AD_Progress = 1
    while AD_Progress = 1: wend
    Sound_Level.lowbyte = ADRESL
    Sound_Level.highbyte = ADRESH
    as I understood of the manual: if I change the input port from the a/d converter I need to wait a minimum of time before recalling a new a/d conversion. So far so good but what happens is it stucks @ "while AD_Progress = 1: wend" because it simply does not clear any more the code above without the pause 50 does work! so if I remove that line "pause 50" the code runs but some times I get a 0 in the result of the a/d conversion :S I don;t get it do you?
    Last edited by egberttheone; - 7th February 2006 at 20:42.

Similar Threads

  1. Replies: 9
    Last Post: - 31st July 2008, 08:56
  2. A/D converter sample
    By allan josephus in forum mel PIC BASIC
    Replies: 5
    Last Post: - 23rd February 2008, 19:44
  3. A/D converter with pic16f84, i need a help
    By micro in forum General
    Replies: 0
    Last Post: - 13th December 2005, 21:17
  4. help with pic16f870 a/d converter
    By cammo in forum mel PIC BASIC
    Replies: 3
    Last Post: - 22nd March 2005, 05:16
  5. Re Cs5532 A/d Converter
    By massquip in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th April 2004, 16:31

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