I have a 4 line by 20 char LCD display setup at 9600 baud, RS232 TTL input. The following program works for ASCII characters but the commands that are in the LCD manual don't seem to work.
The manual says to home cursor (line 1, column 1) as follows:
This display used to work fine with PicAxe basic.
Syntax hexadecimal 0xFE 0x46
I have sent those cmnds everyway I could think of with various delays, but it just keeps writing
the asci characters with funny values between the readable text.
Any suggestions would be greatly appreciated, or tell me what displays you recommend, needs to be RS232 TTL since I don't want to give up pins for a parallel load type.
.
.
;;;A test program for 9600 baud LCD 4 line, 20 characters
;;;Asynchronous mode:
;;; Display is a Newhaven Display NHD-0420D3Z-NSW-BBW-V3
;
;]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
; LOGIC aNALYVER SETUP FOR UART CONFIG]
; 50m @50MhZ ]
; 9600 B/S ]
; INVERTED ]
; LSB FIRST ]
; ]
;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]
;
; ----- Configuration
#chip 18f14K22 , 8
#option explicit
#define USART_BAUD_RATE 9600
;Dir PORTc.6 Out
;Dir PORTc.7 In
dim xxcmd as byte
dim cursor_home as Byte
xxcmd = 0xFE ;LCD cmnd byte
cursor_home = 0x46 ;Send cursor to start after xxcmd byte
; to line 1, column 1
#define LCD_SPEED slow
wait 1500 ms
do Forever
wait 500 ms
HSerPrint "Pauls Test x14" ;this data prints, but eventualy over runs
wait 200 ms
HSerSend xxcmd,cursor_home ;cursor home cmd , can't get cursor home, it's really stubborn
wait 2000 ms
Loop
Last edit: Paul Haug 2017-03-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm guessing that the primary problem is attempting to send multiple bytes with < hsersend>.
Unfortunately, hsersend only supports sending one byte at at time. To send 2 bytes you will need to use two hsersend commands. Below I how I would approach the code using RS232- Serial.
Code is untested
; ----- Configuration
#chip 18f14K22 , 8
#option explicit
#define USART_BAUD_RATE 9600
#define USART_BLOCKING
#define USART_TX_BLOCKING
#define xxcmd 0xFE '254
'REM *** dim xxcmd as Byte
'REM *** dim cursor_home as Byte
'REM *** xcmd = 0xFE ;LCD cmnd byte
'REM *** cursor_home = 0x46 ;Send cursor to start after xxcmd byte
'REM *** #define LCD_SPEED slow (Only applies when using GCB
' LCD Library)
Wait 1500 ms '// Allow Display to initalize , etc
'Note: ** Hsersend does not support sending multiple
' ** bytes. Can Only send 1 byte at a time
' ** (See the sub routines for examples)
Do Forever
HSerPrint "Paul's Test x14"
wait 1 s : Clear_Screen
wait 1 s : Cursor_Home
Loop
'*** Create sub routines for repetetive tasks ***
'--------------------------------------------------------
Sub Cursor_Home
hsersend xxcmd
hsersend 0x46
wait 2 ms
End sub
Sub Clear_Screen
hsersend xxcmd
hsersend 0x51
Wait 2 ms
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your code above is now tested and works perfect. The command codes work now Perhaps post that as another example code as a sample for other beginners like me. Now I can start to develop some useful code now that I can use my display as a de-bugging tool.
My thanks also to Anobium also for helping this beginner trashing my way thru the new compiler (new to me).
.
Where do I find descriptions of these and similer codes, as to what they are ?.:
#define USART_BAUD_RATE 9600
#define USART_BLOCKING
#define USART_TX_BLOCKING
The Baud rate is obvious what it does, but the others ?
Last edit: Paul Haug 2017-03-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Command Set used by the Serial NewHaven LCD Display is proprietary so I doubt that more examples would be of much general benefit.
I think most folks probably use an inexpensive (Imported) LCD Display with an I2C Expander and then take advantage of the excellent LCD driver included with Great Cow Basic, Others use Standard 8-bit mode or 4-bit mode if conserving I/O pins is not an issue.
With these setups the driver "knows" if you are wanting to display a byte, a word, a Long, an integer, or a string and then magically displays it using a single PRINT command . There is no BinToASCII conversion necessary in the source code to display byte or word values. All of the cursor functions are available with LCDCURSOR and the backlight can be controlled with LCDBacklight.
Want to Display the value of a Word Variable on Line2 starting at column 10 ? Easy.
Locate 2,10 : Print WordVar
You can also display numbers in hex format with LCDHEX. All the hard work is done by the driver so that the user/programmer can focus on the actual application code instead of LCD stuff.
William
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks William, I do have some I2C displays coming, but I had this one from a previous system. Now that I have it working I will try to develop a general subroutine so a simple call takes care of all the proprietary stuff.
I will certainly use the I2C stuff when it comes in (China) since then use the GCB drivers..
. EDIT: I have created my own library (? .h) (Local in same directorty as my code)) so my debugging can insert a simple 'gosub' to read variables.
Again many thanks for getting ne started and explaining solutions to my problems.
Last edit: Paul Haug 2017-03-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a 4 line by 20 char LCD display setup at 9600 baud, RS232 TTL input. The following program works for ASCII characters but the commands that are in the LCD manual don't seem to work.
The manual says to home cursor (line 1, column 1) as follows:
This display used to work fine with PicAxe basic.
Syntax hexadecimal 0xFE 0x46
I have sent those cmnds everyway I could think of with various delays, but it just keeps writing
the asci characters with funny values between the readable text.
Any suggestions would be greatly appreciated, or tell me what displays you recommend, needs to be RS232 TTL since I don't want to give up pins for a parallel load type.
.
.
;;;A test program for 9600 baud LCD 4 line, 20 characters
;;;Asynchronous mode:
;;; Display is a Newhaven Display NHD-0420D3Z-NSW-BBW-V3
;
;]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
; LOGIC aNALYVER SETUP FOR UART CONFIG]
; 50m @50MhZ ]
; 9600 B/S ]
; INVERTED ]
; LSB FIRST ]
; ]
;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]
;
; ----- Configuration
#chip 18f14K22 , 8
#option explicit
Last edit: Paul Haug 2017-03-10
Looks like is missing.
I'm guessing that the primary problem is attempting to send multiple bytes with < hsersend>.
Unfortunately, hsersend only supports sending one byte at at time. To send 2 bytes you will need to use two hsersend commands. Below I how I would approach the code using RS232- Serial.
Code is untested
Your code above is now tested and works perfect. The command codes work now Perhaps post that as another example code as a sample for other beginners like me. Now I can start to develop some useful code now that I can use my display as a de-bugging tool.
My thanks also to Anobium also for helping this beginner trashing my way thru the new compiler (new to me).
.
Where do I find descriptions of these and similer codes, as to what they are ?.:
#define USART_BAUD_RATE 9600
#define USART_BLOCKING
#define USART_TX_BLOCKING
The Baud rate is obvious what it does, but the others ?
Last edit: Paul Haug 2017-03-11
You can find that stuff in the Help File.
HELP > Contents> Serial Communications > RS232 (Hardware) > RS232 Hardware Overview
The Command Set used by the Serial NewHaven LCD Display is proprietary so I doubt that more examples would be of much general benefit.
I think most folks probably use an inexpensive (Imported) LCD Display with an I2C Expander and then take advantage of the excellent LCD driver included with Great Cow Basic, Others use Standard 8-bit mode or 4-bit mode if conserving I/O pins is not an issue.
With these setups the driver "knows" if you are wanting to display a byte, a word, a Long, an integer, or a string and then magically displays it using a single PRINT command . There is no BinToASCII conversion necessary in the source code to display byte or word values. All of the cursor functions are available with LCDCURSOR and the backlight can be controlled with LCDBacklight.
Want to Display the value of a Word Variable on Line2 starting at column 10 ? Easy.
Locate 2,10 : Print WordVar
You can also display numbers in hex format with LCDHEX. All the hard work is done by the driver so that the user/programmer can focus on the actual application code instead of LCD stuff.
William
Thanks William, I do have some I2C displays coming, but I had this one from a previous system. Now that I have it working I will try to develop a general subroutine so a simple call takes care of all the proprietary stuff.
I will certainly use the I2C stuff when it comes in (China) since then use the GCB drivers..
.
EDIT: I have created my own library (? .h) (Local in same directorty as my code)) so my debugging can insert a simple 'gosub' to read variables.
Again many thanks for getting ne started and explaining solutions to my problems.
Last edit: Paul Haug 2017-03-12