Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem interfaceing PIC18F2550 and KS0108 LCD

Status
Not open for further replies.
Hi 3v0, thanks by the answer but the lib, link, inc phats are well defined... well they are like you told me.. e:\microchip\MCC18\lib; e:\microchip\MCC18\LKR; e:\microchip\MCC18\h.
maybe the student version have no features for this? I don't know... but I would like to know if some one tell me...
Any one knows if exist a errors manual? I'm trying to find it in the manuals of the compiler but until now I didn't found any thing... If you know please post a link to it. Thanks
 
Last edited:
YOU ARE THE MAN!! hehe, this error is solved!
thanks!!!
 

Attachments

  • Fotos-0028.jpg
    Fotos-0028.jpg
    223.1 KB · Views: 352
Last edited:
  • Like
Reactions: 3v0
To contribute for who needs... I used the 3 codes in the first post of this threat, then because my pic and hardware are different (18f452) my chages was:
GLCD.H

#include <p18f452.h>
//#define __18C452_H
#define GLCD_Data PORTD
#define b_GLCD_GCS1 LATBbits.LATB2
#define b_GLCD_GCS2 LATBbits.LATB1
#define b_GLCD_RS LATEbits.LATE1
#define b_GLCD_RW LATEbits.LATE0
#define b_GLCD_E LATEbits.LATE2
#define b_GLCD_On LATBbits.LATB0
#define b_GLCD_BL LATAbits.LATA0 // Not used in my project

#define TRIS_Data TRISD
#define b_TRIS_GCS1 TRISBbits.TRISB2 //GCS1
#define b_TRIS_GCS2 TRISBbits.TRISB1 //GCS2
#define b_TRIS_RS TRISEbits.TRISE1 //RS
#define b_TRIS_RW TRISEbits.TRISE0 //RW
#define b_TRIS_E TRISEbits.TRISE2 //E
#define b_TRIS_On TRISBbits.TRISB0 //RST
#define b_TRIS_BL TRISAbits.TRISA0 //backlight

void Delay(void);
extern unsigned char GLCD_Read(void);
extern void Wait_Not_Busy(void);
extern void GLCD_Write_Cmd(unsigned char data);
extern void GLCD_Write_Data (unsigned char data);
extern void ClearScreen(void);
extern void Init_GLCD(void);
extern void PutChar(unsigned char data);
extern unsigned char GLCD_Read_Data(void);
extern void SetPos(unsigned char x,unsigned char y);
extern void WritePosition(void);
extern void plot(unsigned char x,unsigned char y);
extern void hline(unsigned char x,unsigned char y1,unsigned char y2);
extern void vline(unsigned char x1,unsigned char x2,unsigned char y);
extern void box(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2);
extern void PutMessage(static char rom *Message);
extern void PutLogo(static char rom *logo);


Main.c
#include <p18f452.h>
#include "glcd.h"
#pragma config WDT = OFF
#pragma config BOR = OFF
#pragma config STVR = ON
#pragma config DEBUG = ON
#pragma config LVP = OFF
//#pragma config PLLDIV= 5 // need 5 for 20MHz xtal
//#pragma config CPUDIV= OSC1_PLL2 // CPU Clock = 96 MHz/2 = 48 MHz
//#pragma config USBDIV= 2 // 96MHz PLL/2 = 48 MHz for USB clock
#pragma config OSC = RC //HSPLL_HS // High Speed Crystal / Resonator with PLL enabled
#pragma config OSCS = OFF //OSC. SWITCH
//#pragma CP0 = OFF
//int li;
//#pragma ADCON1=0x0f; // all digital
//#pragma CMCON=7; // no comparators
void main (void)

Good Luck for the readers and thanks for who helped me!
 
Hello

I'm experiencing problems to get KS008 library working well with PIC 18 familly.

In fact, all my code compile properly but when i run the program its hangs up during Init_GLCD(); function

With debug mode, i found that GLCD_Read function gets an issue when it tryes to return LL, i don't know why :confused:

Code:
unsigned char GLCD_Read(void){
	b_GLCD_E=1;
	Delay();

    	LL=GLCD_Data;
	b_GLCD_E=0;
	[COLOR="Red"]return LL;	[/COLOR]
}

For test purposes, i tried to comment out " return LL; " line, then program goes through but it is not able to display anything on the GLCD.


Here is attached m GLCD.c file ( modified to complement CS1 and CS2 with "1-" solution from Pommie's idea. :)

For my GLCD, if i read well the datasheet i found :
CSx ARE complemented,
E is not complemented.
R/W': R is not complemented, W is complemented,
RS (D/I', D: Data, I: Instruction): D is not complemented, I is complemented
RST pin is not available on my GLCD.


Any help will be much appreciated, because i can't find why the programs hangs during Init function.

Best Regards,
 

Attachments

  • GLCD.c
    18.7 KB · Views: 260
  • LCD LED VFD TFT ARTRONIC S.J..pdf
    360.2 KB · Views: 469
  • Design GLCD HY12864Z.pdf
    28.2 KB · Views: 343
Last edited:
I've just tested your library and program freezes exactly at the same position :

in your code , it stops at return glcdData;

Code:
unsigned char glcd_Read(void)
{
	GLCD_EN = GLCD_EN_HIGH;
	glcd_Delay();
	glcdData = GLCD_DATA;
	GLCD_EN = GLCD_EN_LOW;
	[COLOR="Red"]return glcdData;[/COLOR]
}


If i comment out return glcdData;, then program runs properly.
But it only lights the left hand side board, if i try to Put a Message that is located in the middle on the display it is not working properly !

What should i do to have all display available ?
If i put a text longer than pos (64,64) then the display returns to x = 0 position but keeps y postions ( see attached picture for message : "50/50" written at x=50 y=50

Here are the instruction i used to display the attached picture:
Code:
glcd_SetPos(10,0);						// Positionner le curseur (x,y)
glcd_PutMessage("Graphic");				// Ecrire un message

glcd_SetPos(50,50);						
glcd_PutMessage("50/50");				// Write "50/50" at position x=50 y=50

glcd_SetPos(0,63);
glcd_PutMessage("0,63");				// Write "0,63" at position x=0 y=63

glcd_Plot(63,32);
glcd_Box(12,35,25,45);

glcd_HorizontalLine(10,40,50);


By the way :
Can someone tell me why glcd_Read returns glcdData , why this is usefull ?
It looks that glcd_Data is never been changed during glcd_Read function ...
if i understand well, gllcd_Read function sets some pins to proper state and do only glcdData = GLCD_DATA;


Many thanks for your help,
 

Attachments

  • Display capture.jpg
    Display capture.jpg
    48.2 KB · Views: 269
Last edited:
Hello,

I finally succeeded to get hkBattousai GLCD library working ...
( I've got a problem with CS2 pin )

But this library looks getting outstanding results :

- It looks that it is reverse displaying method : White on Black instead of Black on White
Is there a way to change this ?

- When i try to display a long text that uses the 2 controllers ( CS1 and CS2 ) :

Text well displayed until x position is < 63,
when x position is > 63 the rest of text 1 pixel shifted up.

( see my attached capture, "n is (10,32)" is centered with the beginning to the text.
Also "o" letter is also a bit overwritten. ( 2 pixels are missing at the right hand side )

- When i try to display only one pixel with Plot function, i do not get anything on the screen.


I will appreciate your help and advices,
Best Regards,
 

Attachments

  • GLCD_capture.JPG
    GLCD_capture.JPG
    300.3 KB · Views: 249
wg12864b lcd problem

hello hkbattousai,
i have a similar graphical lcd like the one that you have, i got it from turkey, its a wg12864b and i'm using a pic 18f4550 micro controller.
i have wired up the lcd to my pic using a breadboard and i will attach a potentiometer to adjust the contrast soon, but the problem is that my lcd does even come on! i burned the code successfully to the pic and everything looks wired properly, i hope you could help me . i shall attach the code and and my project schematic. to open the second file simply remove the .zip at the end of the extension and open using proteus simulator
 

Attachments

  • TetrisPrograma.c
    44.4 KB · Views: 213
  • TetrisDesign.DSN.zip
    270.5 KB · Views: 201
^ Your zip file is not opening, it is corrupt.
The C file is a very big (+2000 lines) and messy (probably in Spanish), thus very hard to understand and I couldn't find any glcd commands in it.
Can you briefly write here (between
Code:
 tags) your relevant glcd code?
 
^ Your zip file is not opening, it is corrupt.
The C file is a very big (+2000 lines) and messy (probably in Spanish), thus very hard to understand and I couldn't find any glcd commands in it.
Can you briefly write here (between
Code:
 tags) your relevant glcd code?[/QUOTE]
 

 thanks hkbattousai for the quick response, i dont know much about glcd part of the code as it was sent to meby another programmer . my goal is to write a small game on my graphical lcd. if you could show me how to get my glcd working and putting some graphics on it then i might succeed in writing my game for it. i'll reupload the schematic. thanks again.
 

Attachments

  • TetrisDesign.zip
    57.7 KB · Views: 190
Glcd

Dear hkBattousai,

- Can you send me the code for the Graphics LCD WG12864B that work fine at your end.

- I am facing the same problem that you had face during your development of GLCD.

- Please help

Thanks,

Sandip Nandwana
 
...i will attach a potentiometer to adjust the contrast soon, but the problem is that my lcd does even come on...

Unless you have the contrast pot wired in, it is likely that you can't see anything anyway. You need the contrast pot.
 
bUT what should be the Vee voltage range? As per the datasheet we have to provide the negative voltage but , what is min and max range for this Vee?
 
VEE is usually supplied by the LCD module (usually called the VEE pin ;)).

One side of the pot goes to VEE, the other side of the pot to ground, and the wiper goes to the contrast pin. Use a 10K pot.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top