Adcon register with P18F4550


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    I change a bit of the program , but i am still getting 8 bit results ( max 255)

    Code:
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uSec
    
    ADCON0 = %00000001 ' AN0, Configure and turn on A/D Module
    ADCON1 = %00001001 ' Analog input
    ADCON2.7 =1 	   ' Right justified results for 10 bits,Fosc/8
    
    Check_voltage_Low:
    ADCON0 = 00010001 'Start Conversion
    ADCON2.7 =1
    ADCIN 4, voltage_check 'analog pin 4 get the 10 bit result  Check the battery voltage on pin PORTA.5
    
    lcdout $FE,1, "Battery voltage"
    lcdout $FE,$C0, "TempC: ",  dec voltage_check
    pause 1500
    Return

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    I never did like ADCIN. Take a look at this thread. It may help.
    http://www.picbasic.co.uk/forum/show...9694#post79694
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    Thanks Dave, its working now with your method.
    still wandering why the button command do not work.

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    Hi,

    I added a 1uF capacitor to the analog pin, hoping it would stabilize the voltage. I am measuring a 12v battery, using a 80Mohm and a 16Mohm divider. I am reading about 2.2v on the pin, but the output oscillates between 425, 429, 433. which seems to be a lot. any other things I can do to stabilize the output ? (hardware) I am also thinking of taking an average of the last three inputs..

    K

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    Hi , I added these lines: but it still fluctuates a lot:
    then I output the ChAN_AVG

    Code:
        GOSUB   READ_AD
    	CHAN4_2 = CHAN4_1
    	CHAN4_1 = CHAN4
    	
        CHAN4.HighByte = ADRESH  'PLACES THE HIGH AND LOW BYTE
        CHAN4.LowByte  = ADRESL   'INTO VAR CHAN0
    
    	CHAN_AVG = (CHAN4_2 + CHAN4_1 + CHAN4 ) /3
    	
        RETURN

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    On similar apps I use a 22uF cap from the ADC pin to VSS.

    How stable is VDD?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Adcon register with P18F4550

    I use a 7805 with a 1uF cap and a 47uF cap on the adc pin
    K

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