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.

Unicorn GLCD demo.

Status
Not open for further replies.
That looks like it should work. I would loose the f though in temp = 1.2345f;:D

Mike.
 
Help with similar GLCD (128 x 128)

Hi guys, nice work with the code for your glcd.
I've followed the thread, and will surely try it myself.

I have a 128 x 128 glcd which I want to use.. it uses 4 ks0108 controllers,
each controlling a 64 x 64 quadrant but still using just cs1 and cs2

ie

1st quadrant cs1= lo, cs2=lo
2nd quadrant cs1= hi, cs2=lo
3rd quadrant cs1= lo, cs2=hi
4th quadrant cs1= hi, cs2=hi

can anyone offer suggestions on how to change the write code to suit this arrangement?

Cheers
:):)
I'm in NSW, Australia
about to retire--many years in electronics
 
I am not an expert but i think you might need to change the following functions a little bit:

plot
Wait_Not_Busy
WritePosition
MoveRight

and maybe also
PutChar

However Pommie will be better able to guide you as he wrote the whole thing :)
 
Now my code is working. I want to share it with you.

main.c
Code:
#include <p18f2550.h>
#include "delays.h"
#include "glcd.h"

#pragma config WDT	= OFF
#pragma config MCLRE	= ON
#pragma config DEBUG	= OFF
#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 FOSC	= HSPLL_HS	// High Speed Crystal / Resonator with PLL enabled

void main (void)
{
	int temp;
	float temperature;
	
	ADCON0 = 0x01;
	ADCON1 = 0x0e;
	ADCON2 = 0xbe;
	CMCON=7;
	
	TRISAbits.TRISA0 = 1;
	
	glcd_Init();
	
	while (1)
	{
		// Do A/D conversion
		ADCON0 |= 0x02;
		while(ADCON0 & 0x02);
		
		// Read higher part of digital data
		temp = (int) ADRESH;	// Always zero since LM35 outputs only 0.18V
		
		// Multiply by 256
		     if (temp == 1) temp = 256;
		else if (temp == 2) temp = 512;
		else if (temp == 3) temp = 768;
		
		// Add lower part
		temp += (int) ADRESL;
		
		// Convert digital data to Celcius
		temperature = 0.48828f * (float) temp;
		
		// Clear LCD screen
		glcd_ClearScreen();
		
		// Format and print the string
		glcd_SetPosition(0, 17);
		glcd_PutMessage("The temperature is: ");
		glcd_WriteFloat(temperature);
		
		// Delay before next update
		for (i=0; i<5; i++) Delay10KTCYx(0);
	}
}

New GLCD functions:
Code:
void glcd_WriteInteger(int num)
{
	int i;
	char str[7];
	sprintf(str, "%d", num);
	for (i=0; str[i]!=0; i++) glcd_PutChar(str[i]);
}

void glcd_WriteFloat(float num)
{
	int frac;
	glcd_WriteInteger((int) num);
	glcd_PutChar('.');
	frac = (int) (100.0f * (num - ((int) num)));
	if (frac == 0)
	{
		glcd_PutChar('0');
		glcd_PutChar('0');
	}
	else if (frac < 10)
	{
		glcd_PutChar('0');
		glcd_WriteInteger(frac);
	}
	else
	{
		glcd_WriteInteger(frac);
	}
}
 
trying hard to get this working heh:

glcd-jpg.35752


then i might use parallel to serial shifters to read data from glcd using resistors.
 

Attachments

  • glcd.jpg
    glcd.jpg
    314.3 KB · Views: 958
Hi hkBattousai bat for use the sprintf functioun is not necessary include the string.h library ?
Can you put the code for the glcd_PutRAMMessage function or your glc.c ?
I check the your code bat no work in my board. **broken link removed**
 
Hi hkBattousai bat for use the sprintf functioun is not necessary include the string.h library ?
Can you put the code for the glcd_PutRAMMessage function or your glc.c ?
I check the your code bat no work in my board.
 
Hi hkBattousai bat for use the sprintf functioun is not necessary include the string.h library ?
Can you put the code for the glcd_PutRAMMessage function or your glc.c ?
I check the your code bat no work in my board.

Here you are, my entire project.
(Rename its extension to "rar".)
 

Attachments

  • GLCD Project..zip
    54.4 KB · Views: 452
Thank you very much.
I'll try it and have to modify the code for use whith one 18f4550.
PS: Sorry fon my bad English **broken link removed**
 
Thank you very much.
I'll try it and have to modify the code for use whith one 18f4550 and the EasyPic5.
Sorry for my bad English
 
Thank you very much.
I'll try it and have to modify the code for use whith one 18f4550 and the EasyPic5.
Sorry for my bad English

You can use any PIC, no only 18F4550. You just have to make port mapping carefully, that's all.
I preferred 18F4550 just because of being a 40-pin device, and its USB support.
 
Hi hkBattousai i am confused in this part of your code **broken link removed**
Can you specify

#define GLCD_DATA PORTB
#define GLCD_CS1 LATCbits.LATC7 //GCS1 ok
#define GLCD_CS2 LATCbits.LATC6 //GCS2 ok
#define GLCD_DI LATCbits.LATC0 //DI or RS ???
#define GLCD_RW LATCbits.LATC1 //RW ok
#define GLCD_EN LATAbits.LATA5 //EN or E ???
#define GLCD_RS LATCbits.LATC2 //RS or RST ???

#define GLCD_TRIS_DATA TRISB
#define GLCD_TRIS_CS1 TRISCbits.TRISC7 //GCS1 ok
#define GLCD_TRIS_CS2 TRISCbits.TRISC6 //GCS2 ok
#define GLCD_TRIS_DI TRISCbits.TRISC0 //RS or DI ???
#define GLCD_TRIS_RW TRISCbits.TRISC1 //RW ok
#define GLCD_TRIS_EN TRISAbits.TRISA5 //E or EN ???
#define GLCD_TRIS_RS TRISCbits.TRISC2 //RST or RS or DI ???
 
^ I was confused about the very same thing.

In my code,
DI : Data/Instruction
RS : Reset
EN : Enable

By the way, what made you confuse about the "EN" abbreviation? I don't remember anywhere else where "E" or "EN" is used.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top