LCD Display

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
pcleats
Posts: 35
Joined: 12 December 2005, 11:57 AM

LCD Display

Post by pcleats »

Hello all,

I got a bunch of parts from a friend and in it was an 2 LCD displays. The numbers on the back MTC-C204DPLY-1N.

I found the spec sheet for the unit.

http://www.mpja.com/download/14194op.pdf

Has anybody used this display before?

Seems a bit complicated to get it setup.

Thanks

Patrick
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

I took a quick look at the documentation and it looks like a standard 4/8 bit parallel interface. Using the 8-bit interface is slightly simpler but it does require more lines. In either case, you can reduce the number of ZX I/O lines by employing a shift register or other techniques.

My Reflow Toaster Oven project contains a module named LCD4P.bas that implements the 4-bit parallel interface. The code does not use all of the features of the display but it may serve as a good starting point for you. The schematic contained in the .zip file attached to that post shows the straightforward way to connect the LCD.

If you have additional questions, let me know.
- Don Kinzer
JC
Posts: 56
Joined: 19 February 2006, 20:23 PM
Location: Hudson,OH
Contact:

Post by JC »

Don's suggestion is a good one.

Another alternative is to use a separate serial to parallel LCD Driver. Most 2 line text LCDs either use the HD44780 controller, or a compatible variant. It is, essentially, the de facto standard.
This only requires 1 port, (serial TTL output) to the driver chip, which then connects to the LCD. You then send print commands to the driver, which does the work for you. This saves ports on the ZX, and the trouble of doing the low level interfacing yourself.
Nuts & Volts Magazine, may/might/could possibly be running an article in the Sept issue on two serial to parallel LCD drivers. The article got bumped from the Aug issue.
The less expensive chip is about $6.95, and is a pic programmed in Basic. It has several extra ports available with "print" commands to turn on & off several LEDs, in addition to displaying data on the LCD.
Another, pre-programmed version of this same concept is also available from Kronos Robotics. A pre-programmed "Athena" chip LCD driver is available.

If you have the pins available, and want to tie the LCD directly to the ZX, then google HD44780 for a bunch of interface references.
I found these two helpful:

http://www.myke.com/lcd.htm

http://home.iae.nl/users/pouweha/lcd/lcd0.shtml

Good Luck

JC
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

I had not seen the Athena-based device.


One is $11, and the other is $20. It is not clear exactly what the difference is. Both are assembled and tested. I think the connectors are more complete on the more expensive one. It looks as if the back light is NOT controlled by the device, but it holds resistors for passive control.

I have successfully used the SparkFun serial backpack device ($15). It supports 2,4 lines and 16,20 characters, and is supposed to drive the backlight. The one I have is not on an LCD equipped with a back light, so I do not know how well it works. The last generation of its software apparently had a problem with the backlight. The new generation supposedly has this fixed up.

If you do get the SparkFun device, it can be bought built onto an LCD. But if you ever plan on moving it to a different LCD, buy them separately. The combo is soldered together and the controller ONLY supports the exact size of the display (in my case 4x16).

-Tony
pcleats
Posts: 35
Joined: 12 December 2005, 11:57 AM

4 line lcd display

Post by pcleats »

I got a LCD serial display backpack from Scott Edwards Electronics, and it seems to work. Now my only problem is addressing the last 2 lines.

The code I am using is: (Provided by Don K) thanks

Code: Select all

Call LCD_DisplayStrAt((fmt(OutCurrent,3)), 3, 13)'Display current row 2 Col 10 

The line above overwrites my current label on line 2 of the display, it should display on line 3

Public Sub LCD_DisplayStrAt(ByVal str as String, ByVal row as Byte, ByVal col as Byte) 
   Call LCD_SetPos(row, col) 
   Call LCD_DisplayStr(str) 
End Sub

Public Sub LCD_SetPos(ByVal row as Byte, ByVal col as Byte) 
   If &#40;&#40;row >= 1&#41; And &#40;row <= 4&#41; And _ 
		 &#40;col >= 1&#41; And &#40;col <= 20&#41;&#41; Then 
	  Call sendCmd&#40;IIF&#40;row = 1, 128, 192&#41; + col - 1&#41; 
   End If 
End Sub
If I make any mods to this my display gets all messed up. I know I am missing something simple.

http://www.seetron.com/pdf/bpk_mnl.pdf

Thanks yet again :D

Patrick
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

Now my only problem is addressing the last 2 lines
As originally written, the code only supported a two line display. Extending it for additional lines is fairly straightforward - just add the code to compute the starting address of the additional lines. Here's what I would suggest:

Code: Select all

' modify these values to match your display
Private Const LCD_ROWS as Byte = 4
Private Const LCD_COLS as Byte = 20
Private rowStart as ByteVectorData&#40;&#123; 128, 192, 148, 212 &#125;&#41;

'----------------------------------------------------------------------
'
'' DisplaySetPos
'
' Set the cursor position to the given row and column, both
' of which are 1-based.
'
Public Sub LCD_SetPos&#40;ByVal row as Byte, ByVal col as Byte&#41; 
   If &#40;&#40;row >= 1&#41; And &#40;row <= LCD_ROWS&#41; And _ 
       &#40;CInt&#40;LCD_ROWS&#41; = UBound&#40;rowStart&#41;&#41; And _ 
       &#40;col >= 1&#41; And &#40;col <= LCD_COLS&#41;&#41; Then 
     Call sendCmd&#40;rowStart&#40;row&#41; + col - 1&#41; 
   End If 
End Sub
The data array rowStart contains the addresses of the first character of each row. These values came from the Seetron documentation and can be modified for other displays as necessary.

Note that the added condition in LCD_SetPos() isn't strictly necessary and the compiler will optimize it away if the number of entries in the rowStart array matches the number of rows. Including it has the benefit of making the routine not work at all if the data values don't match.
Last edited by dkinzer on 15 August 2006, 9:56 AM, edited 1 time in total.
- Don Kinzer
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

It just occurred to me that the code could be made slightly more efficient by changing the rowStart values to represent zero-based addresses. This eliminates the need to subtract 1 from the column number.

Code: Select all

' modify these values to match your display 
Private Const LCD_ROWS as Byte = 4
Private Const LCD_COLS as Byte = 20
' zero-based addresses of the first column of each row
Private rowStart as ByteVectorData&#40;&#123; 127, 191, 147, 211 &#125;&#41;

'---------------------------------------------------------------------- 
' 
'' DisplaySetPos 
' 
' Set the cursor position to the given row and column, both 
' of which are 1-based. 
' 
Public Sub LCD_SetPos&#40;ByVal row as Byte, ByVal col as Byte&#41; 
   If &#40;&#40;row >= 1&#41; And &#40;row <= LCD_ROWS&#41; And _ 
       &#40;CInt&#40;LCD_ROWS&#41; = UBound&#40;rowStart&#41;&#41; And _ 
       &#40;col >= 1&#41; And &#40;col <= LCD_COLS&#41;&#41; Then 
     Call sendCmd&#40;rowStart&#40;row&#41; + col&#41; 
   End If 
End Sub
- Don Kinzer
Post Reply