problems with my lcd proyects

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello, I have been trying simple things running in my develop board,deccanbots. I am using and atmega16 and I am exploring the lcds. Everything was going almost right,jjj, but I realiced that when I turn off the power and then on, the proyect didnt work.
I load the file into the micro, it runs acconding to my capabilities,jjj, but if I release the power, then they dont work again.
why?

this is one code witch works:

(why does it take some seconds to the clock to start if i reset?)

/*este reloj tiene segundos minutos y horas */

//cambia los minutos y las horas con p0 y p1




#include 
#include 
#include "lcd_lib.h"

#define outp(a,b) b=a

volatile unsigned char uniseg=0;
volatile unsigned char deseg=0;
volatile unsigned char unimin=6;
volatile unsigned char decmin=5;
volatile unsigned char unihor=0;
volatile unsigned char dechor=0;


SIGNAL (SIG_OVERFLOW1)
{
outp(0xd7,TCNT1L); // al principio para q sea lo mas exacto posible
outp(0Xc2, TCNT1H);



uniseg++;
	

	if(uniseg==10)
	{
		uniseg=0;
	deseg++;
	}
	if(deseg==6)
	{
		deseg=0;
		unimin++;
	}
	if(unimin==10)
	{
		unimin=0;
		decmin++;
	}
	if(decmin==6)
	{
		decmin=0;
		unihor++;
	}
	if(unihor==10)
	{
		unihor=0;
		dechor++;
	}
	if((unihor==4)&(dechor==2))
	{
		unihor=0;
		dechor=0;
	}
	
LCDGotoXY(4, 1);
LCDsendChar(dechor+48);
LCDsendChar(unihor+48);
LCDstring(":", 1);
LCDsendChar(decmin+48);
LCDsendChar(unimin+48);
LCDstring(":", 1);
LCDsendChar(deseg+48);
LCDsendChar(uniseg+48);


}



int main(void)


{
DDRD=0X00;//ENTRADAS

outp((1 << TOIE1), TIMSK); // enables the T/C1 overflow
// - interrupt in the T/C
// - interrupt mask register
outp(0xd7,TCNT1L); outp(0Xc2, TCNT1H);

outp(0, TCCR1A); // no compare/capture/pwm mode
outp(3, TCCR1B); // prescale ck/1024
sei(); // set global interrupt enable

LCDinit();//init LCD 8 bit, dual line, cursor right
LCDclr();//clears LCD
LCDhome();//cursonr home
LCDcursorOFF();//quita la rayita

LCDGotoXY(4, 0);
LCDstring("demo hora", 9);
LCDGotoXY(4, 1);
LCDsendChar(dechor+48);//para parar a codigo ascii
LCDsendChar(unihor+48);
LCDstring(":", 1);
LCDsendChar(decmin+48);
LCDsendChar(unimin+48);
LCDstring(":", 1);
LCDsendChar(deseg+48);
LCDsendChar(uniseg+48);

for(;;)
{




if (bit_is_clear(PIND, 0) )
{unimin++;

	if(unimin==10)
	{
		unimin=0;
		decmin++;
	}
	if(decmin==6)
	{
		decmin=0;
		unihor++;
	}
	if(unihor==10)
	{
		unihor=0;
		dechor++;
	}
	if((unihor==4)&(dechor==2))
	{
		unihor=0;
		dechor=0;
	}

LCDGotoXY(4, 1);
LCDsendChar(dechor+48);//
LCDGotoXY(5, 1);
LCDsendChar(unihor+48);
LCDGotoXY(6, 1);
LCDstring(":", 1);
LCDGotoXY(7, 1);
LCDsendChar(decmin+48);
LCDGotoXY(8, 1);
LCDsendChar(unimin+48);



	while (bit_is_clear(PIND, 0) )
	{
	}


}

if (bit_is_clear(PIND, 1) )
{unihor++;

	if(unihor==10)
	{
		unihor=0;
		dechor++;
	}
	if((unihor==4)&(dechor==2))
	{
		unihor=0;
		dechor=0;
	}


LCDGotoXY(4, 1);//
LCDsendChar(dechor+48);//
LCDGotoXY(5, 1);
LCDsendChar(unihor+48);



	while (bit_is_clear(PIND, 1) )
	{
	}

}


	

}

}

after switch off and on power the only thing that apears is a cursor shift in the 3 column of the first row

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suspect that your pwer supply is slower than the LCD.

Press the reset switch without switching the power off.

Does the LCD work ok ?

Put a small start-up delay before calling lcd_init().

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

my power supply is 2A. ?¿?
I dont think it could be the power.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

osaka wrote:
...when I turn off the power and then on, the proyect didnt work.
I load the file into the micro, it runs acconding to my capabilities,jjj, but if I release the power, then they dont work again.

I've seen this problem before. If memory serves me correctly, the problem was in the initialization routine; though, I can't recall exactly what that deficiency was.

The first thing I would do is verify that your delays and W/R, E, and RS control lines are in the proper relation ship to the data being sent to the display within the initialization routine.

I do remember I spent a very long time studying the data-sheet, and realized that I had misinterpreted the control signal timing with reference to the data being sent to the display.

Sorry I can't be of more help.

EDIT:
In fact, While I see you are calling the LCD initialization routine in main(), I don't see the formal definition of the initialization routine.

If you decide to post it, please comment what you are doing in English. Don't worry about your command of the English language, as any English is better then not knowing how to read Spanish.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Search datasheet of LCD for control part, as microcarl suggested! After RESET it is possible that LCD need some delay, or write access according to pulling low or high reset line, best for you is to check datasheet and if you find in there something you don’t understand then post…

Try to first make initialization and simple data output, and see what you get! Maybe there are some problems in some calls…

P.S. Device data-sheet is best way to become familiar with work of device

Matthew

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well, guys , I have the answer of my problem.

I had the problem that once I swiched off the power supply of my trainer board the program didnt work anymore.
The problem was program loader chip connection. I always let them connected.
I tried to disconnect not needed things to solve this problem. for example the wires that connect the loader chip to my atmega16.
I switched off the power of my training board,...turned it again, and everything running again.
So newbies, be aware of the tricky things that unnecessary wires can do.

I wonder, how many of my previous problems could be caused by this...

but never again.

:D