Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Temperature sensor using pic18f452...require urgent help!!

Status
Not open for further replies.

huzeeigat

Member level 4
Member level 4
Joined
Mar 18, 2012
Messages
75
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Location
Andheri
Activity points
1,776
Hey i m making a temperature sensor using lm35 and pic18f452
the objective is to control the temperature between 25 and 27'C...when the temperature is below 25'c,a heater is to be turned on at pin RD3 and when the temperature is above 27'c,a cooling fan is to be turned on at pin RD2...I have written the code in c lang..and compiled successfully in mplab..but when i tried it on proteus along with the circuit...i get an error as follows...
Processor has been reset by watchdog timer expiring at xyz time...i disabled the wdt from mplab...and then again tried on proteus but i get the same error...i dont knw how to change the oscillator frequency in mplab...m posting the code along with the proteus ckt...can any1 tell me wat is the problem....



---------- Post added at 15:43 ---------- Previous post was at 15:31 ----------

here is an image of the simulation window that i get on proteus after i execute the above circuit
 
Last edited:

The Problem is in Your Connection's...

The First Pin of Micro-Controller MCLR is pulled-high to Vdd by a 10K resistance and after that you have attached a capacitor to ground.
Which always reset your controller.
Remove that connection from ground.
This is causing reset

Hope this helps..
 

Help.JPG

Do like this, as shown in the above pic

Hope this help
 

Hey thanks for ur reply....
But i am still getting the same error of processor is reset by watchdog timer...
 

Upload your code in zip format and Proteus Simulation File...

I will see and correct your problem...

---------- Post added at 21:55 ---------- Previous post was at 21:40 ----------

Also Check PIC18F452 Configuration Bits, Set them Properly and try again i don't anyother problem.
If you could be able to upload your code and hex file and proteus file then i could do something..
 

Hey i have attached the c file and the proteus design here..have a look...
:)
Thanks,
Regards
Huzefa Igatpuriwala
 

Attachments

  • tmp sensor.zip
    18.5 KB · Views: 74

I am not using the same Compiler as u are using...

Try to give me the whole project, till then i am looking at it..

I also need hex file, thats why i want whole Project in Zip Format
 

I am attaching the entire project files now...i am using mplabc18 compiler for my c code...
I checked the configuration bits and disabled the watchdog timer...i saw in one of the threads that i also have to set the oscillator frequency, but that i was unable to change in configuration bits...
And also i dont have any idea about the rest of the configuration bits..
Regards,
Huzefa
 

Attachments

  • tmp sensor.zip
    34 KB · Views: 72

Small mistake in your code...

in the void temperature function, you have use a while loop

Have a look at it
Code:
void temperature(void)
{
ADCON0=0X81;
ADCON1=0XC5;
[B][I][U]while(1);[/U][/I][/B]
{
delay();

ADCON0bits.GO=1;
while(ADCON0bits.DONE==1);
l_byte=ADRESL;
h_byte=ADRESH;
l_byte>>=2;
l_byte &=0X3F;
h_byte<<=6;
h_byte=0XC0;
bin_temp=l_byte|h_byte;
}
}

Have you seen that while(); the semi-comma make the controller to stay here forever
Remove that
Code:
void temperature(void)
{
ADCON0=0X81;
ADCON1=0XC5;
while(1)
{
delay();

ADCON0bits.GO=1;
while(ADCON0bits.DONE==1);
l_byte=ADRESL;
h_byte=ADRESH;
l_byte>>=2;
l_byte &=0X3F;
h_byte<<=6;
h_byte=0XC0;
bin_temp=l_byte|h_byte;
}
}


---------- Post added at 22:48 ---------- Previous post was at 22:43 ----------

You can have a look at this link....

https://sites.google.com/site/coole...0/tutorial-list/temperature-monitoring-system
 
In the beginning of the code, after the #include statement, add these two lines:
Code:
#pragma config WDT=OFF //Turn watchdog timer off
#pragma config OSC=XT //For 4MHz oscillator

Now, I don't get any errors in simulation. Also, make the change done by arunsharma0731.

Hope this helps.
Tahmid.
 
Hey i removed the semi colon from the function but still i have the same error of processor getting reset by WDT... and i also want to ask you that in all the while loops of my code..i have a semicolon at every end...just have a look is it right?
 

You've probably set it from Configure > Configuration Bits. But in the past that had cause problems for me. And it's also not working now. So, just mention config bits in code by checking Configuration Bits Set in Code.

---------- Post added at 23:22 ---------- Previous post was at 23:22 ----------

Hey i removed the semi colon from the function but still i have the same error of processor getting reset by WDT... and i also want to ask you that in all the while loops of my code..i have a semicolon at every end...just have a look is it right?

Did you add the #pragma config statements?
 

I think you don't know how to write a C Program...
You have done so many mistakes in that...
After every while() loop you have put a semicolon which means infinite loop

Tahmid have a look at code, he has used so many while loops and
statements like
while();

which is causing the controller to Hangs and reset always...

Friend first try with Simple programs then go to some advanced ones...
 
Last edited:
Oh My ***....

I think you don't know how to write a C Program...
You have done so many mistakes in that...
After every while() loop you have put a semicolon which means infinite loop

The code is pretty messed up. The loops are all messed up.
 

@Arun and Tahmid: thanks for ur help friends...i am not getting the error of wdt now...but in proteus the circuit isnt working according to my program...when the temperature is below 25'c the led at pin rd3 should glow...and when above 27'c the led at pin rd2 should glow...can ull tell me what is the problem?
i am attaching the image and also the design file along with it...
 

Attachments

  • project.zip
    330.3 KB · Views: 77

Firstly, you should understand the while loop.

Code:
while (a == b);
{
//...........
//...........
}

In the code above, the code will check if a == b. If it does, it will stay there doing nothing until a is not equal to b. And then the part within braces is executed.

Code:
while(a==b)
{
//.......
//.......
}

In the code above, if a==b, the part within the braces is executed repeatedly until a is not equal to b.

Placing a ; after the while loop and the condition like in the 1st example I provided and like what you initially did, "terminates" the while loop execution block in the sense that it signals that it is where code execution is condition is true is limited. So, if ; is placed directly after the while loop, it's just doing nothing while the condition is true.

Hope this helps.
Tahmid.

---------- Post added at 23:35 ---------- Previous post was at 23:33 ----------

I'm looking at the corrections to be made and will let you know.
 
Yup arun..i removed all the semi colons from while loops in my code..and yes this is the first time that we are using embedded c for pic18f so i dont have much practice with i....
 

Friend have a look at this site...
I will provide you the libraries for LCD ans Serial Communication if You want..

https://sites.google.com/site/coole...0/tutorial-list/temperature-monitoring-system

And Your code is prettly ugly.. don't be sad, during starting stage all face these sort of problems..


If you want me to write a code for ur controller then give me some time i will write a one for you..
Not a big task for me...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top