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] project in distress..

Status
Not open for further replies.

InNeedOfHelp

Full Member level 3
Full Member level 3
Joined
Dec 5, 2012
Messages
169
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Visit site
Activity points
2,205
To all the smart peoples out there,,

Im using a PicDem 2 Plus Board with a PIC18F4520 using C-18 Compiler to do my temperature sensor project using TC74.
I have written my codes several times over and over again, but i can't see to be able to display the temperature on the LCD of the board.
For all the codes i written ,i managed to build successfully but there is just no display..

i have already managed to do the second part of my project , which is to get the Fan turn on using a push button .

Phase 3 of the project will be when the temperature gets too high the fan will be auto turn-on
For phase 3 i managed to think of the codes already.

I really need some help now.. PLEASE

hope to see more and more people correcting my errors and explaining it to me

Thanks

I have also attached my codes in the attachment
 

Attachments

  • Temp(Redo Version).zip
    48.3 KB · Views: 84

Mr.InNeedOfHelp,

to get the true result you must test each routine separate. for example test first lcd routine if it working good go the next temperature reading and so on. Do this in the first the ask help about the error portion.
 
The lcd function is working alright as many of the different projects i used the same header files.. so i should test the temp now ?
 

sorry i doesn't have experience in PIC. i given you a general advice. i hope one of the PIC expert help you :)
 

Im using PIC18F4520 . fosc is using internal oscillator as i have burned several crystals before.
I am using
Code:
#pragma config OSC =INTIO67

- - - Updated - - -

UPDATED POST
 

Attachments

  • schematic.pdf
    157.8 KB · Views: 81

Are you using HD44780 compatible LCD? Are you able to display some string on LCD? See the image. Is the circuit right?


Edit: I am not able to build your files. the object files are getting deleted.
 

Attachments

  • tc74.jpg
    tc74.jpg
    413.9 KB · Views: 87
  • build.jpg
    build.jpg
    285.6 KB · Views: 85
Last edited:

I managed to display strings already. Yup my LCD is HD44780. the I2C need connect as well ?
 

object files are created befor linking and creating hex file but the compiler is cleaning the files and hence I am not able to build the project.


Edit: I checked your code. Both LCD and I2C is not working. The value of temp remains 0 and putcLCD("something") doesnt print anything on lcd. Check your lcd and i2c codes.

- - - Updated - - -

I compiled it.
 
Last edited:

you managed to compiled it ?
how to solve the LCD issue ?
cause normally i use the same files to write strings in the LCD.. and normally it will display the strings i inputted..
the file is together with the zip file..
 

I used the function putsLCD("Hello"); in your code but it doesn't generate any output.

There is no LCD display and I2C clock is not working. may be your i2c code is correct but there is not i2c clock generating.

See this https://ww1.microchip.com/downloads/en/devicedoc/mplab_c18_libraries_51297f.pdf

See Hardware i2c library functions in the above document. Try to use those functions in your code.
 

Attachments

  • i2c.jpg
    i2c.jpg
    239 KB · Views: 90
Last edited:

lcd.JPG
I am using
Code:
putrsLCD((const far rom char )* "FinalYearProject");
to print The string..

the function of the
Code:
putsLCD
is to Position the cursor to the first character of the specified line

- - - Updated - - -

Code:
#include<p18f4520.h>
#pragma config LVP = OFF
#pragma config OSC = INTIO67
#include "picdem2lcd.h"

#include<i2c.h>
#include<delays.h>

void main()
{
	unsigned int LastTemp = 0;
	TRISB = 0x00;
	PORTB = 0x00;
	TRISD = 0x00;
	PORTD = 0x00;
	SSPSTAT = 0x80; //Disable SMBus & Slew Rate Control 
	SSPCON1 = 0x28; //Enable MSSP Master 
	SSPADD = 19; //Fosc = 48MHs HS+PLL for 100kHz 
	SSPCON2 = 0x00; //Clear MSSP Conrol Bits 
	
	while(1)
	{
		IdleI2C(); // ensure module is idle 
		StartI2C(); // initiate START condition 
		while ( SSPCON2bits.SEN ); // wait until start condition is over 
		Delay10TCYx(10);
		WriteI2C( 0b10011010 ); // Send TC74 address (Write; LSB=0 10011010) 
		IdleI2C(); // ensure module is idle 
		WriteI2C( 0 ); // Select Temperature Register 
		IdleI2C(); // ensure module is idle 
		RestartI2C(); // generate I2C bus restart condition 
		while ( SSPCON2bits.RSEN ); // wait until re-start condition is over 
		WriteI2C( 0b10011011); // Send TC74 address (Read; LSB=1  10011011) 
		IdleI2C(); // ensure module is idle 
		ReadI2C(); // read in the temp 
		NotAckI2C(); // send not ACK condition 
		while ( SSPCON2bits.ACKEN ); // wait until ACK sequence is over 
		StopI2C(); // send STOP condition 
		while ( SSPCON2bits.PEN ); // wait until stop condition is over 
		LastTemp = SSPBUF; // LastTemp is a Global unsigned char
	

	} 
}

I rewrote another code try to see if I2C is working...
For this code i referred to the I2C access sequence mentionned in the TC74 datasheet....
Hope that it will works.

can you use Proteus and test it out for me if possible ?
 

hmmm. is there anyway to port this value to LCD ? this value now is int or char?

- - - Updated - - -

if i use this it won't work , am i right ?

Code:
printf("Temp[C] = %d ",&LastTemp);
 

As the i2c result is assigned to int variable it will be stored as int. Does your putrsLCD() convert int to char? If not, then you have to convert int to char and then display it but I tried putsrsLCD("Hello"); and it doesn't print.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top