how to add the calculation of temperature in my source code


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2008
    Posts
    28

    Default how to add the calculation of temperature in my source code

    Hello who can teach me how to add the calculation of the temperature in my programe i try many time ad still cant working.....i fast want die ad...few day no sleep ad....hope u all can help me...thanks...

    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 1/25/2008 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    Define LCD_DREG PORTB
    Define LCD_DBIT 4
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 0
    Define LCD_EREG PORTB
    Define LCD_EBIT 1

    ' Define ADCIN parameters '

    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    include"modedefs.bas"

    TRISB=%11111111

    pause 2
    LCDOUT 254,1,"WELCOME MY"
    LCDOUT 254,192,"MONITOR SYSTEM"

    pause 3
    LCDOUT 254,1,"MY STARTING"
    LCDOUT 254,192,"TEMPERATURE"



    TRISC.6=0
    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 =%00001010 ' Set PORTA analog
    Low PORTB.2 ' LCD R/W line low (W)

    Pause 5 ' Wait .5 second

    loop:

    ADCIN 0,B0 ' Read channel 0 to adval

    Lcdout $fe, 1 ' Clear LCD
    Lcdout "Value: ",DEC B0,"'C" ' Display the decimal value
    serout portc.6,n2400,[#b0]
    Pause 1 ' Wait .1 second

    Goto loop ' Do it forever
    End

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Here are some questions to you:

    1. Used PIC?
    2. Used temperature sensor?
    3. Celsius or Fahrenheit? (Only Celsius or Fahrenheit or both).
    4. How much accuracy do you need? (%)
    5. Do you need decimal places? (Example 25.5 °C).
    6. What temperature range do you need to measure?
    7. Are the measured temperatures always positive? (Example: From 0°C to 70°C).
    8. Where is located the temperature sensor? (Cable length).
    9. Used power supply. Single supply or Dual supply? (Example: Single supply +5V / Dual supply ±5V).
    10. Do you have a multimeter and know how to use it?
    11. Do you have a digital thermometer that can be used as reference?
    12. What is your background or occupation?
    13. What is your age?
    14. Is that a school assignment?
    15. What is your mother language?
    16. Are you fluent in English?
    17. Do you read and understand datasheets?

    Best regards,

    Luciano
    Last edited by Luciano; - 25th January 2008 at 14:30.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Talking

    14. Is that a school assignment?

    Hi Luciano,

    The answer is YES ... and Urgent ( he said he will die without it ...).

    http://www.picbasic.co.uk/forum/show...28&postcount=4


    That's why I go back to siesta !!! ... no comment.

    Regards

    Alain
    Last edited by Acetronics2; - 25th January 2008 at 12:25.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    14. Is that a school assignment?
    Hi Luciano,
    The answer is YES ... and Urgent ( he said he will die without it ...).
    http://www.picbasic.co.uk/forum/show...28&postcount=4
    That's why I go back to siesta !!! ... no comment.
    Regards
    Alain
    It'll be overdue by the time it gets finished.
    Wake me when it's over...

    Hello who can teach me how to add the calculation of the temperature in my programe i try many time ad still cant working.....i fast want die ad...few day no sleep ad....hope u all can help me...thanks...
    What?

  5. #5
    Join Date
    Jan 2008
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    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....!!!

    Quote Originally Posted by Luciano View Post
    Hi,

    Here are some questions to you:

    1. Used PIC?
    2. Used temperature sensor?
    3. Celsius or Fahrenheit? (Only Celsius or Fahrenheit or both).
    4. How much accuracy do you need? (%)
    5. Do you need decimal places? (Example 25.5 °C).
    6. What temperature range do you need to measure?
    7. Are the measured temperatures always positive? (Example: From 0°C to 70°C).
    8. Where is located the temperature sensor? (Cable length).
    9. Used power supply. Single supply or Dual supply? (Example: Single supply +5V / Dual supply ±5V).
    10. Do you have a multimeter and know how to use it?
    11. Do you have a digital thermometer that can be used as reference?
    12. What is your background or occupation?
    13. What is your age?
    14. Is that a school assignment?
    15. What is your mother language?
    16. Are you fluent in English?
    17. Do you read and understand datasheets?

    Best regards,

    Luciano

  6. #6
    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.

  7. #7
    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  

  8. #8
    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...!!!!

  9. #9
    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.

  10. #10
    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....!!!!

  11. #11
    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.

  12. #12
    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

  13. #13
    Join Date
    Jan 2008
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Luciano View Post
    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
    Hello Luciano....i got thing want to asking u .....if in my program i need to add the Celsius and Fahrenheit both together how i adding the comment....Thanks u so much....

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by slimpeng View Post
    Hello Luciano..i got thing want to asking u..if in my program i need to add the Celsius and Fahrenheit both together how i adding the comment..Thanks u so much..
    What? May want to reword that question a bit...Can't seem to make heads or tails...and usually I get the general meaning of the question.
    Or maybe the search function is broken again...maybe Google went down for the week...
    Maybe prebuilt code doesn't show up anymore.

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