Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Proteus & LCD & 16F877 problem

Status
Not open for further replies.

Mr.Cool

Advanced Member level 2
Joined
Jun 20, 2001
Messages
664
Helped
87
Reputation
178
Reaction score
60
Trophy points
1,308
Activity points
7,111
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
 

picbasic sample code 16f877

Hi,

I can help you, but only in C code.


NeuralC
 

proteus color lcd simulation

the lcdout command is especially for the hd 44780 (or equivalent) so it only works with this type of lcd controller..
could u probably post ur proteus design + binary?

did u double check ur wiring ;)

dsp_
 

picbasic lcd 16f877

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

DEFINE portD 0xFF all outputs etc...... look in picbasic manual

for a good example

look on the mel site for source code and also to picbasic.org....

knowwhere do i see a port tris definition
or port pass parameter's
for direction and pullup switch etc....

if you add the correct definition for the port registers first

it will work

these go just below the lcd definitions
 

picbasic lcd pin selection

Hi all

Mr.Cool
here you will find a little project (pbp and proteus)
he use one 16f877 with one lcd
download the next file


you can look this code and this project here
h*t*tp://w*ww.re*ntr*on.com/PICX2.htm

debutpic
 

4 bits hd44780 16f877 backlight

Hello Mr.Cool,
Did u LCD<D3:D0> and RW connected the ground?
And what is yours osc fr? Because Pbp of accepted the default osc fr is 4 Mhz.If you use the different osc fr,u must define that.

Example;
.
DEFINE OSC 20
.

Did u check the ports?Those true?
With my dear...
 

Re: picbasic lcd pin selection

Declare Adin_Res 10 ' 10-bit result required
Declare Adin_Tad FRC ' RC OSC chosen
Declare Adin_Stime 50 ' Allow 50us sample time

Declare LCD_Type 0 ' Type of LCD Used is Alpha
Declare LCD_DTPin PORTB.4 ' The control bits B4,B5,B6,B7
Declare LCD_RSPin PORTB.2 ' RS pin on B2
Declare LCD_ENPin PORTB.3 ' E pin on B3
Declare LCD_Interface 4 ' Interface method is 4 bit
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top