Code Problem?


Closed Thread
Results 1 to 5 of 5

Thread: Code Problem?

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Arch,

    You are correct! I have changed this to ANSEL = 51 or ANSEL = %00110011. I have changed this but have the same problem! It only reads 32 over SEROUT2 no change.

    If I rem out the ADCIN1 I get the correct value via ADCIN0 checked by multimeter. It only happens when I add ADCIN1. Does it look like the ADCON0 register?

    Any other suggestions?

    Thanks,

    Scott

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    I've not used ADCIN much, but here's some other things to check:

    I don't see anywhere in your code that sets the pins as inputs - you might try setting up the TRISIO register as needed.

    In the PBP manual it shows an example like this:
    "ADCIN 0, B0 ; Read channel 0 to B0"

    The 'channel' is selected with a number rather than port pin name - don't know if that makes any difference or not.

    Arch
    "Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"

  3. #3
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Here is another way of aproaching the A/D based on some code Melanie posted a long time ago, this uses direct access to the pics registers instead of using PBP's routines:

    Code:
     Analog_In:
         ANSEL=%00110001
        ADCON0=%10000001;
            ' Enable ADC Module on pin AN0
        PauseUS 50;
            ' 50uS Pause to allow sampling Capacitor to charge
        ADCON0.1=1
        ' Start Conversion
        While ADCON0.1=1:Wend
        ' Wait for conversion to complete
        AnalogIn.Highbyte=ADRESH
        AnalogIn.Lowbyte=ADRESL
        ' Read 16-bit Result
    RETURN
    By changing ADCON0 to different values you should be able to read analog in on all the other analog pins

Similar Threads

  1. USART+PWM Problem
    By alex-x in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 2nd December 2009, 10:45
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  3. 16F883 Code Verify Problem
    By munromh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 12:47
  4. problem with my code
    By civicgundam in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd February 2008, 02:52
  5. Code problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th May 2006, 05:43

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