PDA

View Full Version : Two LCDs on one PIC



lester
- 6th August 2004, 16:16
Originally posted by NavMicroSystems on - 4th August 2004 11:22

As this has been asked several times:
Here is an example how to connect two LCDs (or one LCD with two controllers) to the PIC.

You need just one additional Port Bit to toggle between the two controllers.

As only one Controller is enabled at a time
and the LCD is initialized when the first LCDout command is issued
you will need to reset the "INIT Flag" after the first LCD has been initialized.
Then select the second LCD and send a "CLEAR" to initialize the second LCD.

See PBP Manual Section 5.37

Example:
(assuming LCD-Select is connected to PortB.1)

Add to the beginning of your code:

------------------------------
LOW PortB.1 ' Select LCD 1
LCDout $Fe,1 ' initialize and Clear LCD 1
Flags=0 ' Reset "INIT-Flag"
HIGH PortB.1 ' Select LCD 2
LCDout $Fe,1 ' initialize and Clear LCD 2
------------------------------

Darrel Taylor
- 22nd February 2005, 00:31
Originally posted HERE (http://www.picbasic.co.uk/forum/showthread.php?t=626)

Here's another example of 2 LCD's on 1 PIC (See schematics)
Gif format http://www.pbpgroup.com/files/2_LCDs.gif
PDF format http://www.picbasic.co.uk/forum/attachment.php?attachmentid=91

With this method, you can send to either LCD independantly, or to both LCD's at the same time. The only additional parts required are 2 resistors.

By taking the LCD?_Disable pins LOW, it prevents the Enable signal from getting to that particular display. So, just disable the one you don't want to send to, and it sends the data to the one you want.

This method can have more than 2 displays attached to the same pic. The only limitation is the number of pins that are available.

DO NOT attempt to use the R/W pin on the LCD's! The displays will be damaged when more than 1 display is enabled at the same time.

Here's a simple program:
DEFINE LCD_DREG PORTB ' LCD Data port
DEFINE LCD_DBIT 0 ' starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' LCD Register Select port
DEFINE LCD_RSBIT 4 ' LCD Register Select bit
DEFINE LCD_EREG PORTB ' LCD Enable port
DEFINE LCD_EBIT 7 ' LCD Enable bit
DEFINE LCD_BITS 4 ' LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 4 ' Number of lines on LCD

LCD1_Disable VAR PORTB.5
LCD2_Disable VAR PORTB.6

LCDOUT $FE,1 ' Initialize both LCD's
PAUSE 200

GOSUB USE_LCD1
LCDOUT "This is LCD 1"

GOSUB USE_LCD2
LCDOUT "This is LCD 2"

GOSUB USE_BothLCD
LCDOUT $FE,$C0,"Both LCD's"

END

USE_LCD1:
INPUT LCD1_Disable
LOW LCD2_Disable
RETURN

USE_LCD2:
LOW LCD1_Disable
INPUT LCD2_Disable
RETURN

USE_BothLCD:
INPUT LCD1_Disable
INPUT LCD2_Disable
RETURNBest regards,
Darrel

bbarney
- 22nd February 2005, 03:16
how would you go about having two separate pic chips and use one lcd.of course the info could only be displayed from one pic at a time?

mister_e
- 22nd February 2005, 03:28
The easiest will be to use USART interrupt on the MASTER (on wich LCD is connected) to get serial data from a SLAVE and after display it.