couple of questions


Closed Thread
Results 1 to 2 of 2
  1. #1
    Maniac's Avatar
    Maniac Guest

    Default couple of questions

    Hello

    I have a few questions.
    The first one is, how to convert the output of a NTC thermistor to an increasing series of numbers? I am able to read the input, but as the temperature increases, the value displayed decreases. I have seen a similar post a while back, but I can't find it. My thermistor (15k) is wired to gnd, a 15k resistor to 5vdc, then into RE.2(AN7) of the pic.
    I tried to insert few equations to my code but it didn't work. Tried: (1/adval)*1000, and some variation of that.
    The other question I have relates to this. I am using a 16x1 LDC, wired up as of the lcd.bas, included with PBP. I can get only the fisrt 8 digit to display. How can I get all 16? I am using an 18F452, with 20MHz crystal.
    Sorry if I ask something the wrong way, but I am just learning PBP, and don't know any other programming, except labview.

    This is the code I use:

    'to display thermistor reading from RE.2/AN7

    define OSC 20

    Define ACD_BITS 10 '# of bits in result
    define ACD_CLOCK 3 'clock source (3=R/C)
    Define ACD_SAMPLEUS 20 'set sampling rate in uS

    adval var word
    x var word
    temp var word
    decimal var word

    TRISE.2 = 1 'set porte.2 to input
    ADCON1 = 7 'set porte.2 to analog

    Pause 500
    lcdout, $FE, 1, "start"
    pause 1000

    loop:
    adval = 0
    for x = 1 to 150
    adcin 7, temp 'read channel 7
    adval = adval + temp
    next x
    adval = adval/5
    lcdout $FE, 1 'clear LCD
    lcdout "#=", dec adval 'display the decimal #
    pause 50
    goto loop
    end

    thanks in advance

    Attila

  2. #2
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    If you are trying to invert a variable, just subtract it from the maximum value. For an 8 bit #, it's 256 - adval = newval. 10 bit = 1024 - adval = newval. Now you can scale it accordingly.
    For the LCD second line, read the PBP manual about LCDOUT. You need to place it at the second line with the apropriate command.

    Ron

Similar Threads

  1. Two quick (and elementary) questions.
    By scorpion990 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th June 2008, 23:03
  2. A few 12F683 questions
    By dhouston in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th May 2008, 03:54
  3. Usart Questions
    By shawn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2008, 01:17
  4. Hi Everyone! Some newbie questions :-)
    By guest_05 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th October 2006, 22:24
  5. Newbie has some questions
    By bartman in forum General
    Replies: 43
    Last Post: - 5th October 2005, 16:51

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