Mr.Cool
Advanced Member level 2
pic lcd proteus example
hello; i have recently been advised to try out proteus for all my pic16F877 simulation needs. this program is great! i have a question regarding simulating an LCD.
I am writing code in PIC BASIC PRO. and am trying to integrate this into proteus.
In proteus i have a PIC 16F877 and connected LCD as per the PIC BASIC book found here: h**p://www.mikroelektronika.co.yu/english/product/books/picbasicbook/07.htm#7.3%20LCD%20display
( i did not include the parts about the "backlight").
I also connected a logic probe to PORTB.0 to watch if my code would Blink-a-LED which it does with complete success.
my problem is getting the LCD to work. i have chosen the LCD model LM016L. i want it to display text on 2 lines. when i write the code in microcode studio, it looks like this:
DEFINE LCD_DREG PORTD ' I/O port where LCD is connected
DEFINE LCD_DBIT 4 ' initial bit selection (used in 4-bit bus)
DEFINE LCD_RSREG PORTD ' port register select
DEFINE LCD_RSBIT 2 ' Register select pin
DEFINE LCD_EREG PORTD ' Enable port
DEFINE LCD_EBIT 3 ' Enable pin
DEFINE LCD_BITS 4 ' 4-bit data bus
DEFINE LCD_LINES 2 ' LCD has 2 character lines
high PORTD.1 ' Turn on backlight
Main: ' Beginning of program
lcdout $fe,1 ' Clear the LCD display
' Print "first line" in the first line
lcdout "first line"
pause 2000 ' 2 sec pause
lcdout $fe,$c0 ' Move LCD cursor to second line
' Print "Second Line" in the second line
lcdout "Second Line"
pause 2000 ' 2 sec pause
end ' end of program
i then compile it and insert into proteus. i have written a Seperate program to blink and LED and insterted that into proteus and it works perfectly, so there is nothing wrong with my setup. i wonder if it is to do with proteus LCD verson the commands used by pic BASIC.
when i hit the simulate button the only thing that happens is the LED lights up (turns light green colour), but no text appears.
according to proteus documentation, the LCD works on "HD44780" model commands. searching the net i find a list of commands suitable to HD44780 LCDs as shown here:
h**p://www.doc.ic.ac.uk/~ih/doc/lcd/instruct.html
could it be that pic basic's command "LCDOUT" does not follow these insturcitons?? and so proteus knows not what to do?
Mr.Cool
hello; i have recently been advised to try out proteus for all my pic16F877 simulation needs. this program is great! i have a question regarding simulating an LCD.
I am writing code in PIC BASIC PRO. and am trying to integrate this into proteus.
In proteus i have a PIC 16F877 and connected LCD as per the PIC BASIC book found here: h**p://www.mikroelektronika.co.yu/english/product/books/picbasicbook/07.htm#7.3%20LCD%20display
( i did not include the parts about the "backlight").
I also connected a logic probe to PORTB.0 to watch if my code would Blink-a-LED which it does with complete success.
my problem is getting the LCD to work. i have chosen the LCD model LM016L. i want it to display text on 2 lines. when i write the code in microcode studio, it looks like this:
DEFINE LCD_DREG PORTD ' I/O port where LCD is connected
DEFINE LCD_DBIT 4 ' initial bit selection (used in 4-bit bus)
DEFINE LCD_RSREG PORTD ' port register select
DEFINE LCD_RSBIT 2 ' Register select pin
DEFINE LCD_EREG PORTD ' Enable port
DEFINE LCD_EBIT 3 ' Enable pin
DEFINE LCD_BITS 4 ' 4-bit data bus
DEFINE LCD_LINES 2 ' LCD has 2 character lines
high PORTD.1 ' Turn on backlight
Main: ' Beginning of program
lcdout $fe,1 ' Clear the LCD display
' Print "first line" in the first line
lcdout "first line"
pause 2000 ' 2 sec pause
lcdout $fe,$c0 ' Move LCD cursor to second line
' Print "Second Line" in the second line
lcdout "Second Line"
pause 2000 ' 2 sec pause
end ' end of program
i then compile it and insert into proteus. i have written a Seperate program to blink and LED and insterted that into proteus and it works perfectly, so there is nothing wrong with my setup. i wonder if it is to do with proteus LCD verson the commands used by pic BASIC.
when i hit the simulate button the only thing that happens is the LED lights up (turns light green colour), but no text appears.
according to proteus documentation, the LCD works on "HD44780" model commands. searching the net i find a list of commands suitable to HD44780 LCDs as shown here:
h**p://www.doc.ic.ac.uk/~ih/doc/lcd/instruct.html
could it be that pic basic's command "LCDOUT" does not follow these insturcitons?? and so proteus knows not what to do?
Mr.Cool