GLCDs

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

xtdan
Posts: 10
Joined: Wed Jul 04, 2007 1:15 pm
Location: East Yorks
Contact:

GLCDs

Post by xtdan »

:?:
Hi,

I am currently trying to get a GLCD working using flowcode. The module I am working on uses the KS0108 controller chip, which seems to be quite common for these mono dot matrix LCDs. Unlike the small 2/4 line LCDs, the datasheets seem to be quite unhelpful...

....So has anyone else been working with these? If so any help would be GREATLY appreciated...

I don't supose Matrix have ever considered writing a component for one of these? We use the 2 line LCD component a lot and have found it really easy to use.

Many thanks in advance for any help anybody can give.

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: GLCDs

Post by Benj »

Hello

There is now a beta Flowcode component to drive KS0108 and KS0107 mono 128 x 64 pixel displays.

This code is available from here,

http://www.matrixmultimedia.com/Flowcode_Components.php

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Hi Ben.
I quickly tested that Glcd beta component,and it works fine..
But it dont have print number macro,so how an i print some like a/d con value?
And is it possible to reduce "default" font size to 5x7 or even 6x4?
I know that those font sizes are really small,but it gives little smaller font on double font size and that is usefull at least to me...

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: GLCDs

Post by Benj »

Hello

Sorry I missed off the print number function. This updated component code file should now provide the print number functionality.

As for changing font sizes yes this is possible. Theoretically all you would have to do is edit the font arrays that are defined near the start of the component code. If you scaled down the values of each byte so that the 2 least significant bits are always 0 then there is your 6 pixel font etc.
Attachments
KS0108.zip
(8.48 KiB) Downloaded 603 times

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Ok.
Ben how an i change the port for the glcd connections? I need to use the the pwm outputs of the chip,so at least i need to change the cs2 and the data inst gates...

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: GLCDs

Post by Benj »

Hello

The connections for the Graphic LCD are laid out in the custom code c file. Please refer to the readme for instructions on how to change the pins / ports for the LCD.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Ben,tested the new component,it prints the number but when i set the print number macro,and print the variable witch is 3 digit long,the display prints the number 7 digit long,and the 4 last number are the same..
Same thing with the print string macro,if the string size is 5 and the string is like 12,3,the display prints 12,33..
Is there bug,or something what i dont understand?
By the way,is it possible to use onewire temp sensor component and the ks108 component at same program,both are custom component,so it seems impossible...

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: GLCDs

Post by Benj »

Hello Mikat

Ok I will look into the problem of the numbers being repeated. I did not notice this during testing.

In the latest version of Flowcode 3.4.7 there is custom code 2 that can be used. Therefore you can have the onewire code in your program too by renaming one of the custom_code.c files to custom_code2.c

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Ben,have you got time to check that print problem?
I tested i bit more,and it seems that printnumber print 6 number,no matter what,so its the same it the value of printed variable 2 or 22222,the print is 222222...
And the printstring function prints the lenght of string,even if the string value is 2...
By the way,the i2c,custom1 and 2 component have custom_dummy_functions,so it dont compile if two of those components are used...
I solve the problem by renaming those custom1,custom2 etc,is it ok...

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Little update for that problem,just tested different type glcd and the problem is the same,so i dont think that the problem is in hardware...

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: GLCDs

Post by Benj »

Hello

Sorry I have spotted the bug and fixed the problem in the C code driver. Attached is the updated C code file.
Attachments
Custom_Code.c
(22.04 KiB) Downloaded 480 times

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Ben,the print number macro works fine now,but should the print string macro print the lengt of string,even if the value is shorter,like str[6],and value is 2,should it print 222222?
By the way,how i get the degree sing (Β°) in that custom glcd?

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: GLCDs

Post by Benj »

Hello Mikat

I will look into the string problem for you as it should only print out the data held in the string.

As for adding the degree sign. Have a look in the custom code .c file for the ASCII data array. Simply choose an ASCII character that you are unlikley to use and edit the data so that you create the degree character. Then send the ASCII value that you chose to overwrite and the degree symbol will appear. The data is arranged into 5 columns each with 8 rows, therefore each character is defined by 5 byte variables.

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: GLCDs

Post by Benj »

Hello

Ok I have ironed out the print string bug now too. Hopefully this should all be ok now. Let me know if there are any more bug spots.
Attachments
Custom_Code.c
(22.01 KiB) Downloaded 397 times

xtdan
Posts: 10
Joined: Wed Jul 04, 2007 1:15 pm
Location: East Yorks
Contact:

Re: GLCDs

Post by xtdan »

Hi Ben,

Haven't been in the forum for quite a time as I have been working on other projects. But, I am now to be back on the control panel project which sparked my original query - almost a year down the line. I did manage to get PICs to generate text on the display by manually sending the correct sequence of instruction codes and data bytes, it was nice to see things on the screen but was way too cumbersome for what we needed to do.

Anyway, now I have surfed back in to catchup on all things Flowcode I will have a play with the macro.

Many thanks for the help you have provided (even though I haven't personally used it as yet).

Now to post a new thread with a query regarding CAN.

Best Regards

Dan

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Hi Ben. The print string macro seems to working right now,many thanks..
When you have time,could you change the custom c code,so the data port and the cs1,cs2,enable,etc could be changed in component properties box in Flowcode...
Now i had to edit the custom c file every time when i compile code for different pcb layout...

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: GLCDs

Post by Benj »

Hello Mikat

Glad its all working correctly now.

Modifying the component code to allow you to define your own ports and pins in Flowcode is fairly simple.

Near the top of the Custom_Code.C file you will find the following section.

Code: Select all

//Common defines
#define MX_DATA_PORT 		portd	//%a
#define MX_DATA_TRIS		trisd	//%b
#define MX_CONTROL_PORT	portc	//%c
#define MX_CONTROL_TRIS	trisc	//%d
#define MX_CS1				0	//%e
#define MX_CS2				1	//%f
#define MX_DAT_INST		2	//%g
#define MX_ENABLE			3	//%h
#define MX_READ_WRITE		4	//%i
Simply replace with this.

Code: Select all

//Common defines
#define MX_DATA_PORT 		%a
#define MX_DATA_TRIS		%b
#define MX_CONTROL_PORT	%c
#define MX_CONTROL_TRIS	%d
#define MX_CS1				%e
#define MX_CS2				%f
#define MX_DAT_INST		%g
#define MX_ENABLE			%h
#define MX_READ_WRITE		%i
Once you have done this you can enter the parameters directly into the properties of the custom component in Flowcode.

Unfortunatly this way means that you will have to re-enter the parameters for every program you create that uses the custom component. A work around for this is to create a blank Flowchart containing a custom component, define your connections as needed and then use this file as a template for creating programs with that particular set of pin connections.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Hi Ben.
Is it how big job to modify that ks108 code to support 192x64 displays? I i understand correctly,the chip select just goes to 01 to 10 when the adress goes over 128...
Is there any change that you coul to that?

Mika

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: GLCDs

Post by Benj »

Hello Mika

Yes this should be fairly easy to do. You should be able to find the part of the C code that deals with the horizontal addressing and add in an extra address locations.

If you get stuck then let me know and I will take a look.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Ben,how can i mark that the adressa is between 2 values,like 63-127 in c language?
I mean that code
if(mx_currentx < 64)
{
clear_bit(MX_CONTROL_PORT, MX_CS2); //Select chip 1
set_bit(MX_CONTROL_PORT, MX_CS1);
}

else if(mx_currentx >= 64)
{
clear_bit(MX_CONTROL_PORT, MX_CS1); //Select chip 2
set_bit(MX_CONTROL_PORT, MX_CS2);
There should probably be that if the x adr is between 64 - 127 select chip 2...
By the way,how those clear and set goes in 3 "chip values"?

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: GLCDs

Post by Benj »

Hello

You can do the following.

if(mx_currentx < 64)
{
}
else if(mx_currentx >= 64 && mx_currentx < 128)
{
}
else if(mx_currentx >= 128)
{
}

The set and clear functions act to toggle a single bit (0-7) in a 8-bit register or variable.

Hope this helps.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Hi Ben.
I tried to got working that 192x64 display,but no luck,i cant get anything on that chip3 "area"....
By the way,the "normal" ks108 code draws pixels at 64 to 192,so the third chip is 0-63...

Ill take that back,got working,the problem was that the third chip goes firs,and uses cs command 00...

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

Ben,do you have change to test that ks108 code so that you move the controlport to portb?
Because i have tried to get it working but no way,it wont work on port b,the init messes the whole port working,if i set the control pins at b7 to b3,and put the blinking led at b0,the led works untill i put the init lcd macro to flowline...
It would be very nice to have that code work other port than portc,because the timer 1 osc,pwm,spi/i2c and rs232 is that port,so it has many other use..

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: GLCDs

Post by Benj »

Hi Mikat

Yeah its fairly easy to switch port of the driver file. Open the file and browse to the following section of code.

Code: Select all

#define MX_DATA_PORT 		portd	//%a
#define MX_DATA_TRIS		        trisd	//%b
#define MX_CONTROL_PORT		portc	//%c
#define MX_CONTROL_TRIS		trisc	//%d
#define MX_CS1				0		//%e
#define MX_CS2				1		//%f
#define MX_DAT_INST			2		//%g
#define MX_ENABLE			3		//%h
#define MX_READ_WRITE		4		//%i
Change the port and tris registers to suit your application. You can even change the control pin allocation if you wish by editing the numbers.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: GLCDs

Post by Mikat »

The port and the pins are configured in flowcode,like you advise above,the problem is that the code dont work if i change the control pins on portb...
The code allows fine the change the control pins,but i can get it working when i change the controlport.
so can you test that code works controls on portb?

Post Reply