16f877 with LM335 problem


Results 1 to 40 of 47

Threaded View

  1. #5
    Join Date
    Nov 2006
    Location
    Melbourne, Australia
    Posts
    25


    Did you find this post helpful? Yes | No

    Angry 16f877 Adc Not Working

    hi all,
    am trying to understand how to implament the ADC on the pic 16f877
    my code is for a LM335 temp sensor connected to RA0(pin 2)
    the VDD and VSS is from a 7805 voltage reg that also supplies the LM335

    Cant get ADC to work from my circuit. or is it my code??????????????
    why cant i use decimal ie 0.46 in my maths routine?????????????

    This has had me up all week trying to get it to work

    PLZ someone guide me in the correct direction


    'PIC 16f877 with a LM335 temp sender
    '
    '
    define osc 20 ' 20mhz oscillator
    ' LCD ROUTINES
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4 '4,5,6,7
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 3
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 2
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    define ADC_CLOCK 3 ' Set clock source
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    AD_RAW var word ' Create adval to store result
    AD_RESULT var word


    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10001110 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %10000001 ' Configure and turn on A/D Module

    Pause 500 ' Wait .5 second

    loop:
    ADCIN 0, AD_RAW ' Read channel 0 to ad_raw
    AD_RESULT = (ad_raw *0.48828) - 273.15 ' Convert Kelvins to Degrees C

    Lcdout $fe, 1 ' Clear LCD
    Lcdout "TEMP ", DEC AD_Result ," C" ' Display the decimal value

    Pause 100 ' Wait .1 second

    Goto loop ' Do it forever
    End
    Attached Images Attached Images  
    IF ITS STOCK IT WONT ROCK

Similar Threads

  1. 16F877 HSERIN problem with 3th party software
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th March 2009, 17:11
  2. LCD problem with 16F877
    By alexx_57 in forum General
    Replies: 10
    Last Post: - 25th July 2007, 13:47
  3. problem using 16f877
    By yrch in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th February 2006, 18:58
  4. 16F877 20MHz problem
    By swordman in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st July 2004, 10:02
  5. 16F877, DS18S20 and Serial Comm Problem
    By YellowTang in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2004, 10:36

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