18f2525 with LM34


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91

    Default 18f2525 with LM34

    I've spent the last 2 days working on this and can't seem to solve my problem.

    I have a 18f2525 @ 20Mhz connected to a LM34 Temperature sensor on RA5(AN4).
    I have a pot connected to RA3 (+Vref) with 2.55 volts on RA3.
    I've used Bruce's code, with some changes to suit my app.
    I read .68 volts on pin 7 but get bogus numbers on the PC.
    "Temperature is 38 Degrees"
    "Temperature is 5 Degrees"
    I've tried manipulating ADCON0, ADCON1, and ADCON2 with no success.

    Here is the code as it was for my last attempt.
    <code>
    DEFINE LOADER_USED 1 ' Boot loader is being used
    define OSC 20 ' We're using a 4 MHz oscillator
    DEFINE HSER_RCSTA 90h 'setup receive register
    DEFINE HSER_TXSTA 20h 'setup transmit register
    DEFINE HSER_BAUD 38400 'setup baud rate
    DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 3 ' Set A/D clock
    DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS

    samples VAR WORD ' Multiple A/D sample accumulator
    sample VAR BYTE ' Holds number of samples to take
    temp VAR BYTE ' Temperature storage
    samples = 0 ' Clear samples accumulator on power-up

    PORTA = %00000000
    TRISA = %11111111 ' Set PORTA to all input

    'ADCON0 = %00010001
    ADCON1 = %00011010 ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref
    'ADCON2 = %00111011
    PAUSE 500 ' Wait .5 second
    loop:
    FOR sample = 1 TO 20 ' Take 20 samples
    ADCIN 5, temp ' Read channel 0 into temp variable
    samples = samples + temp ' Accumulate 20 samples
    PAUSE 250 ' Wait approximately 1/4 seconds per loop
    NEXT sample
    temp = samples/20
    samples = 0 ' Clear old sample accumulator
    GoSub hyperview
    GOTO loop ' Do it forever
    hyperview:
    HSerout ["Temperature is ",dec temp," Degrees", 13,10]
    'pause 1000
    Return

    END
    </code>

    I'm sure it's something simple, It just hasn't jumped out at me yet.
    Any help would be apreciated.

    PBP v2.45A, MCSP, MPASM and Microcode Loader
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Here's Note 2 from the ADCON1 section of the 2525 datasheet.

    2: AN5 through AN7 are available only on 40/44-pin devices.
    Added: maybe you wanted ADCIN 4, temp
    <br>
    Last edited by Darrel Taylor; - 22nd January 2007 at 22:47. Reason: 4
    DT

  3. #3
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Red face Too easy..........

    Well Darrel, once again you're right on.

    I did read the note (AN5 through AN7 are available only on 40/44-pin devices) and put my sensor on AN4 (RA5) but didn't realize the
    ADCIN 5, temp problem.

    If nothing more at least I got a little schooling on ADCON0, ADCON1 and ADCON2.

    As always many thanks.

    I'm off to return that tall ladder and short rope I just bought.
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The easy one's are often hardest to find (in your own program).
    The hard one's you've already gone over a hundred times and can't understand why it's still not working.

    It's much easier when it's someone else's program.

    I'm off to return that tall ladder and short rope I just bought.
    Oh thank god,
    It would have been horrible for someone to find you like that.

    LOL,
    DT

Similar Threads

  1. Need help with LM34 and 12F675
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th December 2009, 13:06
  2. Migration Issues 16F876 to 18F2525
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 17th November 2007, 22:38
  3. Making RA6 (OSC2) an output on a 18F2525
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th September 2006, 17:51
  4. lm34 and Ad590 with PIC16f877
    By wlp01 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st November 2005, 02:56
  5. 18F2525 Int Osc settings?
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th March 2005, 22:44

Members who have read this thread : 1

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