View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
Strange problem with LCD display *SOLVED* |
Posted: Mon Apr 08, 2013 12:03 pm |
|
|
Hello fellows!
Here is the code:
Code: | #include <16f1508.h>
#fuses INTRC_IO, NOWDT, NOMCLR
#use delay (internal = 16M)
#define LCD_RS_PIN pin_a2
#define LCD_RW_PIN pin_c0
#define LCD_ENABLE_PIN pin_c1
#define lcd_Data4 pin_c2
#define lcd_Data5 pin_B4
#define lcd_Data6 pin_B5
#define lcd_Data7 pin_B6
#include <lcd.c>
void main()
{
lcd_init();
while(true)
{
printf(lcd_putc,"\fFirst row data");
printf(lcd_putc,"\nseccond row data");
delay_ms(20);
output_toggle(pin_b7); //Just for debuging
delay_ms(200);
}
} |
The problem is this: If I am printing only first row data everything works fine, but when I put \n in the string something goes wrong. Second row data is displaying for couple of seconds afterwards i get fake data on the display. I have never had similar problem so far. If someone sees something wrong into the code plz let me know!
Thank you in advance! _________________ A person who never made a mistake never tried anything new.
Last edited by rikotech8 on Thu Apr 11, 2013 8:34 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Apr 08, 2013 12:30 pm |
|
|
some things to consider...
1) Which LCD module ???
2) I always have a delay_ms(1000) before the LCD_init() call
3) I always have a delay_ms(500) after the LCD_init() call
4) check what other peripherals are 'attached' to your pins that you haven't disabled.
5) I always use the 'flex_lcd' driver.
hth
jay |
|
|
branko
Joined: 26 Mar 2013 Posts: 8 Location: Russia
|
Re: Strange problem with LCD display |
Posted: Mon Apr 08, 2013 1:23 pm |
|
|
Try this
Code: |
#define LCD_RS_PIN PIN_A2
#define LCD_RW_PIN PIN_C00
#define LCD_ENABLE_PIN PIN_C1
#define LCD_DATA4 PIN_C2
#define LCD_DATA5 PIN_B4
#define LCD_DATA6 PIN_B5
#define LCD_DATA7 PIN_B6
|
Try using \r instead of \n _________________ Regards
Branko |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Mon Apr 08, 2013 1:50 pm |
|
|
I seem to remember running into an issue like this in the past where I needed to put a delay after a newline or return (it's been a while, but you might give that a shot).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Apr 09, 2013 12:34 am |
|
|
Yes.
My general guess would be that timing is tight for the particular display. Posting the manufacturers part number would be the place to start, preferably with a link to the data sheet. Then we can see if there is anything abnormal in the goto timing.
There is a generic problem, that all these displays are based on 'clones' of the Hitachi controller, and some clones just have tiny differences, that can cause problems.
Things to try:
1) Temtronic's comment about extra delay before starting is well worth following. All these displays do take time to wake up, and the driver allows a little, but many require more than is allowed. Also some start to wake at higher voltages than the PIC, so the PIC can start timing, before the LCD has even begun to wake up. A pause before initialisation is generally a 'good idea'.
2) Consider trying the flex_lcd driver instead. This is generally a little more rugged than the CCS lcd driver, handling 'variations' in the display better than the latter. Temtronic has this as his number 5....
3) /r, won't do the same as /n, on the standard driver. If extended newline is enabled, it moves the cursor to the start of the current line. If not, it does nothing.
4) Use lcd_gotoxy(1,2), instead of newline. The newline function actually writes data to the end of the line, to clear it, so a lot more work, than just doing a direct move to where you want to put the second line. I hardly ever use /n on an LCD.
Best Wishes |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Tue Apr 09, 2013 12:25 pm |
|
|
Hello! Much appreciate all of your replies!
The LCD I am using is: http://store.comet.bg/bg/Catalogue/Product/14282/
I tried with lcd_gotoxy(1,2) and the result was the same.
I haven't tried the delays before and after lcd_init(); but as soon as I am able to try it I will post feedback.
Can someone write me a link or somehow to point me out how can I get flex_lcd driver?
As I said I have no time for now, to try out all your suggestions, but as soon as I have enough time I will write you back.
Thank you again Guys! _________________ A person who never made a mistake never tried anything new.
Last edited by rikotech8 on Tue Apr 09, 2013 12:57 pm; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Apr 09, 2013 12:56 pm |
|
|
In which case, I probably know what is happening.
These displays have a resistor Rf which sets the frequency the oscillator runs. The one supplied as standard are set to allow the display to run at 3v. This results in them running much slower than standard at 5v. The resistor is meant to be 91KR at 5v, and 75KR at 3v. The controller on these is the Samsung KS0066, which is normally a very good clone of the Hitachi.
The flex LCD driver is in the code library. Provided you use the handshake mode, this should work even with the lower resistor.
Best Wishes |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Wed Apr 10, 2013 12:44 pm |
|
|
Hello again guys!
The news are not good
I tried with the flex_lcd driver and the outcomes are the same.
Here is what I have done: Code: |
#include <16f1508.h>
#fuses INTRC_IO, NOWDT, NOMCLR
#use delay (internal = 16M)
#include <flex_lcd.c>
void main()
{
delay_ms(1000);
lcd_init();
delay_ms(500);
while(true)
{
printf(lcd_putc,"\fFirst row data");
printf(lcd_putc,"\nseccond row data");
delay_ms(20);
output_toggle(pin_b7); //Just for debuging
delay_ms(200);
}
} |
I made a brief video so you can see actually what I get on the screen:
http://youtu.be/mORlaTbgsoY
It's randomly how much time the desired data being held, before the false one to appear. _________________ A person who never made a mistake never tried anything new. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Thu Apr 11, 2013 4:45 am |
|
|
Here is my new code as you recommended. Code: |
#include <16f1508.h>
#fuses INTRC_IO, NOWDT, NOMCLR
#use delay (internal = 16M)
#include <flex_lcd.c>
void main()
{
SETUP_ADC(ADC_OFF);
SETUP_WDT(WDT_OFF);
setup_comparator(NC_NC_NC_NC );
SETUP_SPI(SPI_DISABLED);
SETUP_CLC1(CLC_DISABLED);
SETUP_PWM1(PWM_DISABLED);
SETUP_PWM2(PWM_DISABLED);
SETUP_PWM3(PWM_DISABLED);
SETUP_PWM4(PWM_DISABLED);
delay_ms(1000);
lcd_init();
delay_ms(500);
while(true)
{
printf(lcd_putc,"\fFirst row data");
delay_ms(1);
lcd_gotoxy(1,2);
printf(lcd_putc,"Seccond row data");
delay_ms(20);
output_toggle(pin_b7); //Just for debuging
delay_ms(100);
}
} |
Unfortunately, nothing has changed. _________________ A person who never made a mistake never tried anything new. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Apr 11, 2013 5:39 am |
|
|
Are there any unterminated inputs to the LCD? It looks to me like the LCD is spuriously rebooting or resetting. It does not look like a software problem. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Thu Apr 11, 2013 8:33 am |
|
|
Finally Problem has solved!
Guys the problem wasn't software indeed. I had a bad Vdd connection which caused the problem. Anyway thank you to all for the useful advices! _________________ A person who never made a mistake never tried anything new. |
|
|
|