18f452 ADC config


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326

    Default 18f452 ADC config

    Hi to all,

    I am going to set up the PIC18F452 having a clock speed of 40 Mhz in order to read the follwing analog inputs:

    > analog input connected to AN0 pin_2
    > Vref+ connected to AN3 pin_5
    > Vref - connected to AN2 pin_4

    Question_1:
    How do I have to set ADCON0 register and ADCON1 register to achieve this set up ?

    Question_2:
    Do I have to read ADRESL and ADRESH relevant to AN0 ? or I do have to read AN2 and AN3 register in addition to AN0?

    Thanks a lot for any help
    Regards,
    Ambrogio

  2. #2
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default 18f452 adc

    you dont need to set adcon0 register if you are using picbasic.

    Use Adc defines ;

    Code:
    DEFINE ADC_BITS  10      ' ADCIN resolution  (Bits)
        DEFINE ADC_CLOCK 3      ' ADC clock source  (Fosc/8)
        DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
    YOU HAVE TO SET ADCON1 REGISTER TO CHOICE WITCH PORT ANOLOG OR DIGITAL.

    Code:
           
    ADCON1.7 = 1 ; Right justified.
    
    ADCON1.3 = 1 ; PORTA.0 - ANALOG , AN2 - VREF(-) , AN3 - VREF(+)
    ADCON1.2 = 1
    ADCON1.1 = 1
    ADCON1.0 = 1
    
    MAIN :
    
    ADCIN 0 , ADVAL
    
    PAUSE 10
    GOTO MAIN

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default

    Hi ,
    Thanks very much for adc setting help.
    Now it is working well.
    Could you please spend few words for me about the following :

    DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/8)
    DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)

    I am working with a 40 Mhz clock speed: does those defines affect the accuracy of the measure ( in some way ? Fosc/2 or fosc/32 ... sampleus=150 ... ).

    Thanks again
    regards,
    Ambrogio

  4. #4
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default pic multi-calc

    i think mister-e's great program will help you.

    program cointains a adc-calc.

    http://www.picbasic.co.uk/forum/show...light=mister-e

Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. Error 0X0000008E when connecting a 18F2550 USB HID
    By FranciscoMartin in forum USB
    Replies: 8
    Last Post: - 16th October 2008, 17:20
  4. PortE problems (PIC18F4455)
    By RubenR in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 12th July 2006, 15:26
  5. Installation sequence
    By Demon in forum General
    Replies: 23
    Last Post: - 11th July 2006, 03:56

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