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


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2014
    Posts
    21

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

    • Hello everyone, i was wondering if any of you would be as kind as to give me some pointers on where to start with ADC with one of these particular chips (18f-2550/4550)

      basically i need to understand how ADC works since im trying to build a USB Throttle cuadrant for a flight sim, i know the USB aspect of things (ive made a 32 button "Joystick" with no axis that works fine) but i have no idea on how to do the following using PBP3:

      ---conifgure Fuses for ADC operation (configuration bits)
      ---recieve analog input from Pot and turn it into a digital value (this would be an axis)
      ---have a second analog input for a second axis


      • (i already know how to make the descriptor and comm. with the pc via HID class)

        any guide or well commented code would help me greatly, i appreciate any input and thanks for the time.

        Scumari's examples here : http://www.picbasic.co.uk/forum/showthread.php?t=11950

        are helpful but i dont understand how the ADC conversion works in that program,
        if someone by any chance can explain or "comment" this code i would really appreciate it.
        JSAGS






  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

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

    JSAGS you will get a better response by posting the code you are having issues with along with a schematic of your setup . posting the same question over and over again under different headings will not solicit more responses. adc is a big subject ,you need to show us what you know and what you have tried so a suitable targeted response can be given .
    a good start is to read the pbp manual

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427

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

    From one of the GREATEST programmers to grace this forum... (may he rest in peace)

    http://www.darreltaylor.com/DT_Analog/

    dwight
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  4. #4
    Join Date
    Oct 2011
    Posts
    50

    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

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,256

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

    Thread moved to FAQ, good info.

    Robert

  6. #6
    Join Date
    Apr 2014
    Posts
    21

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

    Thanks for all the good info guy ill hope this gives me the kickstart i need (after midterms XD )

  7. #7
    Join Date
    Apr 2014
    Posts
    21

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

    thanks a lot for the input again, i managed to build my joystick, but eventually ran into some trouble again, please see these thread if you guys care to help me out a bit more i would really appreaciate the help..

    http://www.picbasic.co.uk/forum/show...244#post129244

Similar Threads

  1. 4550 osc
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 23rd October 2009, 17:32
  2. Need help PIC 18F2550 with DS 1302
    By christina86 in forum mel PIC BASIC
    Replies: 1
    Last Post: - 28th December 2007, 02:05
  3. getting started with a PIC 18F4550
    By bigbear in forum General
    Replies: 2
    Last Post: - 16th October 2006, 03: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, 09:32

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