View previous topic :: View next topic |
Author |
Message |
nutmegzzzz
Joined: 13 Aug 2007 Posts: 4
|
Matrix Orbital LCD - RS-232 control using 16F877A |
Posted: Fri Nov 05, 2010 8:15 am |
|
|
I am trying to get a matrix Orbital GLC24064 LCD to work using a PIC 16F877A. I have the 232 jumpers in place on the back of the LCD and I'm using the CCS Embedded Serial Busses Prototyping Board with the RS-232 IC. My program is:
Code: |
#include <16F877A.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay (clock=10000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv = PIN_C7, FORCE_SW, INVERT)
void main() {
while(TRUE)
{
printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
}
|
I have absolutly no response on the LCD and I was able to get the LCD to operate using the Matrix Orbital Graphics Display software.
If I insert the plug partially I get strange data repeatedly come out as; 'arrowfxtriangleffarrowfffffffarrowff' where arrow and triangle are actually arrows and triangles.
Thanks for any help that can be provided. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9172 Location: Greensville,Ontario
|
|
Posted: Fri Nov 05, 2010 9:05 am |
|
|
First...get rid of the 'invert' option in the use rs232 setup as you ARE using the MAX232 chip.
Second..you should put in a delay, say 1 second in main before writing to the display, to be sure it gets initialised properly BEFORE you try jamming characters down it's throat.... |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Nov 05, 2010 9:08 am |
|
|
If you have been playing with differents configurations options, do a Manual Override in order to restore
the module configuration in default settings.
If you set the Flow Control OFF, be aware that the module buffer will overflow without any warning,
because of this you can not do a continuous string transmition as shown in your code.
Re-check the Protocol Select Jumpers.
Code: |
#include <16F877A.h>
#device ICD=TRUE
#use delay (clock=10000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv = PIN_C7)
void main() {
int j;
delay_ms(500);
printf("%xX",0xFE); // Clear screen
printf("%xH",0xFE); // Home position
for(j='A'; j<='Z'; j++)
{printf("%c",j);}
while(1);
}
|
Regards |
|
![](templates/subSilver/images/spacer.gif) |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Fri Nov 05, 2010 8:55 pm |
|
|
Always include ERRORS in your #use rs232! _________________ Andrew |
|
![](templates/subSilver/images/spacer.gif) |
nutmegzzzz
Joined: 13 Aug 2007 Posts: 4
|
|
Posted: Mon Nov 08, 2010 8:20 am |
|
|
It works now thank you so much, however when I work with Humberto's code, I get;
feXfeHABCDEFGHIJKLMNOPQRSTUVWXYZ
and the code then fills the whole screen. I would like to clear the screen and sooner or later start choosing the coordinates that I want to write to rather then write the whole screen.
Again thanks so much! |
|
![](templates/subSilver/images/spacer.gif) |
nutmegzzzz
Joined: 13 Aug 2007 Posts: 4
|
|
Posted: Mon Nov 08, 2010 3:22 pm |
|
|
From my request at the Matrix Orbital forum, they suggested;
Quote: | You need to make sure that when you send the command 0xFE 0x58 (clear screen command) that you are sending only 2 bytes, and not a total of 4 bytes as you see in your display: 'fe58' which is 4 bytes.
Please check the printf format details of your compiler. |
Previously they gave the code;
Quote: | // clear screen
printf("%x",0xFE);
printf("%x",0x58);
// go to home position
printf("%x",0xFE);
printf("%x",0x48);
|
I've tried various formats and I understand that I want to send '11111110' and '01011000' but I do not know how to do this and get the screen to actually clear. Any suggestions? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19365
|
|
Posted: Mon Nov 08, 2010 3:41 pm |
|
|
Replace %x, with %c.
%x, sends the hex representation of the value given. %c, sends the 'raw' character.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
nutmegzzzz
Joined: 13 Aug 2007 Posts: 4
|
|
Posted: Mon Nov 08, 2010 4:27 pm |
|
|
That works perfectly, thank you for everyone's help, below is a simple code if anyone needs it in the future.
Code: | #include <16F877A.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay (clock=10000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv = PIN_C7)
void main()
{
int j;
int x;
x=0;
//clear screen
delay_ms (300);
printf("%c",254);
printf("%c",88 );
//place cursor
printf("%c",254);
printf("%c",71);
printf("%c",3); //place cursor at 3rd column over
printf("%c",5); //place cursor at 5th row down
for(j='A'; j<='Z'; j++)
{
printf("%c",j);
//delay_ms(10);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
|