Where To Get Started With ADC (Pic 18f2550 / 4550)


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: Where To Get Started With ADC (Pic 18f2550 / 4550)

    These are the registers used with the A/D converter

    PIC 18F2550

    Select the A/D inputs with the ADCON1 register. So to select AN0 and AN1 as analogue inputs with voltage references of PIC supply and PIC 0v set ADCON1 = %00001101
    AN0 and AN1 must be made inputs with the TRIS register.

    Next set the ADCON2 register. For a 10 bit result (0 - 1023) set ADCON2.7 to 1 (right justified). The A/D result will be in registers ADRESH and ADRESL. For an 8 bit result (0 to 255) clear ADCON2.7 to 0 (left justified). The A/D result will be in register ADRESH. The A/D converter needs a fixed time to settle and do the conversion. Set the rest of the bits according to the table in the datasheet for clock speed used.

    The pic has only one A/D converter so it must be connected to the relevent A/D pin by the ADCON0 register and the converter turned on. So to select AN0 and turn the converter on, ADCON0 = %00000001. To select AN1, ADCON0 = %00000101. If you make AN3 analogue then AN0, AN1, AN2 will also be analogue input, see the datasheet.

    To start the conversion set ADCON0.1 to 1.
    Wait for the conversion to finish with for example
    WHILE ADCON0.1 = 1 : WEND
    The result will be in ADRESH/ADRESL for 16 bit results or ADRESH for 8 bit results depending on the setting of the format in ADCON2.

    Hope this will get you started
    Phil

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Where To Get Started With ADC (Pic 18f2550 / 4550)

    Thread moved to FAQ, good info.

    Robert

Similar Threads

  1. 4550 osc
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 23rd October 2009, 16:32
  2. Need help PIC 18F2550 with DS 1302
    By christina86 in forum mel PIC BASIC
    Replies: 1
    Last Post: - 28th December 2007, 01:05
  3. getting started with a PIC 18F4550
    By bigbear in forum General
    Replies: 2
    Last Post: - 16th October 2006, 02:31
  4. need help just started with pic basic pro
    By houa in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st September 2005, 08:32

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts