CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

NetMedia 2X16 LCD
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

NetMedia 2X16 LCD
PostPosted: Wed Aug 18, 2004 2:15 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 2:48 pm     Reply with quote

It is a serial LCD, any suggestions or code please?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 3:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 3:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 3:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 4:07 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 4:25 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 4:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 5:06 pm     Reply with quote

Yes, it looks like you have properly translated the Basic Stamp 2 function to C.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 5:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 18, 2004 6:01 pm     Reply with quote

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








PostPosted: Thu Aug 19, 2004 6:22 am     Reply with quote

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








PostPosted: Thu Aug 19, 2004 6:30 am     Reply with quote

and My chip become so hot, I am afraid it burned. but I still have several spare one. I will keep trying.
Guest








PostPosted: Thu Aug 19, 2004 6:48 am     Reply with quote

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








PostPosted: Thu Aug 19, 2004 9:52 am     Reply with quote

I connected RS232 between 16f819 and LCD RX, just some strange character, mostly japanese character., Any suggestions?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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