PDA

View Full Version : how to add the calculation of temperature in my source code



slimpeng
- 25th January 2008, 09:32
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

Luciano
- 25th January 2008, 10:49
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

Acetronics2
- 25th January 2008, 12:15
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/showpost.php?p=49328&postcount=4


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

Regards

Alain

skimask
- 25th January 2008, 13:50
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/showpost.php?p=49328&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?

slimpeng
- 26th January 2008, 03:04
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....!!!


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

skimask
- 26th January 2008, 05:46
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.

Luciano
- 26th January 2008, 10:08
Hi,

Try that on your breadboard.
http://img244.imageshack.us/img244/3818/lm35if3.th.png (http://img244.imageshack.us/img244/3818/lm35if3.png)
(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




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

slimpeng
- 28th January 2008, 10:17
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...!!!!

Luciano
- 28th January 2008, 10:35
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

http://img152.imageshack.us/img152/9107/lm35blr6.th.png (http://img152.imageshack.us/img152/9107/lm35blr6.png)
(Click to enlarge the picture)

slimpeng
- 28th January 2008, 17:05
hi.....Luciano.........i get the result ad.....very thankful ....u helping me....thanks u so much...thank.....and also wish u all the best....!!!!

Archangel
- 28th January 2008, 20:04
Hi Luciano,
How do you make those great pictures?
JS

Luciano
- 28th January 2008, 20:16
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

slimpeng
- 20th February 2008, 15:41
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....

skimask
- 20th February 2008, 16:31
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.