|
|
View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
NetMedia 2X16 LCD |
Posted: Wed Aug 18, 2004 2:15 pm |
|
|
Anyone has used NetMedia 2X16 LCD using CCS. I currently have one , and I want to use it, but do not know how. It just use one wire communication RX. but I could not get it work. here is my program
Code: |
#if defined(__PCM__)
#include <16F819.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, parity=N, xmit=PIN_B7)
void main()
{
while(1)
{
printf("Single wire LCD!");
}
}
|
|
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Aug 18, 2004 2:48 pm |
|
|
It is a serial LCD, any suggestions or code please? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 18, 2004 3:00 pm |
|
|
Well how about using Google ?
If I go to Google, and search for NetMedia 2X16 LCD, I get the manual for the device:
http://www.basicx.com/Products/SLCD/ser2x16.pdf
I also get sample code for Basic Stamp 2, from Peter H. Anderson,
a well-known professor in the Pic community.
http://www.phanderson.com/basicx/lcd_2x16_bs2.html
By studying that code, I can see that before he uses the LCD,
he calls two routines:
LCDSetGeometry
and
LCDReset
When I look at those routines, I see that they use the Serout command.
I can see that it uses 9600 baud, so I know to set my #use rs232()
statement in CCS for 9600 baud also.
I can see that the LCDSetGeometry function has 6 data bytes that must
be sent: 15, 16, $80, $c0, $80, $80
So I could do this by using the CCS putc() command, because it sends
a single byte out the RS232 pin. Like this:
putc(15);
putc(16);
putc(0x80);
putc(0xc0);
putc(0x80);
putc(0x80);
For LCDReset function, I must send one byte (14), and then delay
for 1000 ms. So this would work:
putc(14);
delay_ms(1000);
There may be other details that are important. You can use Google
to find more documents on the LCD and study them. |
|
|
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Wed Aug 18, 2004 3:04 pm |
|
|
Hi,
Also, are you sure you've connected to the pin you specify in your code, and are you sure the connections to the LCD are correct? Do you have a scope to put on the data output pin from the PIC to see if any data is being sent??
John _________________ John Morley |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Aug 18, 2004 3:41 pm |
|
|
I saw the code in Basic, and am trying to undertstand it. If there is already one sample, it will be great.
I believe that I connected pins correctly.
I will try to find it out, anyway! |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Aug 18, 2004 4:07 pm |
|
|
what does
sewrout TXPin, N9600,10, [12]
number 10 means?
is it right if I define function as
Code: |
void LCDSetContrast(int8 contr)
{
putc(10);
putc(contr);
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 18, 2004 4:25 pm |
|
|
If you use Google, and type in SEROUT, then you get this as the
top link:
http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv16.pdf
It tells you the format of the Serout command:
Serout tpin, baudmode, {pace,} [output data]
It says the "pace" parameter is the number of milliseconds
between characters. So, if your example has "10", then
that's a 10 ms delay. You can do this with CCS like this:
putc(12);
delay_ms(10);
If you have several characters for "output data", then
put a delay_ms(10); statement after each putc() statement.
This will do the same thing as the Serout command. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Aug 18, 2004 4:38 pm |
|
|
Thank you very much
as of my code
Code: |
LCDSetContrast: 'value is passed in x
SerOut TxPin, N9600,10, [19,x]
return;
|
right if I convert it to c as
Code: |
void LCDSetContrast(int8 x)
{
putc(19);
delay_ms(10);
putc(x);
delay_ms(10);
}
is putc(x) correct?
Thank you
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 18, 2004 5:06 pm |
|
|
Yes, it looks like you have properly translated the Basic Stamp 2 function to C. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Aug 18, 2004 5:18 pm |
|
|
Thank you:
I put this together for a test, but I hust see "||||||||||" on my screen. what might happened?
Code: |
#if defined(__PCM__)
#include <16F819.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, parity=N, xmit=PIN_B7, rcv=PIN_B6) // Jumpers: 8 to 11, 7 to 12
//#include <lcd420_1.c>
//#include <math.h>
void LCDSetGeometry();
void LCDReset();
void LCDinit();
void LCDSetBackLight(int8 backlit);
void LCDSetContrast(int8 contr);
void LCDClrScr();
void LCDNewLine();
void LCDCR();
void LCDTab();
void LCDVerTab();
void LCDBackSpaces(int8 bspa);
void LCDSetTab(int8 Stab);
void LCDSetCursorPos(int8 x, int8 y);
void LCDClrLine(int8 x, int8 y);
void LCDSetCursorStyle();
void LCDOnOff(int8 onoff);
void main()
{
LCDinit();
LCDClrScr();
while(1)
{
puts("Serial LCD");
}
}
void LCDSetGeometry()
{
putc(15);
delay_ms(10);
putc(16);
delay_ms(10);
putc(0x80);
delay_ms(10);
putc(0xc0);
delay_ms(10);
putc(0x80);
delay_ms(10);
putc(0x80);
delay_ms(10);
}
void LCDReset()
{
putc(14);
delay_ms(1000);
}
void LCDinit()
{
// Set LCD Geometry
LCDSetGeometry();
// LCDReset
LCDReset();
}
void LCDClrScr()
{
putc(12);
delay_ms(10);
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 18, 2004 6:01 pm |
|
|
Quote: | I put this together for a test, but I hust see "||||||||||" on my screen. what might happened? |
Are you using a MAX232 type of RS232 level translator chip between
the Netmedia LCD and your PIC ?
I suspect that you are not.
On page 3 of the LCD manual,
http://www.basicx.com/Products/SLCD/ser2x16.pdf
it shows the LCD Rx pin is connected directly to the PC RS-232 connector.
To emulate this with a software USART in the PIC, you need to use
the INVERT option. You should add it to your #use rs232() statement,
as shown in bold, below:
#use rs232(baud=9600, parity=N, xmit=PIN_B7, rcv=PIN_B6, INVERT) |
|
|
Guest
|
|
Posted: Thu Aug 19, 2004 6:22 am |
|
|
Thank you PCM:
I just came back to work. I will work on it till I solve.
I put the "INVERT" there, but still not signal at all. |
|
|
Guest
|
|
Posted: Thu Aug 19, 2004 6:30 am |
|
|
and My chip become so hot, I am afraid it burned. but I still have several spare one. I will keep trying. |
|
|
Guest
|
|
Posted: Thu Aug 19, 2004 6:48 am |
|
|
When I remove Invert, the ||| bar comes back again, When I use INVERT it becomes hot. Do you think I should use RS232 to try, I will and let you know. |
|
|
Guest
|
|
Posted: Thu Aug 19, 2004 9:52 am |
|
|
I connected RS232 between 16f819 and LCD RX, just some strange character, mostly japanese character., Any suggestions? |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|