PDA

View Full Version : LCD going crazy!!!



lerameur
- 1st November 2011, 02:03
This is a test program for my LCD. Sometime I can read on the screen but the following second the words are jumping from one line to another and the letters and just going about anywhere... any thoughts


'LCD testing program

INCLUDE "modedefs.bas"
OSCCON = %01110000 '8 Mhz

CMCON = 7 : ANSEL = 0 : ADCON1 = 7
'/////////////////////////
'// LCD configuration //
'/////////////////////////

DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTA ' Set LCD Register Select port
DEFINE LCD_RSBIT 2 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTA ' Set LCD Enable port
DEFINE LCD_EBIT 3 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
pause 1000


Mainloop:

lcdout $FE,1, " This is a test" '
lcdout $FE,$C0, "Next or Select" '
pause 200

GOTO Mainloop
End

Jerson
- 1st November 2011, 05:16
Just thinking aloud. Have you tried telling PBP
define OSC 8
so that it knows you are working at 8MHz and can adjust its timings accordingly.

bjsunbeam
- 1st November 2011, 09:02
try a pause between each lcd out
Some of the cheaper LCD's are not good with fast transfers
You can also try adjusting the LCD commandUs etc

lerameur
- 1st November 2011, 11:24
I did try using define, same thing happens. I have been using this LCD for a couple of years now. This is happening since I upgraded to windows7 64 bit. and using microcode studio

K

lerameur
- 1st November 2011, 12:56
I also changed pic, used different pins for RS RE LCDout. I just have not changed the LCD module with a new one.. maybe its the LCD ...

LinkMTech
- 1st November 2011, 14:00
How about:



Mainloop:

LCDOUT $FE,1 ' Clear display
PAUSE 50
LCDOUT $FE,2," This is a test" ' Move to 1st line, writes 15 CHAR
LCDOUT $FE,$C0,"Next or Select" ' Move to 2nd line, writes 14 CHAR
PAUSE 200

GOTO Mainloop
End

Jerson
- 1st November 2011, 14:50
taking a cue from Louie, I'd say, you're writing too fast for the lcd to keep pace.

You can try this



Mainloop:
LCDOUT $FE,1 ' Clear display
LCDOUT $FE,2," This is a test" ' Move to 1st line, writes 15 CHAR
LCDOUT $FE,$C0,"Next or Select" ' Move to 2nd line, writes 14 CHAR
STOP
End

lerameur
- 1st November 2011, 21:40
I think the revolution of the earth might of affected my chip. no but seriously I did not touch anything and it is working now...
even with pause 100 after the LCDout...
Althought i do not understand why I need these two line for my frequency:
OSCCON = %01110000 '8 Mhz
Define OSC 8


the OSCCON = %01110000 says that is is running at 8Mhz...

The program is not stable if I do not have BOTH of these lines... why ??


ken

Heckler
- 1st November 2011, 22:42
OSCCON = %01110000 '8 Mhz
Define OSC 8


OSSCON=%0111000 ... configures the actual PIC hardware

Define OSC 8 ... is a directive to the COMPILER to notifiy it that you have set the PIC hardware for 8 MHz

lerameur
- 2nd November 2011, 01:39
Got my hopes up too quickly ... :(
I wrote this clock program.. works good, but sooner or later, after 1 minutes or 4 minutes the Display acts up go crazy, sometimes it comes back showing a proper time.. but its really not stable...

K


'LCD testing program

INCLUDE "modedefs.bas"
OSCCON = %01110000 '8 Mhz
Define OSC 8

CMCON = 7 : ANSEL = 0 : ADCON1 = 7
'/////////////////////////
'// LCD configuration //
'/////////////////////////

DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 7 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 6 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
pause 500



'/////////////////////////
'// PIN configuration //
'/////////////////////////

TRISB = %00000000 ' Set PORTB to all output
TRISA = %11111111 ' Set PORTA to all input



'///////////////////////////////////////////////
'// Variable Declaration and initialization //
'///////////////////////////////////////////////

SDApin var PORTB.1 ' RTC data
SCLpin var PORTB.4 ' RTC clock


Total_time var byte
RTCSec var byte :RTCMin var byte :RTCHour var byte :RTCWDay var byte :RTCDay var byte :RTCMonth var byte :RTCYear var byte :RTCCtrl var byte



lcdout $FE,1, "Bienvenue"
lcdout $FE,$C0, "Welcome"
pause 500


'////////////////////////////////////////////////////
'////////////////// PROGRAM /////////////////////////
'////////////////////////////////////////////////////
I2CWRITE SDApin,SCLpin,$D0,$00,[$49,$59,$00,$00,$00,$00,$00,$00] ' Write to DS1307 to start counter at ZERO
Pause 30

Mainloop:


I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl]
Pause 30
'Will get the time from timer chip and do a 60 min count down
'Also add interrupt if someone presses start to view the charge/discharge cycle
LCDOUT $FE,1 ' Clear display
PAUSE 20
lcdout $FE,2, "Kens Clock"
lcdout $FE,$C0, "time: ", HEX2 RTCHour, ":", HEX2 RTCMin, ":", HEX2 RTCSec
Pause 300
Goto Mainloop
end

Jerson
- 2nd November 2011, 07:09
Question time:
1 - How is your circuit built? Breadboard? or a proper PCB?
2 - How about decoupling capacitors. Do you have them 0.1uF across the supply rails?
3 - How are you powering the circuit? Chances are you have a bad ac adapter (assumption)

I know I'm asking the obvious, but, in times of stress, you need to recheck these.

regards
Jerson

lerameur
- 2nd November 2011, 12:55
I am using a breadboard, powered from a 12v battery and a 10uf 16v rail to rail cap. I might redo the circuit on another breadboard using different wires and parts tonight..

k

lerameur
- 3rd November 2011, 12:17
Changed the breadboard and all parts. Works perfectly now. I think the breadboard might be damaged...
ken