PDA

View Full Version : lcd stops after about 5 minutes and gets stuck



robertpeach
- 11th September 2009, 13:14
hi ive got a real simple lcd program, just trying to see what it does over long periods of time. however it works for a while, but everynow and then only half the word appears on an update and then after 5 minutes it just gets stuck with the same output. it works at first real smooth just as i want it to. watchdog timer doesnt reset it either...

im using an 18f2431 and this is my simple code:


define OSC 20 'define oscillator at 20mhz

Define LCD_DREG PORTC 'defining portC for the databits
define LCD_DBIT 4 'defining bits 4-7 as the 4 data bits for lcd
define LCD_RSREG PORTC 'defining the RS register to be on PORTC
define LCD_RSBIT 0 'defining bit0 of portC as the RSbit for LCD
Define LCD_EREG PORTC 'defining the LCD enable bit to be on portC
define LCD_EBIT 3 'defining the lcd enable bit on portc to be bit0
define LCD_BITS 4 'set number of lcd data bits, 4 is standard
define LCD_LINES 2 'define the number of lines on LCD, 2 lines is standard
define LCD_COMMANDUS 3000 'set command delay time in microseconds
define LCD_DATAUS 150 'set data delay time in microseconds



pause 1000 'pause for initialization of lcd
main: 'start of program, where the program loops back to
lcdout $FE,1,"hello" 'clears display and shows "hello" on first line
'$FE,1 clears display
'"hello" shows hello on lcd
lcdout $FE,$C0,"world" 'goes to second line of lcd and displays "world"
'$FE,$C0 = move cursor to beginning of second line
'"world" displays world

pause 1000 'pause so not to update lcd too quickly

lcdout $FE,1,"EVANCE" 'clears display and shows "hello" on first line
'$FE,1 clears display
'"hello" shows hello on lcd
lcdout $FE,$C0,"ISKRA" 'goes to second line of lcd and displays "world"
'$FE,$C0 = move cursor to beginning of second line
'"world" displays world
pause 1000

goto main 'end of program and looping back to start of program

end

thanks

Dave
- 11th September 2009, 15:35
robertpeach, I have found in the past some LCD's require a timeout of approx. 5 to 15 milliseconds after receiving a clear command.. Try putting a "PAUSE 15" statement just after the clear LCD command... I'm pretty sure that will take care of the problem...

Dave Purola,
N8NTA

Archangel
- 11th September 2009, 19:19
Hi Robert,
this PIC has capture comparators on portC, turn them off
CCP1CON = 0

robertpeach
- 14th September 2009, 10:46
thanks for the help!

made a difference, although i still had a problem. in the end i tried putting a capacitor (about 470micro ohms) across the input voltage and the ground. this made my pic work real smooth and now all my programs run completely fine over long periods of time!

unfortunately im not an expert on schematics of electronics and it was probably quite obvious to a seasoned programmer... can anyone explain the physical reason behind why this worked? sorry im quite interested in knowing this kind of stuff.

mackrackit
- 14th September 2009, 13:25
Properly sized caps near the PIC across VDD/VSS will help do a final clean up of the power. The power supply may have nice clean power but a lot can happen along the way to the PIC.

Larger caps most anyplace in the circuit will help with short "brown outs" a short term battery of sorts.

That is all the technical I feel like today :). But it should give you the idea.

dias11
- 14th September 2009, 15:03
Hi
Im new at microcontrollers and i have the same problem with pic16f877a.
Im try to make a counter.

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 2


cnt var word
cnt =0
pause 1000

mainloop:
Lcdout $fe, 1
Lcdout $fe, 2
cnt = cnt +1
Lcdout "x=",DEC cnt
Pause 1000


Goto mainloop


LCD starts to count (sometimes doesnt start) and after few seconds gives me
-<????-<????-<????-<????
and other strange things.

same results if i use port B or port E. The pins connections are ok because i see sometimes the counter running.
Please give some advice, i cant sleep at night. :confused:

mackrackit
- 14th September 2009, 15:11
You might try adding these line to your code


define LCD_COMMANDUS 3000 'set command delay time in microseconds
define LCD_DATAUS 150 'set data delay time in microseconds

mehmetOzdemir
- 14th September 2009, 15:20
I think these are all about your config settings.

Try ; power_on_reset_enable and brown_out_reset_enable



@ device pwrt_on , bod_on

dias11
- 14th September 2009, 15:45
Thanks
mehmetOzdemir

Can someone tell me all about @........
Do i have to use something like ?

@ DEVICE pic16F877 ' System Device
@ DEVICE pic16F877, WDT_ON ' Watchdog Timer
@ DEVICE pic16F877, PWRT_ON ' Power-On Timer
@ DEVICE pic16F877, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F877, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F877, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F877, PROTECT_OFF ' Program Code Protection
@ DEVICE pic16F877, XT_OSC

mackrackit
- 14th September 2009, 16:37
http://www.picbasic.co.uk/forum/showthread.php?t=543

Archangel
- 14th September 2009, 19:38
thanks for the help!

made a difference, although i still had a problem. in the end i tried putting a capacitor (about 470micro ohms) across the input voltage and the ground. this made my pic work real smooth and now all my programs run completely fine over long periods of time!

unfortunately im not an expert on schematics of electronics and it was probably quite obvious to a seasoned programmer... can anyone explain the physical reason behind why this worked? sorry im quite interested in knowing this kind of stuff.I have found putting a .01 &micro;F capacitor on the lcd power pins helps too

dias11
- 14th September 2009, 21:36
Thanks everyone. i put

@ DEVICE pic16F877 ' System Device
@ DEVICE pic16F877, WDT_ON ' Watchdog Timer
@ DEVICE pic16F877, PWRT_ON ' Power-On Timer
@ DEVICE pic16F877, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F877, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F877, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F877, PROTECT_OFF ' Program Code Protection
@ DEVICE pic16F877, XT_OSC


and all works fine.
:p

robertpeach
- 15th September 2009, 08:50
thanks mack and joe.s

yeah that makes total sense, i was just being a bit idiotic i think! it just stores energy almost and then when there is a fluctuation in power source, the capacitor releases the built up charge to oppose the change.

mackrackit
- 15th September 2009, 12:03
thanks mack and joe.s

yeah that makes total sense, i was just being a bit idiotic i think! it just stores energy almost and then when there is a fluctuation in power source, the capacitor releases the built up charge to oppose the change.

That was a good question. Not idiotic.

Oppose the change. Yes, we must.