Reset risetime seems to upset LCD on 18f4550


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Location
    Durban. South Africa
    Posts
    2

    Default Reset risetime seems to upset LCD on 18f4550

    I am trying to drive a 4x20 LCD on port D of an 18f4550. If the circuit is started by switching on the power (risetime about 300 µsec) everything works fine but if the circuit is reset from an electronic signal from the programmer, the watchdog timer or mechanical switch with a risetime in the nano second region,the lcd is very confused. LCD is not reset from the PIC MCLR line.
    I have tried the circuit on the EasyPIC4 board from Mikroelektronika (horrors - the opposition !nice board but I dont like the compiler except for floating point) as well as a board I made myself with exactly the same LCD circuit . Also have tried 3 chips and all combinations do the same. When the LCD gets confused a few characters are missing at the start of the first line, the second line gets printed somewhere outside the display area, the third line is printed in the right place and the fourth line is printed on top of line one.
    If the program is put in a loop to repeat the four display lines it repeats the patern that it starts with. That is if it starts ok it repeats the display correctly but if it starts in the confused state all subsequent loops of the program are similarly confused.
    The program was run without the watchdog being enabled and then when enabled the ASM code was inserted to cause it to timeout.
    Any suggestions would be greatfully accepted.

    Sorry about cutting and pasting program, attach didnt seem to work.
    ' PICBASIC PRO program to demonstrate operation of an LCD in 4-bit mode
    'PROCESSOR = 18F4550
    ' LCD should be connected as follows:
    ' LCD PIC
    ' DB4 PortD.4
    ' DB5 PortD.5
    ' DB6 PortD.6
    ' DB7 PortD.7
    ' RS PortD.2 (add 4.7K pullup resistor to 5 volts)
    ' E PortD.3 AS IN EASYPIC4
    ' RW Ground
    ' Vdd 5 volts
    ' Vss Ground
    ' Vo 20K potentiometer (or ground)
    ' DB0-3 No connect
    DEFINE OSC 8
    DEFINE LCD_DREG LATD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG LATD
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG LATD
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 150

    trisa = 0
    TRISD = 0
    Pause 1800 ' Wait for LCD to startup
    mainloop:

    PORTA = 7
    PAUSE 500 'flash led
    PORTA = 0

    Lcdout $fe, 1 'CLEAR
    Lcdout $fe, $0C 'CURS OFF
    Lcdout $fe, 2 'HOME
    lcdout "Hello WORLD" ' WRITE
    PAUSE 500
    lcdout $fe,192, "second line"
    PAUSE 500
    Lcdout $fe, 148, "third line "
    PAUSE 500
    LCDOUT $FE,212, "FOURTH LINE"
    PAUSE 500
    'THE FOLLOWING FOUR LINES INSERTED TO FORCE WATCHDOG TO TIMEOUT FOR TEST
    Asm
    NOP
    GoTo ($-2)
    EndAsm
    Goto mainloop ' Do it forever

    END

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Reset risetime seems to upset LCD on 18f4550

    try what this thread is about:
    http://www.picbasic.co.uk/forum/showthread.php?t=8193
    also bypass your LCDpower pins with a .01 µ F cap.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Feb 2011
    Location
    Durban. South Africa
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Reset risetime seems to upset LCD on 18f4550

    Thanks Joe S

    The power is very well bypassed so I tried the FLAGS = 0 command and it worked but not without a bit of fiddling.
    I reasoned that if any reset occurrs the software would be reinitialised but I must be wrong.
    I first put the FLAGS command at the start of the program but that didnt work.
    I then put it after the clearing and home commands with a pause before continuing as below.

    Lcdout $fe, 1 'CLEAR
    Lcdout $fe, $0C 'CURS OFF
    Lcdout $fe, 2 'HOME
    flags = 0
    pause 2000
    lcdout "Hello WORLD" ' WRITE

    It was also neccessary to adjust the timing parameters quite carefully as below
    DEFINE LCD_COMMANDUS 3000
    DEFINE LCD_DATAUS 150

    It now works from any kind of reset.
    I have used literally hundreds of these displays with several PICS and 8051 types but never battled like this before!

    Thanks again for the suggestion.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts