I am trying to use a GU112x16G-7003 on my PIC18F4580. I am using the LCD commands, but the problem is that the screen has a serial interface. When using the LCD commands, I get jarbled screen, but when I try using the Ser commands, I get nothing. I am using the 2 bit commands, but maybe I am doing it wrong?
#chip 18F458, 8
#define LCD_IO 2
#define LCD_DB PORTC.5 'SIN pin on the LCD
#define LCD_CB PORTC.6 'SCK on the LCD
PRINT "ON"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A very simple example was recently posted in the "Serial Problem" post. Perhaps get your Pic to talk to hyperterminal first at the appropriate baud rate, then apply to your serial LCD with appropriate control/character codes. In your case something like XMIT_RS232 0x1B, XMIT_RS232 0x40 would initialize the display. So a hyperterminal example working at 9600 baud, on port pin D1, might look like:
#chip 18f458,8
Ser_Init
start:
XMIT_Print ("Hello")
For test = 1 to 10
Bin2ascii(test)
Next
goto start
sub Bin2ascii(LCDValue )#NR
SERCEN = 0
SERDEC = 0
SERUN = 0
LCDValueTemp = 0
If LCDValue >= 100 Then
LCDValueTemp = LCDValue / 100
SERCEN = LCDValueTemp + 48
Xmit_RS232 SERCEN
LCDValue = LCDValue - LCDValueTemp * 100
end if
IF LCDValueTemp > 0 OR LCDValue >= 10 then
LCDValueTemp = LCDValue / 10
SERDEC = LCDValueTemp + 48
Xmit_RS232 SERDEC
LCDValue = LCDValue - LCDValueTemp * 10
end if
SERUN = LCDValue + 48
Xmit_RS232 SERUN
end sub
Sub Ser_Init
#define baud 104 ;the us delay for 9600 baud rate
#define SerTxHigh Set PortD.1 On
#define SerTxLow Set PortD.1 Off
dir PortD.1 out
SerTxHigh ;Initial RS232 idle state
end sub
sub XMIT_PRINT (PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then exit sub
'Write Data
for SysPrintTemp = 1 to PrintLen
XMIT_RS232(PrintData(SysPrintTemp))
next
end sub
Sub XMIT_RS232(Xmit_Byte)#NR
SerTxLow ;Start bit
wait baud us
For cntr = 1 to 8
Rotate Xmit_Byte Right
If Status.C ON Then SerTxHigh
If Status.C Off Then SerTxLow
wait baud us
Next
SerTxHigh ;Stop bit
wait baud us
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The 0x1B and 0x40 would go before main I presume,don't have the full data sheet for your serial LCD. Hopefully they provide examples, or you can get one off the net.
There are no specific serial LCD commands in GCBasic, each type of serial LCD is going to have a different setup and command structure. A generic approach will have to be used with a software or hardware USART. Try the using GCBasic software RS232 setup and commands, InitSer, Relevant Constants, and SerSend. Using an external crystal will most likey give you the best results.
If no joy is found with the software RS232 commands then I can recommend the hardware USART library, as found in the contributors section.
And lastly, there is the XMIT commands, they are a port of Nigel Goodwins http://www.winpicprog.co.uk/ tutorial code. Sort of a quick, and non-generic software USART. If you Have a max232 and db9 connector, the above example should work on a terminal program of your choice. You may very well get the lcd working without trying the hyperterminal program, always a certain amount of guesswork going on to make that first connection.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am having no luck with the software serial, but some luck with the hardware serial. Does anyone know how to send hex commands through the serial or how I can use the serial LCD screen?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The SerSend command should work up to a certain baud rate, check help. No luck there? then have a look at the alternate RS232 routines in the contributors section.
Sounds like you can just go ahead and send ascii directly to your display without any fancy footwork? Not sure how the baud rate is set for display tho, guess you need yet another data sheet for that? Some idea's on how to send stuff to your display:
;set up constants that you use over and over
#define cmd1 0x0C
#define cmd2 0x1F
#define cmd3 0x24
#define vfdBaud xxxx?
...
...
etc.
Main:
;Passing straight hex values here
InitDisplay (0x1B, 0x40)
For Pixels = 1 to ??
;Insert constants and variables as required here
WriteDisplay (cmd1, cmd2, cmd3, 4, 5, 6, 7, 8)
Next
....
....
clrd
...
...
goto Main
sub clrd
XMIT_RS232 cmd0
end sub
sub InitDisplay (ser1,ser2)#NR
XMIT_RS232 ser1
XMIT_RS232 ser2
end sub
sub WriteDisplay (ser3, ser4, ser5, ser6, ser7, ser8, ser9, ser10)#NR
XMIT_RS232 ser3
XMIT_RS232 ser4
XMIT_RS232 ser5
...
...
...
end sub
There is probably a more elegant way to do this, but this would get the job done.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to use a GU112x16G-7003 on my PIC18F4580. I am using the LCD commands, but the problem is that the screen has a serial interface. When using the LCD commands, I get jarbled screen, but when I try using the Ser commands, I get nothing. I am using the 2 bit commands, but maybe I am doing it wrong?
#chip 18F458, 8
#define LCD_IO 2
#define LCD_DB PORTC.5 'SIN pin on the LCD
#define LCD_CB PORTC.6 'SCK on the LCD
PRINT "ON"
AHH After reading the GC DOCs, I found out that the LCD_IO 2 isn't for serial LCDs. Does anyone know how to use serial LCDs and have any sample code?
A very simple example was recently posted in the "Serial Problem" post. Perhaps get your Pic to talk to hyperterminal first at the appropriate baud rate, then apply to your serial LCD with appropriate control/character codes. In your case something like XMIT_RS232 0x1B, XMIT_RS232 0x40 would initialize the display. So a hyperterminal example working at 9600 baud, on port pin D1, might look like:
#chip 18f458,8
Ser_Init
start:
XMIT_Print ("Hello")
For test = 1 to 10
Bin2ascii(test)
Next
goto start
sub Bin2ascii(LCDValue )#NR
SERCEN = 0
SERDEC = 0
SERUN = 0
LCDValueTemp = 0
If LCDValue >= 100 Then
LCDValueTemp = LCDValue / 100
SERCEN = LCDValueTemp + 48
Xmit_RS232 SERCEN
LCDValue = LCDValue - LCDValueTemp * 100
end if
IF LCDValueTemp > 0 OR LCDValue >= 10 then
LCDValueTemp = LCDValue / 10
SERDEC = LCDValueTemp + 48
Xmit_RS232 SERDEC
LCDValue = LCDValue - LCDValueTemp * 10
end if
SERUN = LCDValue + 48
Xmit_RS232 SERUN
end sub
Sub Ser_Init
#define baud 104 ;the us delay for 9600 baud rate
#define SerTxHigh Set PortD.1 On
#define SerTxLow Set PortD.1 Off
dir PortD.1 out
SerTxHigh ;Initial RS232 idle state
end sub
sub XMIT_PRINT (PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then exit sub
'Write Data
for SysPrintTemp = 1 to PrintLen
XMIT_RS232(PrintData(SysPrintTemp))
next
end sub
Sub XMIT_RS232(Xmit_Byte)#NR
SerTxLow ;Start bit
wait baud us
For cntr = 1 to 8
Rotate Xmit_Byte Right
If Status.C ON Then SerTxHigh
If Status.C Off Then SerTxLow
wait baud us
Next
SerTxHigh ;Stop bit
wait baud us
end sub
Where would the 0x1B and the Ox40 go in the code? I don't see the XMIT commands in the HELP section, so it's confusing me.
The 0x1B and 0x40 would go before main I presume,don't have the full data sheet for your serial LCD. Hopefully they provide examples, or you can get one off the net.
There are no specific serial LCD commands in GCBasic, each type of serial LCD is going to have a different setup and command structure. A generic approach will have to be used with a software or hardware USART. Try the using GCBasic software RS232 setup and commands, InitSer, Relevant Constants, and SerSend. Using an external crystal will most likey give you the best results.
If no joy is found with the software RS232 commands then I can recommend the hardware USART library, as found in the contributors section.
And lastly, there is the XMIT commands, they are a port of Nigel Goodwins http://www.winpicprog.co.uk/ tutorial code. Sort of a quick, and non-generic software USART. If you Have a max232 and db9 connector, the above example should work on a terminal program of your choice. You may very well get the lcd working without trying the hyperterminal program, always a certain amount of guesswork going on to make that first connection.
Here is the spec sheet of the LCD if it's helpful: https://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/GU112X16G-7003.pdf
I am going to try the software serial wit the InitSer, etc. commands and see what that does.
I am having no luck with the software serial, but some luck with the hardware serial. Does anyone know how to send hex commands through the serial or how I can use the serial LCD screen?
The SerSend command should work up to a certain baud rate, check help. No luck there? then have a look at the alternate RS232 routines in the contributors section.
Sounds like you can just go ahead and send ascii directly to your display without any fancy footwork? Not sure how the baud rate is set for display tho, guess you need yet another data sheet for that? Some idea's on how to send stuff to your display:
;set up constants that you use over and over
#define cmd1 0x0C
#define cmd2 0x1F
#define cmd3 0x24
#define vfdBaud xxxx?
...
...
etc.
Main:
;Passing straight hex values here
InitDisplay (0x1B, 0x40)
For Pixels = 1 to ??
;Insert constants and variables as required here
WriteDisplay (cmd1, cmd2, cmd3, 4, 5, 6, 7, 8)
Next
....
....
clrd
...
...
goto Main
sub clrd
XMIT_RS232 cmd0
end sub
sub InitDisplay (ser1,ser2)#NR
XMIT_RS232 ser1
XMIT_RS232 ser2
end sub
sub WriteDisplay (ser3, ser4, ser5, ser6, ser7, ser8, ser9, ser10)#NR
XMIT_RS232 ser3
XMIT_RS232 ser4
XMIT_RS232 ser5
...
...
...
end sub
There is probably a more elegant way to do this, but this would get the job done.
OK, I got it working with the hardware library usart.h and a baud rate of 38400. I added a 40 MHz osc and now it all works.