• C

LCD Scrolling Module Problem

Hey I am having problems with my LCD Module, i can get it to display text, but i require to get the LCD module to scroll the text, displaying a full sentence.

Now in theory i know you need a loop of some kind, but i am not sure what the loop contains.

Examples of Code would help alot, along with the explaination, so i could implement that tiny bit into my code.

Thanks for all the help

:-)
Deepanp

Code *************

#include <dos.h>
#include <string.h>

#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2
#define outportb
#define inportb
#define delay
void main(void)
{
 char string[] = {"I'm Being Displayed!!"};
 char init[10];
 int count;
 int len;
 init[0] = 0x0F; /* Init Display */
 init[1] = 0x01; /* Clear Display */
 init[2] = 0x38; /* Dual Line / 8 Bits */

 outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make sure Forward Direction */

 outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */

 for (count = 0; count <= 2; count++)
  {
   outportb(DATA, init[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
  }

 outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer (Register Select) */

 len = strlen(string);

 for (count = 0; count < len; count++)
  {
   outportb(DATA, string[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(2);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(2);
  }
}

Code ***************
deepanpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deepu chandranCommented:
hi friend,

#define outportb
#define inportb
#define delay

these three are functions in dos.h so avoid declare this as macros
0
deepanpAuthor Commented:
Sorri, i ain't too clever, how would i exactly declare them as macros, and can you help with the loop by any chance?
:-)
0
PaulCaswellCommented:
So what does it (or doesnt it) do?

The logic looks right but the outport stuff is hardware specific so there's not a lot we can check there. Is there a manual on the net? If so, post a URL to it and we'll take a look.

Paul
0
The IT Degree for Career Advancement

Earn your B.S. in Network Operations and Security and become a network and IT security expert. This WGU degree program curriculum was designed with tech-savvy, self-motivated students in mind – allowing you to use your technical expertise, to address real-world business problems.

grg99Commented:
Not too hard.

If your display is D characters wide:

First put out the first D chararacters of the string.
Then wait a second or so.
Then reset the display.
Then send out D characters, but starting at position "1" in the string.
repeat until you've displayed the whole string.  Take care to not write past the end of the string.

So you need a loop around all your code, indexing from 0 to strtlen(text)-D, and useing that index as a starting index into the string.


0
deepanpAuthor Commented:
Is there any examples of code that is possible please, since i am not too good At C, its bin years since i have touched the topic.

Many Thanks for the reply..

PaulCaswell

There are some examples on the net but they dnt help too much, and the funny thing is, thats its just a silly little loop kind of thing that needs to be done.
0
PaulCaswellCommented:
OK! Without much information we'll just have to do some guessing!

I'm assuming that this loop:

len = strlen(string);

 for (count = 0; count < len; count++)
  {
   outportb(DATA, string[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(2);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(2);
  }

correctly puts the string up to the LCD.

I expect you need to repeat this process starting at one character further in each time so you'll need something like:

len = strlen(string);

for ( offset = 0; offset < len; offset++ )
{
 // Reset the character position on the display so we start at the beginning. No need to blank the display.
 ...
 // Display the string starting at offset.
 for (count = offset; count < len; count++)
  {
   outportb(DATA, string[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(2);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(2);
  }
 // Pad with spaces to the right.
 for (count = 0; count < offset; count++)
  {
   outportb(DATA, ' ');
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(2);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(2);
  }
 // Probably have to delay a bit here.
...
}

See what happens with that. Fill in the '...' bits yourself.

Paul
0
deepanpAuthor Commented:
Hey PaulCaswell, i am sorry for the late reply, i have been busy debugging this problem of mine, all we need to do is just to shift the characters one by one so that it can display say numbers from 1-29... we can get numbers only 1 - 12 to display and then it cuts the rest of the string off, obviously due the the scrolling option not there. Can you please help me. Sorry for not explaining well enough, i hope this helps :-)
0
deepanpAuthor Commented:
Is there a function that will shift characters one by one
0
PaulCaswellCommented:
>> Is there a function that will shift characters one by one
Unlikely! You'll have to look at the hardware spec for the LCD display.

Honestly, the moethod I described is the way customer displays on cash tills in stores have their scrolling messages displayed. You look next time you go shopping!

Paul
0
deepanpAuthor Commented:
yeh, thanks, i had a go with the code and it didn't work for me, is there anyway you can please just get the code to work?

Plzz!!
0
PaulCaswellCommented:
What happened? What went wrong? Did anything work correctly? Post the code you tried!

Try putting a '   delay(10)' between each operation so you can clearly see what is happening.

Pail
0
deepanpAuthor Commented:
Gimme a sec, just restarted pc, was having problems with the LCD Module
0
deepanpAuthor Commented:
Here is the Code, that i have been trying...

/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>

#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2
void main(void)
{
 char string[] = {"1234567891011121314151617181920212223242526272829"};
 char init [30];
 int count;
 int len;
 init [0] = 0x0F; /* Init Display */
 init [1] = 0x01; /* Clear Display */
 init [2] = 0x38; /* Dual Line / 8 Bits */

 outportb(CONTROL, inportb(CONTROL) & 0xDF);     /* Reset Control Port - Make sure Forward Direction */

 outportb(CONTROL, inportb(CONTROL) | 0x08);     /* Set Select Printer (Register Select) */

len = strlen(string);

for ( offset = 0; offset < len; offset++ )
{
 /* Reset the character position on the display so we start at the beginning. No need to blank the display.*/

outportb (CONTROL, inportb (CONTROL) & 0x80); /*Should set cursor to beginning of text!!*/


/*Display the string starting at offset.*/

 for (count = offset; count < len; count++)

{
   outportb(DATA, string[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(30);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(30);
}
 /*Pad with spaces to the right.*/
 for (count = 0; count < offset; count++)

{
   outportb(DATA, ' ');
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(5000);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(5000);
}
   delay (2000);
}
}
}
0
deepanpAuthor Commented:
Just gnna test it again, to give a sentence to why it doesn't work
0
deepanpAuthor Commented:
Expression syntax in functon main ====   for (offset = 0 ; offset < len ; offset++)
Expression syntax in function main ====
Expression syntac in function main ====


declaration syntax error ==== }   -- this is the end parathensises of the code
0
PaulCaswellCommented:
Hi deepanp,

Add

int offset;

after

int count;

Paul
0
deepanpAuthor Commented:
Hey Paul,

/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)
{
 char string[] = {"1234567891011121314151617181920212223242526272829"};
 char init [30];
 int count;
 int offset;
 int len;
 init [0] = 0x0F; /* Init Display */
 init [1] = 0x01; /* Clear Display */
 init [2] = 0x38; /* Dual Line / 8 Bits */

 outportb(CONTROL, inportb(CONTROL) & 0xDF);     /* Reset Control Port - Make sure Forward Direction */

 outportb(CONTROL, inportb(CONTROL) | 0x08);     /* Set Select Printer (Register Select) */

len = strlen (string);

for ( offset = 0; offset < len; offset++ )
{
 /* Reset the character position on the display so we start at the beginning. No need to blank the display.*/

outportb (CONTROL, inportb (CONTROL) & 0x80); /*Should set cursor to beginning of text!!*/


/*Display the string starting at offset.*/

 for (count = offset; count < len; count++)

{
   outportb (DATA, string [count]);
   outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
   delay (30);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay (30);
}
 /*Pad with spaces to the right.*/
 for (count = 0; count < offset; count++)

{
   outportb (DATA, ' ');
   outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
   delay (5000);
   outportb (CONTROL, inportb (CONTROL) & 0xFE); /* Reset Strobe */
   delay (5000);
}
   delay (2000);
}
}


Sorri, i just noticed the obvious mistakes due to forgetting to save the version we were on, and i have realised that in this code, the screen is't initialised. and i believe that it needs to be done in order for the text to be sent..

Thanks :-)

Deepan
0
PaulCaswellCommented:
Hi deepanp,

Does it work now?

Paul
0
deepanpAuthor Commented:
Nah it doesn't sorri, forgot to write that, it doesn't display anything on the Module
0
deepanpAuthor Commented:
Hey, Paul,

just let you know, we have a software that verifies that the Module does in fact work, program used is LCD Smartie...:-)....
This is a executable program, which will not allow us to see how they got theirs to work :(...
0
PaulCaswellCommented:
Hi deepanp,

Did your original loop work? If so, go through the whole init process each time around the offset loop:

for ( offset = 0; offset < len; offset++ )
{
 // Full reset and clear!
 for (count = 0; count <= 2; count++)
  {
   outportb(DATA, init[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
  }

 outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer (Register Select) */

/*Display the string starting at offset.*/

 for (count = offset; count < len; count++)

{
   outportb(DATA, string[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(30);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(30);
}
...

Paul
0
deepanpAuthor Commented:
well it printed the string to the size of the screen and, but it didn't actually scroll.. i am not exactly sure what you mean by around the offset loop?
0
PaulCaswellCommented:
Hi deepanp,

Essentially, you need to redisplay the string starting one more character in each time around the outer loop. The 'offset' value is the offset into the string to start at and it's stepping one forward each time so you skip one more character off the start of the string each time around the offset loop.

Since the original code worked, the whole process should work but if you do a full reset each time around, the display will flash irritatingly because you are doing a complete reset and clear of the LCD each time around. Once it works, you should be able to get rid of the flash by adjusting the 3-byte init data so it doesnt clear the display, just reset to the start position.

Paul
0
deepanpAuthor Commented:
/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)
{
 char string[] = {"1iewjnfiowejfoiwejfoiwjefoijweoifjwoeijfopi234567891011121314151617181920212223242526272829"};
 char init [50];
 int count;
 int offset;
 int len;
 init [0] = 0x0F; /* Init Display */
 init [1] = 0x01; /* Clear Display */
 init [2] = 0x38; /* Dual Line / 8 Bits */

 outportb(CONTROL, inportb(CONTROL) & 0x0F);     /* Reset Control Port - Make sure Forward Direction */

 outportb(CONTROL, inportb(CONTROL) | 0x08);     /* Set Select Printer (Register Select) */

len = strlen (string);

for ( offset = 0; offset < len; offset++ )
{
 /* Reset the character position on the display so we start at the beginning. No need to blank the display.*/

 for (count = 0 ; count <= 2 ; count++)
 {
  outportb (DATA, init [count]);
  outportb (CONTROL, inportb (CONTROL) | 0x01);
  delay (20);
  outportb (CONTROL, inportb (CONTROL) & 0xFE);
  delay(20);
 }



outportb (CONTROL, inportb (CONTROL) & 0x80); /*Should set cursor to beginning of text!!*/


/*Display the string starting at offset.*/

 for (count = offset; count < len; count++)

{
   outportb (DATA, string [count]);
   outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
   delay (30);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay (30);
}
 /*Pad with spaces to the right.*/
 for (count = 0; count < offset; count++)

{
   outportb (DATA, ' ');
   outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
   delay (5000);
   outportb (CONTROL, inportb (CONTROL) & 0xFE); /* Reset Strobe */
   delay (5000);
}
   delay (2000);
}
}


=====

yeh i see what you mean, is this the kind of loop that you are referring to:S?
0
PaulCaswellCommented:
Hi deepanp,

Yes! But you probably dont need:

outportb (CONTROL, inportb (CONTROL) & 0x80); /*Should set cursor to beginning of text!!*/

because the init loop above it will do a full reset and do this for you.

Just get it to display first, then play with it to not flash.

Paul
0
deepanpAuthor Commented:
okay, let me try doing this without the line, thanks alot paul, you dnt understand how long we have been on this, we are beginners with C as well!
0
PaulCaswellCommented:
Hi deepanp,

No problems! Just post when you have something.

Paul
0
deepanpAuthor Commented:
Hey  Paul,

The probelm still exists :S, what i will try and do, is get the old working version, and integrate into the one were working on to see what happens then :-)


Heres the Code that i tried, wth the LCD still being blank.


=======


/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)

{

 char string[] = {"1234567891011121314151617181920212223242526272829"};
 char init [50];
 int count;
 int offset;
 int len;
 init [0] = 0x0F; /* Init Display */
 init [1] = 0x01; /* Clear Display */
 init [2] = 0x38; /* Dual Line / 8 Bits */

 outportb (CONTROL, inportb(CONTROL) & 0x0F);     /* Reset Control Port - Make sure Forward Direction */
 outportb (CONTROL, inportb(CONTROL) | 0x08);     /* Set Select Printer (Register Select) */

len = strlen (string);

for (offset = 0; offset < len; offset++)

{


 for (count = 0 ; count <= 2 ; count++)

{
      outportb (DATA, init [count]);
      outportb (CONTROL, inportb (CONTROL) | 0x01);
      delay (20);
      outportb (CONTROL, inportb (CONTROL) & 0xFE);
      delay (20);
}

/*Display the string starting at offset.*/

      for (count = offset; count < len; count++)

{
      outportb (DATA, string [count]);
      outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
      delay (30);
      outportb (CONTROL, inportb (CONTROL) & 0xFE); /* Reset Strobe */
      delay (30);
}

 /*Pad with spaces to the right.*/

 for (count = 0; count < offset; count++)

{
      outportb (DATA, ' ');
      outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
      delay (500);
      outportb (CONTROL, inportb (CONTROL) & 0xFE); /* Reset Strobe */
      delay (500);
}
      delay (200);
}
}


0
PaulCaswellCommented:
That sounds like a good plan! Let me know how it goes.

Paul
0
deepanpAuthor Commented:
:-), gnna try it nw, will ask if i need assistance

Thanks Alot!
0
deepanpAuthor Commented:
just to keep you informed, we had a problem with the lcd, lcd smartie wasn't working :S, but its cse it was some tiny piece of metal contacting pins, were trying the code again nw :)
0
PaulCaswellCommented:
Hope it didnt short and do some permanent damage!
0
deepanpAuthor Commented:
yeh were hoping that too, we tested the program, and we had a load of 3's and " ' s coming up, and you could see the blinkler like scanning the letters, i.e i think its the scrolling, :)
0
PaulCaswellCommented:
Hi deepanp,

If it's going too fast the display wont be able to keep up. Try slowing it down with delay calls of about 1/2 second. You can always tune it later to get it smooth.

Paul
0
deepanpAuthor Commented:
do you think there could be something with the loop, because now its not displaying anything, the delays are set to 500, which i think would be half a second... the display looks like it is tryig t display something though as you can see thing lines flashing...hmmm?
0
deepanpAuthor Commented:
This is the code that we are wrking on, just in case if theres something we missed that you can notice :)

=======

/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)

{

 char string[] = {"1234567891011121314151617181920212223242526272829"};
 char init [50];
 int count;
 int offset;
 int len;
 init [0] = 0x0F; /* Init Display */
 init [1] = 0x01; /* Clear Display */
 init [2] = 0x38; /* Dual Line / 8 Bits */

 outportb (CONTROL, inportb(CONTROL) & 0x0F);     /* Reset Control Port - Make sure Forward Direction */
 outportb (CONTROL, inportb(CONTROL) | 0x08);     /* Set Select Printer (Register Select) */

len = strlen (string);

for (offset = 0; offset < len; offset++)

{


 for (count = 0 ; count <= 2 ; count++)

{
      outportb (DATA, init [count]);
      outportb (CONTROL, inportb (CONTROL) | 0x01);
      delay (500);
      outportb (CONTROL, inportb (CONTROL) & 0xFE);
      delay (500);
}

/*Display the string starting at offset.*/

      for (count = offset; count < len; count++)
{
      outportb (DATA, string [count]);
      outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
      delay (300);
      outportb (CONTROL, inportb (CONTROL) & 0xFE); /* Reset Strobe */
      delay (300);
}

 /*Pad with spaces to the right.*/

 for (count = 0; count < offset; count++)

{
      outportb (DATA, ' ');
      outportb (CONTROL, inportb (CONTROL) | 0x01); /* Set Strobe */
      delay (500);
      outportb (CONTROL, inportb (CONTROL) & 0xFE); /* Reset Strobe */
      delay (500);
}
      delay (500);
}
}
0
deepanpAuthor Commented:
Hey Paul, can you help us, we aren't sure with the delay time, is the delay time in seconds or milliseconds... if you could just give us the time for each loop, cse we are pretty sure it is displayin something, but the screen is going too fast...
0
PaulCaswellCommented:
I would guess it would be milliseconds. Port control is unlikely to need a one-second delay for settling.

I'd suggest you go back to:

   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(2);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(2);
 
like you had originally as these delays are merely to allow the chips to keep up with the code.

With the other delay (the very last one) you probably just need to use somethng like 5000 to begin with and tighten it up as you like when its all working.

}
     delay (5000);
}

Paul
0
deepanpAuthor Commented:
ok, we'll try that our lcd smartie is working... i will try the delay now, get bk to u in a minute, thanks again paul, were just strted to get funstrated, since we hve spent the third day on building the circuit and etc..

full points will be awarded to u :-)
0
PaulCaswellCommented:
Hi deepanp,

I have to go to sleep now. I hope you have enough info now to get it all working. Good night! I'll be back tomorrow (its midnight here right now).

Paul
0
deepanpAuthor Commented:
so far we have had no luck, :(... could u think it is the loops:S
0
deepanpAuthor Commented:
the kind of visual we are getting is some lines flikkering:S
0
deepanpAuthor Commented:
oh i saw, yeh its midnight here as well, lol... tell me about it, we haven't slept for some time, if you can give us a hand tomorrow with it paul, i will definately give u some big points:)
0
deepanpAuthor Commented:
Hey Paul, its 3 o clock right now!!

Just to inform you if you can please still assist me in getting this program done, i will award double points to what it is now, if that is possible, which i think is...hmmm, anyway, what we did was try to do the code so that it prints out information, atleast some string, and it did that, then we tried to implement the code that you gave us, and the result was still the same that the lines was flikkering and so on... we played around with the delay time, and it would still not work, so we come up with the theory of maybe one of the loops just keeps looping itself, causing the flashing (we think writing) view.

We tried to change the loop around, and had no luck, we will try again tomorrow, i just thought if you would could please help us out and find out why it doesn't work, cse in theory, it should realli...

Will keep monitoring for replies.. :-)

Many GREAT Thanks
Deepanp
0
PaulCaswellCommented:
Good morning! Wow! You really need to take a break and get some sleep!

If this process doesnt work right try to find out the manufacturer of the smartie and we can look up some specs for it.

Here's a link to just one. Its probably not the one you have but thats the sort of info we are looking for. The 'Clear Display' function is the same but that's probably a coincidence.

http://www.doc.ic.ac.uk/~ih/doc/lcd/instruct.html

One possibility would be to put another delay between the initialise loop and the write loop but we'll crack it somehow.

Paul

FYI: You arent allowed to award more than 500 points for a question but dont worry! I dont care much about points anyway, I like just helping.

0
deepanpAuthor Commented:
Hey Paul, yeh i know!, i just woke up and i'm still feeling sleepy.

Lets hope today is a better day :).

The model number on the Module is DEM16217 SYH-LY/V 142

I can do even better since this module was brought from Maplins store, i will be able to get the data sheet for it...

http://www.maplin.co.uk/Media/PDFs/N27AZ.pdf

this is data sheet for the lcd module..
0
PaulCaswellCommented:
That should help! I'm having a look at it now.

Where did you get your original code?

Paul
0
deepanpAuthor Commented:
It was from the net, findin which web site it was again, one sec...
0
deepanpAuthor Commented:
0
deepanpAuthor Commented:
The problem that i have is i'm not sure how to use the functions, as i.e. I/D, i dnt know what that would mean
0
PaulCaswellCommented:
Its not very good english is it?

This one looks better! Slightly different model but it may be useful.

http://www.sos.sk/a_info/resource/d/dem/dem16217syh-ly.pdf

Paul
0
deepanpAuthor Commented:
How have you got on, do u know how to work it?
0
PaulCaswellCommented:
I'm doing other things right now. I'll try to get back to it later. I'd suggest you try to understand from the documentation meanwhile.

Sorry!

Paul
0
deepanpAuthor Commented:
thanks, i'll have a read :-), just thinking of trying a differen't method quickly, see what happens, keep you posted
0
deepanpAuthor Commented:
Hey Paul, this is really stressful, i still ain't gt it to work, i have the text showing this time, and the text is scrolling, but i have dne it like reseting the strobe and then setting it, etc... but the string prints itself, and for some reason, the string repeats again half way through the other string.

Can you help out please!
:-)
0
PaulCaswellCommented:
Post the code you've got. I've nearly finished! I should be able to take a look in a little while.

Try to show me exactly what happens to the display, e.g. explain what you mean by: 'the string repeats again half way through the other string'.

Paul
0
deepanpAuthor Commented:
Thanks!
0
deepanpAuthor Commented:
/*  LCD Module Software                                               */
/*  17th May 1997                                                */
/*  Copyright 1997 Craig Peacock                                      */
/*  WWW     - http://www.senet.com.au/~cpeacock                       */
/*  Email   - cpeacock@senet.com.au                                   */
/*                                                                    */
/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)

{
 char string[] = {"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152"};
 char init[10];
 int count;
 int len;
 int b;
 init[0] = 0x0F; /* Init Display */
 init[1] = 0x01; /* Clear Display */
 init[2] = 0x38; /* Dual Line / 8 Bits */

 outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make sure Forward Direction */
 outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */

 for (count = 0; count <= 2; count++)

{
   outportb(DATA, init[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
}

 outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer (Register Select) */

 len = strlen(string);
 for (count = 0; count < len; count++)

{
  int a;
  a = 0;
  b = strlen(string);
  while (a <= b)
{
   outportb(DATA, string [a]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(5000);
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
   delay(5000);
   a++
   delay(10000);
   outportb(CONTROL,inportb(CONTROL) | 0x01);
   b--;
}
      delay(5000);
}
}
0
deepanpAuthor Commented:
Right!! now for the long explaination.


 -- When executed, the LCD shows:

                         >1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16, then it carries on the count, from cutting the beginning lot, so
                         >17 18 19 20 21, Then half way through this count, it will start again so,
                         >22 23 1 2 3 4 5 6 7 8 9 10, then it basically shows like two versions on the lcd counting, i.e.
                         >1 2 3 4 5 6 8 9 10 11 12 13 7 8 9 10 11 12 13 14

Hope this helps you see what is going on...

And again its gotta do with the loop, it recalls the loop for some reason, which is not what i am sure..

Someone gave me the idea of minusing the text that has already been written, but i am not sure which variable to minus, i tried the len, but that then only prints like half of the string:S
0
PaulCaswellCommented:
I wonder if its because we have only 16 characters to work with? I should have thought of that!

There's also some other strange things in your code too. This should improve matters but I dont think its the answer:

void main(void)

{
      char string[] = {"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152"};
      char init[10];
      int count;
      int len;
      init[0] = 0x0F; /* Init Display */
      init[1] = 0x01; /* Clear Display */
      init[2] = 0x38; /* Dual Line / 8 Bits */

      outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make sure Forward Direction */
      outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */

      for (count = 0; count <= 2; count++)

      {
            outportb(DATA, init[count]);
            outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
            delay(20);                                 /* Larger Delay for INIT */
            outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
            delay(20);                                 /* Larger Delay for INIT */
      }

      outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer (Register Select) */

      len = strlen(string);
      for (count = 0; count < len; count++)

      {
            int a;
            //** I think we need to start back at position 1 here again. Check!

            for ( a = 0; string[count+a] != '\0' && a < 16; a++ )
            {
                  // Not sure what each of these do but if your previous code worked, this should.
                  outportb(DATA, string [count+a]);
                  outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
                  delay(5000);
                  outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
                  delay(5000);
                  outportb(CONTROL,inportb(CONTROL) | 0x01);
            }
            delay(5000);
      }
}


0
deepanpAuthor Commented:
i have been working on a differen't method that actually shifts now, but again, it skips some characters:S..

I'll paste the code in a minute, gnna test your code :-)
0
PaulCaswellCommented:
>>gnna test your code
Dont bother! All I've done is limit the printing to 16 characters! Just see how I've done it. You should do that in yours if yours works better.

Paul
0
deepanpAuthor Commented:
Right, i have done it a totally different method, check this out for me please..

#include <stdlib.h>
#include <dos.h>
#include <string.h>


#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)
{

char string1[] = {" hello world its a good day "};
char string2[] = {"        "};
char init[16];
int count;
int len;
int dee;
int i=0;
init[0] = 0x0F; /* Init Display */
init[1] = 0x01; /* Clear Display */
init[2] = 0x38; /* Dual Line / 8 Bits */

outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make
sure Forward Direction */

outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register
Select) */

for (count = 0; count <= 2; count++)
  {
   outportb(DATA, init[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
   delay(10);                                 /* Larger Delay for INIT */
   outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
   delay(10);                                 /* Larger Delay for INIT */
  }

outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer
(Register Select) */

len = strlen(string1);
if(len > 16)
{
dee = len-16;
}else
{
dee = 0;
}
while (i<=dee)
  {
  for(count = i; count <=len-0; count++)
  {
   /*outportb(CONTROL,inportb(CONTROL) & 0xFE);Reset Srobe*/
   outportb(DATA, string1[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(20);
   outportb(CONTROL,inportb(CONTROL) & 0xFE);/*  Reset Strobe */

  delay(20);
  }
  delay(9000);
  i++;
  outportb(CONTROL,inportb(CONTROL)& 0xFE);/*Reset Strobe*/
  }
  outportb(CONTROL, inportb(CONTROL) & 0xF7);

  len = strlen(string2);

  for (count = 0; count <=len; count++)
  {
         outportb(DATA, string2[count]);
         outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
         delay(20);
         outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
         delay(20);
  }

}

0
PaulCaswellCommented:
Does it work? If not, what goes wrong?

Paul
0
deepanpAuthor Commented:
Nah, this is the same problem, with this one, it prints


                 >hello world its
                 >y !/*this is a funny character, bt looks like !*/ world its
                 >orld its a good
                 >ay /*funny character again*/ its a goo

Dunno why this is happenin
0
PaulCaswellCommented:
This doesnt look right:

            for(count = i; count <=len-0; count++)

len-0 ?

Paul
0
deepanpAuthor Commented:
yeh i removed it, and it stil prints da sme
0
deepanpAuthor Commented:
what about the strobe and that, do u think it could be that...

heres a link i bin looking for functions as well....     http://www.shellyinc.com/techsupIOR.htm
0
deepanpAuthor Commented:
Hey Paul, i think i have kinda given up, and just show what i have.
But can i ask one last Huge favour, which is the easiest for you, and hard for me since i know more about java compared to C..

>>>>What i need is the string to be read from a text file instead of the string stored..

Hope that makes sense, the text file is OutFile.txt.

It is written in the file like this:

hello world - this is a test

:-)

Thanks SOO MUCH FOR ALL THE HELP you have given to me, if it weren't for you, i probably would be in the same place as i was before, but i can say, that atleast we have something showing, lol..

Thanks again!!

:-)
0
deepanpAuthor Commented:
just to clarify if you didn't understand me, it should be read from a text file, and stored in like char string is, if that makes it better, or which ever way you think is best, but it the string should be read from the text file in order to print to the lcd module
0
PaulCaswellCommented:
                >hello world its
Brilliant! So first time around the while loop its working! You have to look to what happens next!

Start with something like this now, since you know that the first string displays correctly.

Remember that I dont know what the delays should be, nor do I know what should be sent to the ports but your last post suggested that this should work:

/*  LCD Module Software                                               */
/*  17th May 1997                                             */
/*  Copyright 1997 Craig Peacock                                      */
/*  WWW     - http://www.senet.com.au/~cpeacock                       */
/*  Email   - cpeacock@senet.com.au                                   */
/*                                                                    */
/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

#include <stdlib.h>
#include <dos.h>
#include <string.h>


#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

// Function that shows string.
void ShowString ( char * string, int start );
// Show one character.
void ShowChar ( char ch );

void main(void)
{

      char * string = "Hello world its a good day!";
      int length = strlen(string);
      char init[16];
      int offset;
      init[0] = 0x0F; /* Init Display */
      init[1] = 0x01; /* Clear Display */
      init[2] = 0x38; /* Dual Line / 8 Bits */

      outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make
                                                                        sure Forward Direction */

      outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register
                                                                        Select) */

      for (offset = 0; offset ; offset++)
      {
            outportb(DATA, init[offset]);
            outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
            delay(10);                                 /* Larger Delay for INIT */
            outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
            delay(10);                                 /* Larger Delay for INIT */
      }

      outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer
                                                                         (Register Select) */

      // Show the string at least once. Start at 0 first time around.
      ShowString( string, 0 );
      // Scroll it.
      for ( offset = 1; offset < length - 16; offset++ )
      {
            // Pause a little between each scroll.
            delay(9000);
            // Show the string starting at this offset.
            ShowString ( string, offset );
      }
}

// Show the first 16 characters of string starting at 'start'.
void ShowString ( char * string, int start )
{
      int i;
      // Stop at 16 or string end, whichever comes first.
      for(i = 0; i < 16 && string[i] != '\0'; i++)
      {
            ShowChar ( string[i] );
      }
      // Fill the rest with spaces.
      for(; i < 16; i++)
      {
            ShowChar ( ' ' );
      }
}

// Show one character.
void ShowChar ( char ch )
{
      /*outportb(CONTROL,inportb(CONTROL) & 0xFE);Reset Srobe*/
      outportb(DATA, ch );
      outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
      delay(20);
      outportb(CONTROL,inportb(CONTROL) & 0xFE);/*  Reset Strobe */
      delay(20);

}

Paul
0
deepanpAuthor Commented:
trying it nw, fingers crossed!
0
deepanpAuthor Commented:
it does't shift the letters, i can see the cursor moves, but it like blinks the characters and it doens't shift it....


I tried changing the letters, and even then, the letters didn't move about:S

Any reason you could think of.
0
deepanpAuthor Commented:
i think were LIKE SOO CLOSE!!!, we just need to move the character, COME ON PAUL!!, lol :-)..
0
PaulCaswellCommented:
Tell me what it does. Remember I can see what you see!

Paul
0
PaulCaswellCommented:
Sorry! I didnt read your first post!

void ShowString ( char * string, int start )
{
      int i;

      ... Put something here to make it start back at the left side of the display.

      for(i = 0; i < 16 && string[i] != '\0'; i++)


Paul
0
deepanpAuthor Commented:
as in from the begginning of the display, i.e. the hex function
0
deepanpAuthor Commented:
Hey Paul,

http://www.shellyinc.com/techsupIOR.htm

this site, theres a hex code, that basocally tells the:

80 10000000        Home first line

is this what you mean, i used the code
outportb(CONTROL,inportb(CONTROL) & 0x80);


this is a comment, /*outportb(CONTROL,inportb(CONTROL) & 0xFE);Reset Srobe*/ , should this be right, just in case?
0
PaulCaswellCommented:
>>as in from the begginning of the display, i.e. the hex function
Perhaps!

You could try the 2) Return Home function (0x02) instead. Take a look in the manual (page 8) and see what works.

Paul
0
deepanpAuthor Commented:
gnna reset the whole circuit, and try agian, just in case if its dt, gimme a sec :)
0
PaulCaswellCommented:
From

http://www.shellyinc.com/techsupIOR.htm

02 00000010        Home cursor, also returns display to original position

Perhaps, but, again, try it and see.

Paul
0
deepanpAuthor Commented:
right, i tried it, and it printed worlds its a good, but it missed day...hmmmm, nearly der:P
0
deepanpAuthor Commented:
Yes!!, it does work, but for some reason it misses out day, it prints the information also on two lines, i ain't too bothered about that, that will do..


But its just the day thing:s... its probably the length or something... what do u think.. which part would it be
0
deepanpAuthor Commented:
WERE SOO CLOSE!!, i just figurered it out that it doesn't carry on from the second, like so it will show
i.e
>world its a
>oo world
0
PaulCaswellCommented:
Try changing:

     for ( offset = 1; offset < length - 16; offset++ )
 
to:

     for ( offset = 1; offset < length; offset++ )
 
Paul
0
deepanpAuthor Commented:
lemme give dt a try.

P.S, if you are planning to go to bed, cse i knw its coming to twenty to twelve, then can you just quickly whip up the code that stores the text into the string, cse this might take more time, even hough we are ever soo close, i have been trying to use the other hexs, it just prints the sme as wlel..
0
PaulCaswellCommented:
Post the code.

What do you mean by 'code that stores the string'?

Paul
0
deepanpAuthor Commented:
like, the text file reads the string from the file, and then stores it into a String variable, so it can be dne that way instead of puttiing the string in code, it reads string from the text file
0
deepanpAuthor Commented:
u know since i have changed that last bit of code, it doesn't seem to print anything anymore:S, dunno why, i have bin trying several resets n etc, fustrating thinking it could be lcd, but lcd smartie program wrks...


What time u plannin to go to bed btw?
0
PaulCaswellCommented:
Going to bed soon!

Make a file called Message.txt in the current direcory. Add a line of text < 128 characters long with CR on the end. Then try this:

/*  LCD Module Software                                               */
/*  17th May 1997                                             */
/*  Copyright 1997 Craig Peacock                                      */
/*  WWW     - http://www.senet.com.au/~cpeacock                       */
/*  Email   - cpeacock@senet.com.au                                   */
/*                                                                    */
/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378  /* Enter Your Port Address Here */
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

#include <stdlib.h>
#include <dos.h>
#include <string.h>


#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

// Function that shows string.
void ShowString ( char * string, int start );
// Show one character.
void ShowChar ( char ch );
// Read the string from a file.
char * ReadFromFile ( void );

void main(void)
{

      char * string = ReadFromFile();
      int length = strlen(string);
      char init[16];
      int offset;
      init[0] = 0x0F; /* Init Display */
      init[1] = 0x01; /* Clear Display */
      init[2] = 0x38; /* Dual Line / 8 Bits */

      outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make
                                                                        sure Forward Direction */

      outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register
                                                                        Select) */


      for (offset = 0; offset ; offset++)
      {
            outportb(DATA, init[offset]);
            outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
            delay(10);                                 /* Larger Delay for INIT */
            outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
            delay(10);                                 /* Larger Delay for INIT */
      }

      outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer
                                                                         (Register Select) */

      // Show the string at least once.
      ShowString( string, 0 );
      // Scroll it.
      for ( offset = 1; offset < length - 16; offset++ )
      {
            ShowString ( string, offset );
      }
}

void ShowString ( char * string, int start )
{
      int i;
      // Print the string.
      for(i = 0; i < 16 && string[i] != '\0'; i++)
      {
            ShowChar ( string[i] );
            delay(20);
      }
      delay(9000);
      outportb(CONTROL,inportb(CONTROL)& 0xFE);/*Reset Strobe*/
      for(; i < 16; i++)
      {
            ShowChar ( ' ' );
            delay(20);
      }
      // Return Home (maybe)
      outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register
                                                                        Select) */
      ShowChar ( 0x02 );
      outportb(CONTROL, inportb(CONTROL) & 0xF7);  /* Reset Select Printer
                                                                         (Register Select) */
}

// Show one character.
void ShowChar ( char ch )
{
      /*outportb(CONTROL,inportb(CONTROL) & 0xFE);Reset Srobe*/
      outportb(DATA, ch );
      outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
      delay(20);
      outportb(CONTROL,inportb(CONTROL) & 0xFE);/*  Reset Strobe */
      delay(20);
}

// Read the string from a file.
char * ReadFromFile ( void )
{
      // Open file called 'Message.txt"
      FILE * file = fopen ( "Message.txt", "r" );
      static char string [128];
      if ( file != NULL )
      {
            // Read one line.
            fgets ( string, sizeof(string), file );
            // Trim cr/lf off end.
            while ( strlen(string) > 0 && strchr ( "\n\r", string[strlen(string)-1] ) != NULL )
            {
                  string[strlen(string)-1] = '\0';
            }
            fclose ( file );
      }
      else
      {
            // Couldnt open the file! Return an error string.
            strcpy (string,"File 'Message.txt' not found!");
      }
      return string;
}

Paul
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deepanpAuthor Commented:
okay, going to try it now!

With the code, i don't get it still don't work, but i have given up, i'll just revert back to the code that you gave when it was working, and might have a go tomorrow again..

The thing is that the presentation is tomorrow, that is why, and its at 2pm, just to let u knw, if you wanna have a go with it..

gnna try it nw, let u knw in a bit



0
PaulCaswellCommented:
Too tired now! Sorry! Gotta sleep! Got work in the morning! Good luck!

GET SOME SLEEP!

Paul
0
deepanpAuthor Commented:
lol, i knw!, i will, if it doesn't work after this, i will just finish it with what we have done..


Paul, i'd just want to say a BIG THANKS to you, for all the help that you have given, people like you is what makes this service so much better, not to mention, worth actually keeping, as other services like this, i have experienced have been poor in communication.

P.S - if by any chance you get to crack the code, if you attempt it again, post me, as i will be monitoring all of tomrorow until deadline.

:-)

THANKS AGAIN!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.