ADC problem


Results 1 to 4 of 4

Thread: ADC problem

Threaded View

  1. #1
    NacNud's Avatar
    NacNud Guest

    Arrow ADC problem

    Hello,

    First I want to say that this is a nice forum finding solutions for PBP.

    Here is my queston about an Analog to digital conversion.
    I want to put an conversion in the variable word_temp_int, but this ain't seem to work. Every result of the AD conversion is 0.
    Using a PIC16F870.

    This code is in my interrupt routine, the routine is 500 ms. The varaiable word_wachttijd_aantal is decreased with every interrupt.

    Code:
    if (word_wachttijd_aantal == 12) and (byte_status == 1) then
       adcon0.0 = 1                            ' AD converter on
    endif
    if (word_wachttijd_aantal == 11) and (byte_status == 1) then
       word_pot_adc = 0                     ' reset value potmeter
       adcon0.2 = 1                         ' start AD conversion
    endif                
    if (word_wachttijd_aantal < 11) and (byte_status == 1) then
       if adcon0.2 == 0 then                   ' test AD conversion ready
          word_temp_int.highbyte = ADRESH      ' store AD value
          word_temp_int.lowbyte = ADRESL       ' store AD value
          word_pot_adc = word_pot_adc * 9      ' some calculations
          word_pot_adc = word_pot_adc + word_temp_int
          word_pot_adc = word_pot_adc / 10
       endif
       adcon0.2 = 1                            ' start new AD conversion
    endif
    The AD converter is put on when word_wachttijd_aantal is equal to 12.
    500 ms later the AD converter is started when word_wachttijd_aantal is equal to 11.
    500 ms later the AD converter is stored in word_pot_adc because word_wachttijd_aantal is less than 11 and adscon0.2 is equal to 0 a long time ago.
    After the AD value is stored in word_pot_adc a new AD conversion is started.

    If I put de code untherneath here at the same place it works fine.
    Code:
    test:
       adcon0.0 = 1                            ' AD converter on
       pause 500                               ' wait 500ms is
       adcon0.2 = 1                            ' start AD conversion
    ADC:	
       pause 5                                 ' wait 5ms aquisition time
       if adcon0.2 = 1 Then ADC                ' test if AD conversie is ready             
       word_pot_adc.highbyte = ADRESH          ' store AD value
       word_pot_adc.lowbyte = ADRESL
       adcon0.0 = 0                            ' AD converter off
    goto test
    Last edited by NacNud; - 14th December 2004 at 20:18.

Similar Threads

  1. pic12f675 ADC problem
    By radu022003 in forum mel PIC BASIC
    Replies: 3
    Last Post: - 1st September 2009, 10:13
  2. PIC18F2423, ADC problem
    By mistergh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th March 2009, 01:31
  3. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  4. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  5. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46

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