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.
Code:
 unsigned int LastTemp
defines LastTemp variable as unsigned int. So, you cannot store values less than 0 in it. In
Code:
 signed int LastTemp
you can store negative values. For range of values for different data types see c18 manual.

Have you tested the LCD code you are using before? Does it work?
 
i took a look at the C18 Manual..
do you think we can use
Code:
#include <capture.h>
?

- - - Updated - - -

or perhaps use
Code:
putcUSART
 

To use putcUSART you have to use OpenUSART() function to start serial communication. Then if you use putcUSART it will print on Virtual Terminal. If you have any other project with LCD code working then post it.
 

First attached file is Voltage Test.rar.. using ADC..

Second Attached file is my original file , i using the lib original xlcd.h file

i got this error . no matter how i solve also cannot solve ...
Error - could not find definition of symbol 'DelayFor18TCY' in file 'busyxlcd.o'.
 

Attachments

  • Voltage Test.rar
    57.1 KB · Views: 64
  • Rewritten Program.rar
    20.6 KB · Views: 61

Voltage Test.rar is the one that is displaying strings...
Both are using PIC18F4520 and are using internal osc
 

Code:
#include<p18f4520.h>
#include "picdem2lcd.h"
#include<i2c.h>
#include<delays.h>
#include <stdio.h>

#pragma config OSC = INTIO67
#pragma config WDT = OFF    //Turn off watchdog timer
#pragma config LVP = OFF    //Turn off low voltage program
#pragma config DEBUG = OFF  //Turn off debug mode

void initLCD(void);
//Start Of Main Function//
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; //Internal Crystal 8MHz, Standard Mode for I2C 100kHz : Fosc/4*(SSPADD+1) 
	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
		initLCD();
		putrsLCD((const far rom char * ) "Hello");
	

	} 
} 
void initLCD(void)
{
	putrsLCD((const far rom char*)"Initializing LCD...");
	TRISD = 0x00;       //Set port D as outputs initially for LCD
	PORTDbits.RD7 = 1;  //Power On LCD
	OpenXLCD(FOUR_BIT & LINES_5X7);
	while(BusyXLCD());
	WriteCmdXLCD(DON & CURSOR_OFF & BLINK_OFF);
	printf((const far rom char*)"done.\r\n");
}

i followed the same method as i did before but it still couldnt display
 

See this simulation video. It is displaying and i2c is working but the display is moving. You are not getting the display because you have not called initLCD() before main() function.
 

Attachments

  • i2c.rar
    142 KB · Views: 55
Ok. I got the I2C value displayed. See it shows 27 for 27 degrees. We have to stop the moving. Don't worry we will fix it. No not because of the while loop.
 

Attachments

  • i2c v2.rar
    161.7 KB · Views: 61
ic... i remember when i was doing C++ program.
there was a function call leave a line
Code:
printf("/n");
or is it /r . i am not very sure of it already
 

It is printf("\r\n");


Edit: See it is working.
 

Attachments

  • tc74 i2c lcd.jpg
    tc74 i2c lcd.jpg
    255.8 KB · Views: 70
  • Temp(Redo Version) v2.rar
    68.7 KB · Views: 74
  • Temp(Redo Version) v4.rar
    63.8 KB · Views: 64
  • tc74 v3.jpg
    tc74 v3.jpg
    512 KB · Views: 74
Last edited:

jayanth, if i were to draw a flowchart for my temperature program, how am i going to do it ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top