128 x 64 glcd

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

128 x 64 glcd

Post by Tony Brown »

Does anyone know how to connect the cs lines of a glcd to the pic. I have a 128 x 64 glcd and I am unsure how to connect to,
its not as easy as a standard 16 x 2 lcd.

Thanks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: 128 x 64 glcd

Post by Enamul »

Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Enamul,

If you ment the hardware connection, its not that difficult you can pick any OI port or pin you like.
If you need to know how to do this in software, you would need to edit the C code.

What type of display are you using???

Regards jordy
the will to learn, should not be stopped by any price

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: 128 x 64 glcd

Post by Enamul »

Hi jordi,
I do not have one in hand but I am thinking to order one. Tony asked about connection I told him that.
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

O sorry that message was not ment for you haha.
I mented to ask tony brown. Sorry about that.
the will to learn, should not be stopped by any price

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi
I am wanting to use a MG1206E 128x64 dot glcd. I have never used one of these before so your help is most appreicated.

Would I be able to use on e of these displays in flowcode?

Regards

Tony

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Hi, Tony Brown

I have googled up your display and it turns out that this display uses the KS0107/KS0108 controller chip. There is a costum component for it so we are going to get this to work!
First I need to know, do you have this display connected in hardware. If so Do you have the costume component installed, if you dont have the display connected in hardware here is a example how you can do this.

Image

beware of that the above example can use different pinouts then your display so be carefull that you connect this properly.
For the data lines I would recommend to use one whole port for example PortB0...7 for the other signals such as CS1 CS2 R/W E you can use any other port.

Let me know how you get along.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: 128 x 64 glcd

Post by Enamul »

Hi Jordi,
You are talking about your following post...
http://www.matrixmultimedia.com/mmforum ... LCD#p37244
Can you please post program what you have modified so that Tony and others those who are interested in gLCD can try that.
Thanks,
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Ofcourse I can...,

If you LCD is connect correctly and the costum component is correct but you experience the following problems:

* One half side of the LCD print the text correctly and the other doesnt
* If you switch the CS line the result is the same but switch from sides
* Display doesnt show any correct strings all pixles over the place

Its likely to be a timing problem, not every controller chip is the same so timing can very. a quick and simple solution to this problem is to add open the costume code file and ad some "No Operation" functions this will add some delay the the program.

to do this you will need to open the costume code C file in you favorite editor and go to the following line:

Code: Select all

//Global Variables
char mx_page;
char mx_currentx;
char mx_currenty;


//Internal Prototypes
void MX_LCD_Enable (void);
void MX_Write_Command(char cmd, char chip);
void GotoXY(char x, char y);
void MX_WriteData(char data);
char MX_ReadData(void);


//Internal Functions
void MX_LCD_Enable (void)
{
	set_bit(MX_CONTROL_PORT, MX_ENABLE);
	//delay_10us(1);								//Min delay 450ns
	nop();
	nop();
	nop();
	nop();
	nop();
	nop();
	nop();

	clear_bit(MX_CONTROL_PORT, MX_ENABLE);
	//delay_10us(1);								//Min delay 1.5us
	nop();
	nop();
	nop();
	nop();
	nop();
	nop();
	nop();
}
This part of the code is located directly under the ASCII table(s)

You can see the "nop();"functions.
What you are going to do is add one nop in every row and uplaod you program to your controller and check the result, evry time you ad a nop you should see some inprovement, keep adding nops (one at a time) untill the display works correctly. if adding nops doesnt help you can remove the number of nops you have added and remove on at a time in the two rows until the display works correctly but this unlikely.
the will to learn, should not be stopped by any price

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi Jordy

As of yet I have not done anything with the glcd, only got it Wednesday... I have been reading your post that mentions custome components, firstly what are these and were do you get them from (please remember I am very new to flowcode ;-) ). Is it easy in flowcode to add this display?

I have looked in flowcode and have not seen a glcd like this one in the output glcd section.

The hardware side of things I will be fine with.

Regards

Tony

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi Jordy

Just downloaded the custome code for the glcd, been on flowcode and called it up as user output. Seems easy enough. I seen a flowcode example of a glcd, can you please explain all the cordinates for example : lcd_draw_line(0,0,127,63,1).

Thanks

Tony

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Ok thats good news,

remeber that you cannot edit the components connection in flowcode itself this needs to be done in the costum code C file this is the section where you can do this.
If you open the costum component file goto line 282 here you will find //Common Defines.
These are the things you need to change:

*#define MX_DATA_PORT port(h)
*#define MX_DATA_TRIS tris(h)
*#define MX_CONTROL_PORT port(d)
*#define MX_CONTROL_TRIS tris(d)
*#define MX_CS1 (3)
*#define MX_CS2 (4)
*#define MX_DAT_INST (1)
*#define MX_ENABLE (2)
*#define MX_READ_WRITE (0)

For DATA_PORT and DATA_TRIS you need to change the letter in bold to the port you're using for your datalines (DB0...7)
For CONTROL_PORT and CONTROL_TRIS you need to change the letter in bold to the port you're using
The rest you need to change the number to the port pin you're using for that signal.

If you understand this and have done the changes I will explane how the macros work.

Regards Jordy

PS. you need to understand this first otherwise the macro's wont do anything :wink:
the will to learn, should not be stopped by any price

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi Jordy

I figured out that I needed to change the custom C file and have adjusted it accordingly.
ie: data is on port d and control is on port c. With the file I downlaoded there was a pinout guide, I have adjusted this to match the glcd I have.

So how do we do the macro part?

And did you understand the cordinates I was on about?

Regards

Tony

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Oke lets move on,

You we always start with some initilization of the LCD so first we use this macro

LCD_Init

To print some text on the glcd we will use this macro

LCD_Print_String

Here we need to enter some expresssions, these are the following expression we need to enter:

* String = Your text in string format for example ("Hello World") dont forget the brackets ""
* X = the horizontel position of the cursor this can range from 0 to 127
* Y = The vertical posistion of the cursor this can range from 0 to 63
* Font = the size of your text 0 is standard (Just play with it
* Transparent = makes your string transparent I think I dont use this function :roll:
* Color = 1 for positive and 0 for negative

What this means is when selecte 1 your text is dark and the background not.
when color is 0 your background becomes black and the text not.

hope this helps, if not let me know
If you want a example just ask.

Regards Jordy
the will to learn, should not be stopped by any price

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi Jordy

Thanks for your excellent explaination, your help is much appreciated.

I will let you know how it goes :D

Regards

Tony

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi Jordy

How do I create the macros?, it is not like usual. I am unsure of how to get the LCD_int into the macro box.

Regards

Tony

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Hi Tony

first you need to select this component and drag into your panel.

Image

Remeber that you need to rename your costum code C file if you not already done this. If not rename this to : FC5_PIC_Custom.C

Now you can select this icon for inserting macros:

Image

If you've done this you can double click on the macro icon in your flowcode and select: Costum(0)
If you've done verything correct all the different options are visible for your GLCD

Hope this help you out, if not let me know :wink:

Regards Jordy
the will to learn, should not be stopped by any price

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi Jordy

Thanks for that, its all familiar now :)

Will let you know how it goes.

Regards

Tony

electron67
Posts: 311
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 104 times
Been thanked: 47 times
Contact:

Re: 128 x 64 glcd

Post by electron67 »

Hi All,
you can give an little example where using a 128x64 LCD, I have one, but I have not used the block cusstom and do not understand code c.

Electron67
Thanks

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

what do you not understand, how to use the costum component, how to make the costume component ready for use. Can you clear this up for me,
I can make you a example flowcode but if you dont understand what I have said in this topic it wont help you much.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: 128 x 64 glcd

Post by Enamul »

Hi jordy,
I have ordered one 128*64..I will get soon. I think if you could make a complete tutorial to use gLCD that will be helpful for lots of users..
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

electron67
Posts: 311
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 104 times
Been thanked: 47 times
Contact:

Re: 128 x 64 glcd

Post by electron67 »

Hi Jordy101091
Yes, I see that you use codigo c in cusstom component; if I see an exemple the custom component ready for use a lcd 128x64, I can understand how can do.

Electron67
Thanks

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 128 x 64 glcd

Post by Jordy101091 »

Oke, if I have some time tomorrow I will make a tutorial on how to use a GLcd with flowcode specifically a ks0107/0108 GLcd. Also I will put a example file together that you can use with the tutorial. hope this helps people to use there ks0107/0108 graphic LCDs.

So... Report to you all back tomorrow

Over and out :)

Regards jordy
the will to learn, should not be stopped by any price

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

I got my glcd to work but instead of the text being instantly on the screen it slowly prints one letter at a time. Anyone have any idea's

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: 128 x 64 glcd

Post by Tony Brown »

Hi All this is the first time that I have put any help on here but I hope it helps.

Im using the ks0107/0108 graphic LCD 128x64.

To get it to work in flowcode I downloaded the custom_code.c file (see attachment Custom_code.c), renamed it to FC5_PIC_Custom.C, and copy and pasted it into: Program files (x86), Flowcode, V5, components.

Now I opened Flowcode and selected the pic, and then selected the icon with the hammer and spanner on (near the top right), in there you will see Custom and Custom2, select Custom. Note: Flowcode will not emulate this code so your glcd will only work when your pic has been programmed and the glcd is hardwire to the pic.

REMEMBER to rename your Custom_code.c to FC5_PIC_Custom.C and put it in the correct folder (should have been done this already, but just in case :-) ).

This can now be treated like a normal lcd would be in flowcode, meaning you can now initailise and select other functions like you would if you were priniting to a lcd, although the coordinates take abit of getting used too.

Taking a look at the attached file "adjusting the ports to match your glcd" , in here you will find a section of the Custom_code.c file, at present it is set so that all data is sent to port D (ie DB0-DB7) of the pic and the controls (ie cs1, cs2, dat_inst) are sent to port C. The data sent to port D is sent such that DB0 on your glcd goes to the first bit of the port. ie (on my glcd) pin 7 of glcd is DB0 and this goes to (using a 16f887) pin 19 of my pic and so on. The pinout for your glcd will help you greatly when sorting this out, it did me. If you dont want to use ports C and D you can change them, but remember to save your changes to Program files (x86), Flowcode, V5, components and FC5_PIC_Custom.C

I have also included a copy of flowcode I made to test the glcd.

I hope this is useful to someone.

Id like to thank Jordy for all his help when I was stuck.
Attachments
adjusting ports to match your glcd.txt
These are the ones to adjust to change the ports that the pic will use.
(317 Bytes) Downloaded 347 times
Custom_Code.c
This is the ks0107/0108 graphic LCD custom code
(22.01 KiB) Downloaded 352 times
glcd.fcf
This is my working flowcode for this glcd
(7.5 KiB) Downloaded 371 times

Post Reply