how to add the calculation of temperature in my source code


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by slimpeng View Post
    i using the 16F877A PIC, and the temperature sensor i using LM35DZ and i only want clesius and count form 0-100oC because i want to measuring the boiler and i using the cable around 4meter only and using power supply +5V so all thing i let u all knw very clearly ad and i knw my english no good no lought ppl....and that is my assignment...i know u all no help ppl to do assignment so i jst want to ask how to adding the math formula in my program and where can get it the formula becasue i no stronge in math so want to ask u all to help me....!!!
    How many times do you have to be reminded that there is a SEARCH function here (not to mention GOOGLE returns a couple dozen decent hits...).
    The SEARCH here, gives me 19 hits (including one practically pre-made example, linked on a different site, but nonetheless, practically complete), and of those 19 hits, 12 of them have working code in them.

  2. #2
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Try that on your breadboard.

    (Click to enlarge the picture)

    The original tutorial + code can be found here:
    http://www.rentron.com/PicBasic/LM34.htm

    LM35 datasheet:
    http://www.national.com/ds/LM/LM35.pdf

    The code below will work with the above connections.
    Note that you will have to add the DEFINE + code for the LCD.

    Best regards,

    Luciano


    Code:
    DEFINE osc 4            ' We're using a 4 MHz oscillator
    DEFINE ADC_BITS 8       ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 1      ' Set A/D clock Fosc/8
    DEFINE ADC_SAMPLEUS 50  ' Set A/D sampling time @ 50 uS
    ' Add the LCD DEFINEs here <<<<<<<<<<<<<<<<<<<<<<<<<
    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
    
        TRISA = %11111111   ' Set PORTA to all input
        ADCON1 = %00000011  ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref
        PAUSE 500           ' Wait .5 second
    
    loop:
    
        FOR sample = 1 TO 20    ' Take 20 samples
            ADCIN 0, 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
        
        LCDOUT $FE, 1 ' Clear LCD
        LCDOUT "Temp: ",DEC temp,"'C" 
    
        samples = 0             ' Clear old sample accumulator
        GOTO loop               ' Do it forever
    
        END
    Attached Images Attached Images  

  3. #3
    Join Date
    Jan 2008
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    hello....Luciano....the potentiometer how many resister....10K,100k or 5k.....i want to comfont i scare will burn off my pic....and i want say thanks u so much here....and helpping me..thanks man...!!!!

  4. #4
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    The value of the potentiometer is 10k.
    (The value is visible on the picture of my previous post, click on the picture to enlarge).

    Note that you can also use a 5k potentiometer. There is no danger for
    the microcontroller.

    Set the potentiometer in its middle point. Connect the red lead of your
    multimeter (voltmeter) to the pin 5 of the PIC and connect the black lead
    of your multimeter to ground (GND). Adjust the potentiometer so that on the
    multimeter you see 2.55V. If you don't have a multimeter, just set the
    potentiometer in its middle point.

    Best regards,

    Luciano


    (Click to enlarge the picture)
    Last edited by Luciano; - 28th January 2008 at 13:52.

  5. #5
    Join Date
    Jan 2008
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    hi.....Luciano.........i get the result ad.....very thankful ....u helping me....thanks u so much...thank.....and also wish u all the best....!!!!

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Great Pictures

    Hi Luciano,
    How do you make those great pictures?
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi Joe,

    Microsoft Paint.

    The 16F877A was taken from the datasheet, the multimeter and potentiometer from the WEB.
    (Google search images, 100% copyright violation, sorry about that).

    Best regards,

    Luciano

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. My Code get crazy after i add interrupt
    By jetpr in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th May 2005, 04:43
  4. code source
    By meyou in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th August 2004, 21:01
  5. accessing source code
    By mle in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st July 2003, 14:25

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