LCD display 16x4

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

Post Reply
JCMB
Posts: 22
Joined: Wed Feb 08, 2006 3:15 pm
Location: St Etienne, France
Been thanked: 1 time
Contact:

LCD display 16x4

Post by JCMB »

With a 16x4 lcd display lines 2 and 3 are shifted of 4 postitions.
J modifie LCDDisplay_Code.c and now it's ok.

Old code:

Code: Select all

void Cursor(char x, char y)
{
/*Macro_Curseur_Start*/
/*Macro_Cursor_Start*/

  #if (%j == 1)
    y=0x80;
  #endif

  #if (%j == 2)
	if (y==0)
		y=0x80;
	else
		y=0xc0;
  #endif

  #if (%j == 4)
	if (y==0)
		y=0x80;
	else if (y==1)
		y=0xc0;
	else if (y==2)
		y=0x94;
	else
		y=0xd4;
  #endif

	%i_RawSend(y+x, 0);
	delay_ms(2);

/*Macro_Cursor_End*/
/*Macro_Curseur_End*/
}
New code:

Code: Select all

void Cursor(char x, char y)
{
/*Macro_Curseur_Start*/
/*Macro_Cursor_Start*/

  #if (%j == 1)
    y=0x80;
  #endif

  #if (%j == 2)
	if (y==0)
		y=0x80;
	else
		y=0xc0;
  #endif

  #if (%j == 4)
	if (y==0)
		y=0x80;
	else if (y==1)
		y=0xc0;
	else if (y==2)
		y=0x90;  //94->90 JCMB 10/2/09
	else
		y=0xd0;  //d4->d0 JCMB 10/2/09
  #endif

	%i_RawSend(y+x, 0);
	delay_ms(2);

/*Macro_Cursor_End*/
/*Macro_Curseur_End*/
}

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LCD display 16x4

Post by Benj »

Hello

Are you sure this is correct??

The addresses 94 and d4 are the ones used to address lines 3 and 4 of the 4 line displays.

This is confirmed here: http://joshuagalloway.com/lcd.html

So in fact this code is correct

Code: Select all

void Cursor(char x, char y)
{
/*Macro_Curseur_Start*/
/*Macro_Cursor_Start*/

  #if (%j == 1)
    y=0x80;
  #endif

  #if (%j == 2)
   if (y==0)
      y=0x80;
   else
      y=0xc0;
  #endif

  #if (%j == 4)
   if (y==0)
      y=0x80;
   else if (y==1)
      y=0xc0;
   else if (y==2)
      y=0x94;
   else
      y=0xd4;
  #endif

   %i_RawSend(y+x, 0);
   delay_ms(2);

/*Macro_Cursor_End*/
/*Macro_Curseur_End*/
}
Is this not the case with your hardware? If so then please can you tell us where you got your LCD from so we can have a look at the specs and see why it is working differently.

JCMB
Posts: 22
Joined: Wed Feb 08, 2006 3:15 pm
Location: St Etienne, France
Been thanked: 1 time
Contact:

Re: LCD display 16x4

Post by JCMB »

J got my LCD from "Electronique Diffusion", http://www.elecdif.com.
Ref. for ElecDif is "OPLCD4X16C".
Ref. on the display is "ECM 1604C-RN-YBS".
J can't find doc. on web for this display.
It works fine with the change J made.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LCD display 16x4

Post by Benj »

Hello

Ok I think we have this under control now. 4x16 LCDs require the 0x90 and 0xd0, 4x20 displays require the 0x94 and 0xd4. I have edited the components and should be able to provide a more long term solution to the problem shortly.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LCD display 16x4

Post by Benj »

Hello JCMB

Please could you try out this new component for me and see if it fixes the problems you were having.

Simply drop the contents of the archive into your Flowcode V3/components and then restart Flowcode. You may want to make a backup of your LCD component files first incase there is a problem.
Attachments
LCDComponent.zip
(36.25 KiB) Downloaded 594 times

JCMB
Posts: 22
Joined: Wed Feb 08, 2006 3:15 pm
Location: St Etienne, France
Been thanked: 1 time
Contact:

Re: LCD display 16x4

Post by JCMB »

Tests OK.
The new code you send works fine with my 16x4 LCD dispaly.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LCD display 16x4

Post by Benj »

Great thanks for letting me know. Was worried there for a bit.

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: LCD display 16x4

Post by jimhumphries »

Benj wrote:Hello JCMB

Please could you try out this new component for me and see if it fixes the problems you were having.

Simply drop the contents of the archive into your Flowcode V3/components and then restart Flowcode. You may want to make a backup of your LCD component files first incase there is a problem.
Ben:

I use the LCD code that appears in the "Articles" section to support custom characters (http://www.matrixmultimedia.com/mmforum ... =26&t=4796). Do the code modifications described in that article apply to your new LCD component code? If not, can you describe how to modify your code to support custom characters.

Thanks,

Jim

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LCD display 16x4

Post by Benj »

Hi Jim

Yes the solutions detailed on that topic will work with the latest LCD component. No simulation though.

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: LCD display 16x4

Post by jimhumphries »

Thanks Ben.

Will the v4 LCD component incorporate your update and the custom-character-enabling code? I may be wrong but it seems that these general enhancements are not being rolled up into successive versions and it seems to me that they should be. Surely you wizards are better equipped to accomplish this successfully than are the individual Users.

Jim

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LCD display 16x4

Post by Benj »

Hi Jim

Custom characters for simulation is rather a tricky one and we feel at the moment that as the program will work instantly on the hardware there are better uses of our time. Eg other more important things that need working on. Sorry to bear the bad news. We have an article in our knowledge exchange portion of the forum that details creating and using custom characters.

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: LCD display 16x4

Post by jimhumphries »

Ben:

It isn't the ability to simulate custom characters that I was referring to. The simulator is handy but I find it more useful to debug on the target system because of timing concerns.

What I'm referring to seems to me to be more like a revision control issue and a question of who has the ultimate responsibility to assure that enhancements that Matrix offers on the Forum get incorporated into successive versions of Flowcode. The case in point in my previous post was the LCD custom-character-enabling code that was presented in Steve's Forum article. At least in my opinion, that feature should have been rolled up into the v3.6 version of the LCD component (and all subsequent versions) and I think that you guys are obviously the best qualified to do that. There may be other examples but that's the one that caused my v3.2 code to fail to compile to HEX under v3.6. I chased my tail for several days not knowing if I had a bad installation or what until Steve reminded me that I needed to modify the LCD component to support my custom characters.

Anyway, I think you get the idea and I agree that you shouldn't spend you valuable time enhancing the simulator!

Jim

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: LCD display 16x4

Post by Steve »

Hi Jim,

I understand your concern, but this is not an issue of version control. The customization of the LCD code presented in the article I wrote was just that - an example of how to customize the C code for the components. We did not (necessarily) intend it to be incorporated into the main LCD code (although perhaps eventually this will be the case). It was probably intended for Flowcode users who also write in C.

Regarding the question of who has ultimate responsibility for Flowcode enhancements, then I suppose I do. But you cannot assume that the enhancements and customizations we offer through the forum will ever become incorporated into Flowcode itself, although some may do so.

Of course, we'll always provide excellent support for anyone wanting to migrate these customizations into a later version of Flowcode. But we can never guarantee that such customizations will continue to work once Flowcode has been upgraded.

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: LCD display 16x4

Post by jimhumphries »

Steve:

Thanks for the reply and I understand your position.

My fear of course is that components or .fcd code that I modify per your Forum posts will not be upwardly compatible with newer releases of Flowcode. Upgrading, then, is somewhat like playing Russian roulette and troubleshooting, when required, is likely to be beyond my limited programming skills. I have to rely on you for the diagnosis and cure. No complaints so far on the support side, though. You guys have always been terrific at fixing my problems.

Jim

Post Reply