help me: temperature sensor lm35 with pic16f877 and code

Thread Starter

mohamedspider

Joined May 31, 2012
2
hi everyone,,

i want to ask for my project

my project is fire alarm by using lm35 sensor and pic16f877

that will send output from sensor to pic then to serial port

and i will recieve it in visual basic 6 program

i draw this circuit in " ISIS 7 Professional "

i want anyone help me and tell me if this circuit correct or not

and send the code that will put in pic by using "microc" and hex file

http://www.mediafire.com/?is14xyu4sttuvy1
 

Attachments

absf

Joined Dec 29, 2010
1,968
I see that there are 2 things left out in your circuit. You didn't pull up /MCLR with a 10K resistor and 2x 22pF caps are needed on the both sides of the crystal or else it wouldn't start the osc reliably.

If you want the software in the language you wanted, you can always do a google search and see if there is one that would fit your need. But hoping someone to write a customized program for you ? :eek:......... I am doubtful someone would do that kind of favour for you.:D

Is a program written in Hi Tech C with sample schematics and hex code OK with you? You may refer to this link if you want....

http://www.cytron.com.my/viewProduct.php?pid=CQETLQMVCCEeEiwgJAkGB7jFpdiP0exH82At4sXol8s=&store=

All the files are downloadable from the useful doc section. You may use it as a reference for your design....

Allen
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
Additionally while a PIC can output RS-232 data it does not do so at RS-232 levels. There are chips available to do such.

A further error is expecting others to write your code for you.
 

t06afre

Joined May 11, 2009
5,934
Additionally while a PIC can output RS-232 data it does not do so at RS-232 levels
That will work in the Proteus simulator. You can connect like this. In this way you can have a virtual microcontroller. That interface with a onboard serial port on your host computer. The latter data can be read by any other serial port. But of course as you say. This will not work in any real world setting.
A further error is expecting others to write your code for you.
Why not also write the report while we are at it:p
 

Thread Starter

mohamedspider

Joined May 31, 2012
2
thank you so much for your help

i know it wrong to ask write code to my project but this is first time to make project like this and i don't know any program language to write code for pic

anyway

this is my new schematic




but i try run it on visual basic

it gave me this result



i don't know what's wrong in this code

this code is writen in PICbasic pro compiler

Rich (BB code):
DEVICE 16F877
DECLARE  XTAL 4
DECLARE ADIN_RES 10
DECLARE ADIN_TAD 8_FOSC
DECLARE ADIN_STIME 50
Dim TEMP As WORD
TRISA = %00000001
TRISC 0.6 = 0
ADCON1 = %10000000
       TEMP = 0
                TEMP = ADIN 0
                TEMP = (TEMP / 2)
                SEROUT PORTC.6,16780, [ DEC TEMP,13]
 

ErnieM

Joined Apr 24, 2011
8,377
Your new schematic did not attach, nor did anything appear under where you say "it gave me this result" but I assume it did not work.

I don't use PICbasic anymore so I don't have a reference to completely check your code to check how you set up the voltage conversion, but generally what you are doing seems reasonable. (That means the error may be subtle and hard to spot.)

You are doing two tasks here:

1) read temperature voltage

2) transmit temperature voltage via RS-232

I would separate these two tasks to simplify things by for the moment by ignoring reading the voltage and just send a known number, say instead of

Rich (BB code):
TEMP = ADIN 0
Use this instead:

Rich (BB code):
TEMP = 100
Once you get "50" inside VB you can move on to reading the voltage.

Next (and more importantly) you probably intend to read the temperature voltage continuously. To do that you should place the last 3 lines in a loop:

Rich (BB code):
    DO
        TEMP = 100    ' was ADIN 0
        TEMP = (TEMP / 2)
        SEROUT PORTC.6,16780, [ DEC TEMP,13]
    LOOP
(The code may be looping anyway after the processor runs out of memory to execute but this way is cleaner and proper.)
 

t06afre

Joined May 11, 2009
5,934
Your new schematic did not attach, nor did anything appear under where you say "it gave me this result" but I assume it did not work.

I don't use PICbasic anymore so I don't have a reference to completely check your code to check how you set up the voltage conversion, but generally what you are doing seems reasonable. (That means the error may be subtle and hard to spot.)

You are doing two tasks here:

1) read temperature voltage

2) transmit temperature voltage via RS232
The terminal program used by the OP is clearly ASCII based. So would it not be better to write something like this


Rich (BB code):
TEMP = 16706
and then
Rich (BB code):
    DO
        TEMP = 16706    ' was ADIN 0
          SEROUT PORTC.6,16780, [ DEC TEMP,13]
    LOOP
As a first test program. If everything OK then terminal program should show the letters "A" and "B" Until it do that something is wrong in the communication setup
 
Top