need help with adc


Results 1 to 10 of 10

Threaded View

  1. #2


    Did you find this post helpful? Yes | No

    Default

    Code:
        DEFINE  OSC 4               ' Set Xtal Frequency
        DEFINE  ADC_BITS 10         ' Set resolution of conversion
        DEFINE  ADC_CLOCK 8         ' Set clock source (x/FOSC or FRC)
        DEFINE  ADC_SAMPLEUS 50     ' Set sampling time (in uS)
    
        ADFM    var     ADCON1.7    ' ADC result format select bit
        PCFG3   var     ADCON1.3    ' ADC port configuration bit
        PCFG2   var     ADCON1.2    ' ADC port configuration bit
        PCFG1   var     ADCON1.1    ' ADC port configuration bit
        PCFG0   var     ADCON1.0    ' ADC port configuration bit
    
        PCFG0 = 0                   ' Configure AN0 as analogue input, others digital 
        PCFG1 = 1
        PCFG2 = 1
        PCFG3 = 1
        ADFM = 1                    ' Right justified result in ADRESL and ADRESH
                                   
        adcin 0,adc_in              ' Place the conversion of channel0 into adc_in
    For 0-300 lbs output = adc_in * 100 / 341
    For 0-400 lbs output = adc_in * 100 / 256

    This will give you an output within 1 lb.
    Last edited by CocaColaKid; - 20th September 2005 at 13:00.

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. 10 bit ADC display on LCD using 16f873
    By pr2don in forum mel PIC BASIC
    Replies: 3
    Last Post: - 6th March 2010, 18:29
  3. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  4. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 15:54
  5. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55

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