Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:39 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : More than  one lcd on rpi (4x40 character)

Author Message
vincenthimpe
Newbie

Joined: 14/10/2018
Location: United States
Posts: 24
Posted: 05:44pm 09 Nov 2023
Copy link to clipboard 
Print this post

I want to use a 4x40 lcd display ( character type. these are essentiallt two hd44780 controllers with a chip select. one drives the top two lines, the other the bottom 2 lines.

is it possible to create two lcd displays and simply map to different pins ?
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 07:52pm 09 Nov 2023
Copy link to clipboard 
Print this post

Hello vincenthimpe....
You can search in the "thebackshed" search engine for what I was working on, maybe you can start there.

"Kermess" ..... "LCD 40X4 problem."

I don't know how to do it any other way, sorry.
Cheers!

David from Barcelona (spain)
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 07:59pm 09 Nov 2023
Copy link to clipboard 
Print this post

https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=7449#79439
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 09:03pm 09 Nov 2023
Copy link to clipboard 
Print this post

Thank you so much ....

David
 
vincenthimpe
Newbie

Joined: 14/10/2018
Location: United States
Posts: 24
Posted: 09:13pm 09 Nov 2023
Copy link to clipboard 
Print this post

great ! thanks. so it's just a matter of manually controlling the enable pin.
i searched for 4x40 but did not find that thread.

thanks.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 09:19pm 09 Nov 2023
Copy link to clipboard 
Print this post

You can use your browser for searching.

site:thebackshed.com "Kermess"AND"LCD 40X4 problem."
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1057
Posted: 05:44am 10 Nov 2023
Copy link to clipboard 
Print this post

Hi
Thanks @vincenthimpe for the post

I wish I had had seen @kermess' post back then but it was before my TBS time.  It may have saved me a bit of hassle when I was faced with the same problem. I saw the 40 x 4 LCD on RS many years ago & ordered one.

Robert R's idea of using the O/C outputs is a great idea & allows both sections of the display to be addressed together for some functions as noted e.g. Init & clr. It did not occur to me at the time to do this.

My solution at the time was to used some steering diodes c/w a transistor & resistors with one extra control pin from the 'mite, which combined with the normal EN pin, enabled each section to be addressed separated but, not both at once.

The EN pin enables the interface while the EN_SEL determines which section is selected (0 for top, lines 1 & 2 & 1 for bottom, lines 3 & 4)  

I also wrote some pseudo code routines to replace the normal LCD commands.

I may get around to changing to the other solution which is simpler but does use one more pin. I haven't actually used the setup for a while now.

Circuit & code (which may not be elegant, but works) are shown below for interest. I did draw up a later untried version just using a 4001 quad 2 input NOR IC  









' Some preamble
dim integer d4 = 5, d5 = 4, d6 = 3, d7 = 2, rs = 6, en = 7, en_sel = 9, en1 = 0, en2 = 1 'LCD variables
'LCD Setup 40x4 display treated as 2 x 20x2 displays. Subroutines used to emulate normal LCD Cmds.
'set cursor value below as:   12 = 0ff
'                             13 = blinking ON OFF #
'                             14 = solid "_"
'                             15 = blinking solid "_#"
cursor = 12         'set cursor OFF
lcd_init d4,d5,d6,d7,rs,en    'Pins 5,4,3,2,6,7  initialise the LCD
'* NOTE LCD INIT in LCD_CLOSE routine

%%%%%%%%%%%  LCD ROUTINES  %%%%%%%%%%%%%%%%%%
'  'The 40 chr x 4 line LCD has to be treated as 2 separate LCD's or sections.
'  'MMBasic requires a LCD Close before an initialzation.
'  'The first section is selected & then initalised "LCD INIT".
'  'The second selection is then selected then the CLOSE command sent which
'  'satisfies MMBasic.
'  'The LCD INIT is then sent to the second section
'
sub LCD_INIT (d4,d5,d6,d7,rs,en)  '4 data bits plus select & enable
pin(en_sel) = en1                 'first section - top 2 lines or rows
LCD init d4,d5,d6,d7,rs,en        'Initialise section section
lcd_cmd 1, cursor                 'set cursor mode top section
pin(en_sel) = en2                 'second section -3rd & 4th lines
lcd close                         'Terminate function in MMBasic
lcd init d4,d5,d6,d7,rs,en        'Initialise section section
lcd_cmd 3, cursor                 'set cursor mode bottom section
end SUB

' Each section cleared in turn
sub LCD_Clear()
pin(en_sel) = en1                 'Select first section
LCD CLEAR                         'clear it
pin(en_sel) = en2                 'Select second section
lcd clear                         'Clear it
lcd_cmd 1, 2                      'row 1, cursor to start
end SUB

'Close Display. Each section closed in turn
sub LCD_Close()
pin(en_sel) = en1                 'select first selection
LCD CLose                         'close top section
pin(en_sel) = en2                 'select second selection
lcd init d4,d5,d6,d7,rs,en        'Have to re-initialise before another close.
lcd close                         'close bottom section
'setpin en_sel, off               'release the select pin
End SUB

'writes data (words$) to selected line & position & sets cursor position if enabled
sub LCD_Write (row, position, words$)
if row > 4 then row = 4
if row =< 2  then               'check if row 1 or 2
lcd_cmd 3, cursor_off         'go turn cursor off bottom section
lcd_cmd 1, cursor             'set cursor mode top section
pin(en_sel) = en1             'yes. Enable this section
lcd row, position, words$     'write data to appropriate pos & row
else if row => 3 then
pin(en_sel) = en1
lcd_cmd 1, cursor_off         'turns cursor off bottom section
lcd_cmd 3, cursor             'set cursor mode
pin(en_sel) = en2             'select bottom section
row = row - 2                 'select appropriate row in bottom section. (1 or 2)
lcd row, position, words$
end if
end sub

sub LCD_CMD (row, action)
if row = 2 and action >= 128 then action = action + 40
if row = 4 and action >= 128 then action = action + 40
if row <= 2  then
pin(en_sel) = en1
lcd cmd action
pin(en_sel) = en2
else if row => 3 then
pin(en_sel) = en2
lcd cmd action
pin(en_sel) = en1
end if
end sub

sub LCD_DATA (row, action1)
if row <= 2  then
pin(en_sel) = en1
lcd cmd Cursor
lcd data action1
pin(en_sel) = en2
lcd cmd cursor
else if row => 3 then
pin(en_sel) = en2
lcd cmd cursor
lcd data action1
pin(en_sel) = en1
lcd cmd cursor
end if
end sub

ChopperP
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024