ejemplo del uso lcd grafico 128 64

48
CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 1 de 10 PROXECTO PIC 18F452 CON LCD GRÁFICO 128x64 T6963C E TECLADO 4x4 MANUEL RODRÍGUEZ PADRON

Upload: gcirvini

Post on 26-Dec-2014

574 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 1 de 10

PROXECTO PIC 18F452 CON LCD GRÁFICO 128x64 T6963C

E TECLADO 4x4

MANUEL RODRÍGUEZ PADRON

Page 2: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 2 de 10

1.- O MICROCONTROLADOR: PIC 18F452. O micro que utilizaremos será o PIC 18F452:

Aquí podemos ver o PIC aínda no seu embalaxe de compra

Aquí xa o vemos montado sobre a placa proto (con zócalo pois hai que quitalo para programalo)

Page 3: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 3 de 10

A continuación mostro a tabla de rexistros deste PIC:

2.- OS SENSORES DE TEMPERATURA: DS1624. Este circuito de Dallas funciona coa tecnoloxía I2C, perfecto para traballar co PIC 18F452, que dispón desta tecnoloxía (patillas 18 e 23).

Page 4: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 4 de 10

A continuación mostro un gráfico descriptivo de cómo funciona o protocolo I2C con este circuito.

A dirección deste circuito é :

1 0 0 1 A2 A1 A0 WR

Sendo A2, A1 e A0 configurable. Para o primeiro Ds1624 (temp. exterior) temos: I2C write:

1 0 0 1 0 0 0 0 I2C read:

1 0 0 1 0 0 0 1 Para o segundo Ds1624 (temp. interior) temos: I2C write:

1 0 0 1 0 0 1 0 I2C read:

1 0 0 1 0 0 1 1

Un detalle da placa cos dous sensores,a memoria EEPROM e o PCF8583

Page 5: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 5 de 10

3.- A MEMORIA EEPROM: 24LC256. Nesta memoria é onde se almacenarán todos os gráficos que vai a menxar o PIC para representar na pantalla LCD.

Os pins A0, A1 e A2 son para configurar a dirección da memoria no bus I2C, que ten a seguinte configuración:

Page 6: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 6 de 10

No noso caso: Memoria write:

1 0 1 0 0 0 0 0 Memoria read:

1 0 1 0 0 0 0 1 Todo esto está recollido no driver 24256.c que ven co CCS software. 4.- O RELOXIO CALENDARIO: PCF8583. Este reloxio calendario de Philips ten os seguintes diagramas de pins:

Imaxen da representación do reloxio analóxico

Page 7: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 7 de 10

Os rexistros teñen as seguintes direccións

A dirección no bus I2C é a seguinte:

O motivo de que teña A0 é para que non coincida a dirección coa da EEPROM, polo que nos configuramos as direccións da seguinte maneira: Memoria write (0xA2):

1 0 1 0 0 0 1 0 Memoria read (0xA3):

1 0 1 0 0 0 1 1

Page 8: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 8 de 10

Detalle da placa onde se ve o reloxio co cristal de 32.768khz

Tipo de conexión do reloxio

O condensador deste reloxio que se pon xunto co cristal é o mesmo que se pon co cristal do PIC, é decir de 27pF.

Page 9: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 9 de 10

5.- O LCD 128X64

Page 10: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 10 de 10

6.- O PROGRAMA PRINCIPAL /* **************************************************************************************************************************************************************** * uso dun T6963C 128x64 * * * * * * Dia:20/02/06 : Version 0.0 (20 Febreiro 2006) **************************************************************************************************************************************************************** * DESCRIPCION * * * ******************************************************************************** */ #include <18F452.h> #fuses XT, NOPROTECT, NOPUT, NOWDT, NOBROWNOUT, NOLVP, NOCPD #use delay(clock=4000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) #use fast_io(A) #use fast_io(B) #include "string.h" #include "math.h" #include "t6963_18F452.h" #include "t6963.c" #include <kbd_lib.c> // driver para teclado 4x4 #use I2C(MASTER, SDA=PIN_C4, SCL=PIN_C3, fast) #define EEPROM_SDA PIN_C4 #define EEPROM_SCL PIN_C3 #include <24256.c> #define simbolo_grados 0b11011111 #define simbolo_coma 0b00101100 #define I2CWRITE 0b10010000 #define I2CREAD 0b10010001 #define I2CWRITE2 0b10010010 #define I2CREAD2 0b10010011 #define PCF8583_WRITE_ADDRESS 0xa2 // direccion escribir PCF8583 #define PCF8583_READ_ADDRESS 0xa3 // direccion leer PCF8583 #define bcd2bin(val) ((val)&15)+((val)>>4)*10 // subrutina para pasar de bcd a binario // esto e porque o pcf8583 almacena os datos en bcd #define bin2bcd(val) (((val)/10)<<4)+(val)%10 // subrutina para pasar de binario a bcd #define DS1624_CMD_ACCESSCONFIG 0xAC

Page 11: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 11 de 11

#define DS1624_CMD_INITIATECONVERT 0xEE #define DS1624_CMD_ACCESSTEMPERATURE 0xAA #define DS1624_CMD_ACCESSMEMORY 0x17 # byte port_a=6 # byte port_b=6 int mi1,mi2,mes1,mes2; float tempe,tempe2; /* ****************************************************************************************** * PROTOTYPES ****************************************************************************************** */ void GDispDefIcon32X32(unsigned int8 icon_id); void GDispIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 icon_id); void GDispSelIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 mode); void GDispDefCGPat(void); void GDispCGPat2(unsigned int16 row, unsigned int16 col); void GDispDefCGPat2(void); void GDispCGPat(unsigned int16 row, unsigned int16 col); void GDispDefCGPat3(void); void GDispDefCGPat4(void); /* ****************************************************************************************** */ float convertir (int valor1) { float dec; switch(valor1) { case 248: dec=0.98; break; case 240: dec=0.94; break; case 232: dec=0.90; break; case 224: dec=0.87; break; case 216: dec=0.83; break; case 208: dec=0.80; break; case 200: dec=0.77; break; case 192: dec=0.75; break; case 184: dec=0.72; break; case 176: dec=0.70; break; case 168: dec=0.68; break; case 160: dec=0.66; break; case 152: dec=0.62; break; case 144: dec=0.60; break; case 136: dec=0.58; break; case 128: dec=0.55; break; case 120: dec=0.53; break; case 112: dec=0.50; break; case 104: dec=0.48; break; case 96: dec=0.44; break; case 88: dec=0.40; break; case 80: dec=0.37; break; case 72: dec=0.34; break; case 64: dec=0.30; break;

Page 12: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 12 de 12

case 56: dec=0.28; break; case 48: dec=0.23; break; case 40: dec=0.20; break; case 32: dec=0.17; break; case 24: dec=0.13; break; case 16: dec=0.10; break; case 8: dec=0.05; break; case 0: dec=0.00; break; } return (dec); } void i2c_conversion() { i2c_start(); i2c_write(I2CWRITE); i2c_write(DS1624_CMD_INITIATECONVERT); delay_ms(20); i2c_start(); i2c_write(I2CWRITE2); i2c_write(DS1624_CMD_INITIATECONVERT); i2c_stop(); } void i2c_ds1624_inicia() { i2c_start(); i2c_write(I2CWRITE); i2c_write(DS1624_CMD_ACCESSCONFIG); i2c_write(0b01001010); delay_ms(20); i2c_start(); i2c_write(I2CWRITE2); i2c_write(DS1624_CMD_ACCESSCONFIG); i2c_write(0b01001010); i2c_stop(); delay_ms(20); i2c_conversion(); } float i2c_ds1624_leer_temp_c() //lee temp. exterior { float dec,valor; i2c_start(); i2c_write(I2CWRITE); i2c_write(DS1624_CMD_ACCESSTEMPERATURE); i2c_start(); i2c_write(I2CREAD); mes2=i2c_read(); mes1=i2c_read(0); dec=convertir(mes1); i2c_stop(); valor=mes2+dec;

Page 13: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 13 de 13

if (mes2>127) { valor=valor-256; } return (valor); } float i2c_ds1624_leer_temp_c2() //lee temp. interior { float dec,valor; i2c_start(); i2c_write(I2CWRITE2); i2c_write(DS1624_CMD_ACCESSTEMPERATURE); i2c_start(); i2c_write(I2CREAD2); mi2=i2c_read(); mi1=i2c_read(0); dec=convertir(mi1); i2c_stop(); valor=mi2+dec; if (mi2>127) { valor=valor-256; } return (valor); } void write_pcf(byte address,byte data) { i2c_start(); i2c_write(PCF8583_WRITE_ADDRESS); i2c_write(address); i2c_write(data); i2c_stop(); } //lee datos no calendario byte read_pcf(byte address) { byte data; i2c_start(); i2c_write(PCF8583_WRITE_ADDRESS); i2c_write(address); i2c_start(); i2c_write(PCF8583_READ_ADDRESS); data=i2c_read(0); i2c_stop(); return(data); } void dibujalinea(float t1,float t2,byte pos1,byte pos2) { byte c; if (t1>t2) { for (c=3; c < 14; c++) { GDispSetPixel(c,pos2,WHITE); } for (c=56; c < 69; c++) { GDispSetPixel(c,pos2,BLACK);

Page 14: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 14 de 14

} for (c=3; c < 14; c++) { GDispSetPixel(c,pos1,WHITE); } for (c=56; c < 69; c++) { GDispSetPixel(c,pos1,BLACK); } } else if (t1<t2) { for (c=3; c < 14; c++) { GDispSetPixel(c,pos2,BLACK); } for (c=56; c < 69; c++) { GDispSetPixel(c,pos2,WHITE); } for (c=3; c < 14; c++) { GDispSetPixel(c,pos1,BLACK); } for (c=56; c < 69; c++) { GDispSetPixel(c,pos1,WHITE); } } } void dibujalinea2(float t1,float t2,byte pos1) { byte c; for (c=4; c < 31; c++) { GDispSetPixel(pos1,c,BLACK); } if (t1>t2) { GDispSetPixel(pos1-1,29,WHITE); GDispSetPixel(pos1-1,28,WHITE); GDispSetPixel(pos1-2,27,WHITE); GDispSetPixel(pos1+1,29,WHITE); GDispSetPixel(pos1+1,28,WHITE); GDispSetPixel(pos1+2,27,WHITE); GDispSetPixel(pos1-1,5,BLACK); GDispSetPixel(pos1-1,6,BLACK); GDispSetPixel(pos1-2,7,BLACK); GDispSetPixel(pos1+1,5,BLACK); GDispSetPixel(pos1+1,6,BLACK); GDispSetPixel(pos1+2,7,BLACK); } else if (t1<t2) { GDispSetPixel(pos1-1,29,BLACK); GDispSetPixel(pos1-1,28,BLACK); GDispSetPixel(pos1-2,27,BLACK); GDispSetPixel(pos1+1,29,BLACK);

Page 15: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 15 de 15

GDispSetPixel(pos1+1,28,BLACK); GDispSetPixel(pos1+2,27,BLACK); GDispSetPixel(pos1-1,5,WHITE); GDispSetPixel(pos1-1,6,WHITE); GDispSetPixel(pos1-2,7,WHITE); GDispSetPixel(pos1+1,5,WHITE); GDispSetPixel(pos1+1,6,WHITE); GDispSetPixel(pos1+2,7,WHITE); } } //convirte os datos char do teclado //en un dato tipo byte byte devolv (byte posx,byte posy) { byte devolve,ant,valor3,pos; char first; ant=0; pos=posy; do { first=kbd_getc(); if(first!=0) { if(first !='*') { switch (first){ case '0':valor3=0;break; case '1':valor3=1;break; case '2':valor3=2;break; case '3':valor3=3;break; case '4':valor3=4;break; case '5':valor3=5;break; case '6':valor3=6;break; case '7':valor3=7;break; case '8':valor3=8;break; case '9':valor3=9;break; } devolve=ant*10+valor3; ant=valor3; GDispGoto(posx,pos); pos=pos+1; GDispChar(first); delay_ms(30); } } }while (first !='*'); return(devolve); } void glcd_line(int x1, int y1, int x2, int y2,int color) { signed int x, y, addx, addy, dx, dy; signed long P; int i; if (x2!=999) { dx = abs((signed int)(x2 - x1)); dy = abs((signed int)(y2 - y1)); x = x1;

Page 16: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 16 de 16

y = y1; if(x1 > x2) addx = -1; else addx = 1; if(y1 > y2) addy = -1; else addy = 1; if(dx >= dy) { P = 2*dy - dx; for(i=0; i<=dx; ++i) { if (color==1) GDispSetPixel(x,y,BLACK); else if (color==0) GDispSetPixel(x,y,WHITE); if(P < 0) { P += 2*dy; x += addx; } else { P += 2*dy - 2*dx; x += addx; y += addy; } } } else { P = 2*dx - dy; for(i=0; i<=dy; ++i) { if (color==1) GDispSetPixel(x,y,BLACK); else if (color==0) GDispSetPixel(x,y,WHITE); if(P < 0) { P += 2*dx; y += addy; } else { P += 2*dx - 2*dy; x += addx; y += addy; } } } } } ///////////////////////////////////////////////////////////////////////////// void main() { char str[7] ; char str2[7]; char hor[3],min[3],seg[3],mes[3],dia[3]; char dd[] = "Tªmini:"; char me1[] = "Configuracion hora";

Page 17: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 17 de 17

char me23[] = "1-Temperaturas"; char me3[] = "2-Max. y min."; char me4[] = "3-Config. tempo"; char me5[] = "4-Reloxio"; char me6[] = "5-Menu xeral"; char me7[] = "Opcion:"; char first,pista; char dm[] = "Tªmaxi:"; float tant,tant2,valor,valor2,min1,min2,dec,max1; int t1,t2,mem1,mem2,mem4,mem3,grabext,grabint,mim1,mim2,py,ptx,pty,pantx,panty; byte pt2x,pt3x,pt2y,pt3y,pant2x,pant2y,pant3x,pant3y,dhora; byte dat1,dat2,dat3,dat4,dat5,dat6,dat7,fil,colu,horas,minuto,dias,meses,c,relox; byte conf,xeral,temp,menu,opcion,unavez,dosvez,tresvez,tempo; i2c_ds1624_inicia(); set_tris_A(0b000001); port_b_pullups(TRUE); /* write_pcf(0x00,0x00); write_pcf(0x02,bin2bcd(30));//segundos inicial write_pcf(0x03,bin2bcd(59));//minuto inicial write_pcf(0x04,bin2bcd(23));//hora inicial write_pcf(0x05,bin2bcd(19));//dia incial write_pcf(0x06,bin2bcd(0x09));//mes inicial i2c_stop(); */ GDispInit(); //T6963C display initialization FontSize = 8; //8 font mode GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON GDispClrTxt(); GDispClrGrh(); //Clear the text area GDispDefCGPat2(); //read data from eeprom, write to LCD's CG RAM for for DOG picture GDispCGPat2(0, 0); delay_ms(2000); tant=0; tempe=0; tempe2=0; min1= 45; max1=-10; grabext=0; grabint=0; conf=0; temp=0; menu=1; relox=0; while(1) { tant=tempe2; tant2=tempe; tempe=i2c_ds1624_leer_temp_c(); tempe2=i2c_ds1624_leer_temp_c2(); dat1=read_pcf(0x02); dat2=read_pcf(0x03); dat3=read_pcf(0x04); dat4=read_pcf(0x05); dat5=read_pcf(0x06); if (tempe<min1) {

Page 18: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 18 de 18

min1=tempe; grabext=1; } if (tempe>max1) { max1=tempe; grabint=1; } //si se pulsa o pulsador if (input(PIN_A0)==1) { temp=0; conf=0; xeral=0; menu=1; relox=0; } // menu de configuracion da hora if (conf==1) { conf=0; menu=1; GDispClrTxt(); GDispClrGrh(); GDispPixFontAt(2,2,&me1[0],1,BLACK); GDispGoto(2,0); GDispChar('H'); GDispGoto(2,1); GDispChar('o'); GDispGoto(2,2); GDispChar('r'); GDispGoto(2,3); GDispChar('a'); GDispGoto(2,4); GDispChar(':'); horas=devolv(2,5); GDispGoto(3,0); GDispChar('M'); GDispGoto(3,1); GDispChar('i'); GDispGoto(3,2); GDispChar('n'); GDispGoto(3,3); GDispChar('u'); GDispGoto(3,4); GDispChar('t'); GDispGoto(3,5); GDispChar('o'); GDispGoto(3,6); GDispChar(':'); minuto=devolv(3,7); GDispGoto(4,0); GDispChar('D'); GDispGoto(4,1); GDispChar('i'); GDispGoto(4,2); GDispChar('a'); GDispGoto(4,3); GDispChar(':'); dias=devolv(4,4); GDispGoto(5,0); GDispChar('M'); GDispGoto(5,1);

Page 19: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 19 de 19

GDispChar('e'); GDispGoto(5,2); GDispChar('s'); GDispGoto(5,3); GDispChar(':'); meses=devolv(5,4); write_pcf(0x00,0x00); write_pcf(0x02,bin2bcd(0x00));//segundos inicial write_pcf(0x03,bin2bcd(minuto));//minuto inicial write_pcf(0x04,bin2bcd(horas));//hora inicial write_pcf(0x05,bin2bcd(dias));//minuto inicial write_pcf(0x06,bin2bcd(meses));//hora inicial i2c_stop(); GDispClrTxt(); GDispClrGrh(); GDispDefCGPat(); //read data from eeprom, write to LCD's CG RAM for for DOG picture GDispCGPat(0, 0); } if (temp==1) { if (unavez==0) { GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON GDispClrTxt(); GDispClrGrh(); //Clear the text area GDispDefCGPat3(); //read data from eeprom, write to LCD's CG RAM for for DOG picture GDispCGPat2(0, 0); unavez=1; } sprintf(str,"%f",tempe); sprintf(str2,"%f",tempe2); sprintf(hor,"%u",bcd2bin(dat3)); sprintf(min,"%u",bcd2bin(dat2)); sprintf(seg,"%u",bcd2bin(dat1)); sprintf(dia,"%u",bcd2bin(dat4)); sprintf(mes,"%u",bcd2bin(dat5)); // temperatura exterior i2c_ds1624_inicia(); GDispGoto(7,0); GDispChar(str[0]); GDispGoto(7,1); GDispChar(str[1]); GDispGoto(7,2); GDispChar(str[2]); GDispGoto(7,3); GDispChar(str[3]); //temperatura interior GDispGoto(7,11); GDispChar(str2[0]); GDispGoto(7,12); GDispChar(str2[1]); GDispGoto(7,13); GDispChar(str2[2]); GDispGoto(7,14); GDispChar(str2[3]); for (c=6; c < 39; c++) {

Page 20: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 20 de 20

GDispSetPixel(20,c,WHITE); } py=31-(floor((mes2*8)/10)); for (c=py; c < 39; c++) { GDispSetPixel(20,c,BLACK); } for (c=6; c < 39; c++) { GDispSetPixel(103,c,WHITE); } py=31-(floor((mi2*8)/10)); for (c=py; c < 39; c++) { GDispSetPixel(103,c,BLACK); } dibujalinea2(tempe2,tant,77); dibujalinea2(tempe ,tant2,48); temp=1; } if (relox==1) { if (tresvez==0) { GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON GDispClrTxt(); GDispClrGrh(); //Clear the text area GDispDefCGPat4(); //read data from eeprom, write to LCD's CG RAM for for DOG picture GDispCGPat2(0, 0); //Clear the text area pantx=999; tresvez=1; } sprintf(hor,"%u",bcd2bin(dat3)); if ((hor[1]<'0') || (hor[1]>'9')) { hor[1]=hor[0];hor[0]='0';} GDispGoto(0,0); GDispChar(hor[0]); GDispGoto(0,1); GDispChar(hor[1]); GDispGoto(0,2); GDispChar(':'); sprintf(min,"%u",bcd2bin(dat2)); if ((min[1]<'0') || (min[1]>'9')) { min[1]=min[0];min[0]='0';} GDispGoto(0,3); GDispChar(min[0]); GDispGoto(0,4); GDispChar(min[1]); GDispGoto(0,5); GDispChar(':'); sprintf(seg,"%u",bcd2bin(dat1)); if ((seg[1]<'0') || (seg[1]>'9')) { seg[1]=seg[0];seg[0]='0';}

Page 21: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 21 de 21

GDispGoto(0,6); GDispChar(seg[0]); GDispGoto(0,7); GDispChar(seg[1]); //calcula posicion segundos if(bcd2bin(dat1)<16) { c=90-(6*(bcd2bin(dat1))); ptx=89+floor(24*cos(c*PI/180)); pty=32-floor(24*sin(c*PI/180)); } else if((bcd2bin(dat1)>15) && ((bcd2bin(dat1)<31))) { c=(6*(bcd2bin(dat1)))-90; ptx=89+floor(24*cos(c*PI/180)); pty=32+floor(24*sin(c*PI/180)); } else if((bcd2bin(dat1)>30) && ((bcd2bin(dat1)<46))) { c=90-((6*(bcd2bin(dat1)))-180); ptx=89-floor(24*cos(c*PI/180)); pty=32+floor(24*sin(c*PI/180)); } else if((bcd2bin(dat1)>45) && ((bcd2bin(dat1)<60))) { c=(6*(bcd2bin(dat1)))-270; ptx=89-floor(24*cos(c*PI/180)); pty=32-floor(24*sin(c*PI/180)); } //calcula posicion minutos if(bcd2bin(dat2)<16) { c=90-(6*(bcd2bin(dat2))); pt2x=89+floor(18*cos(c*PI/180)); pt2y=32-floor(18*sin(c*PI/180)); } else if((bcd2bin(dat2)>15) && ((bcd2bin(dat2)<31))) { c=(6*(bcd2bin(dat2)))-90; pt2x=89+floor(18*cos(c*PI/180)); pt2y=32+floor(18*sin(c*PI/180)); } else if((bcd2bin(dat2)>30) && ((bcd2bin(dat2)<46))) { c=90-((6*(bcd2bin(dat2)))-180); pt2x=89-floor(18*cos(c*PI/180)); pt2y=32+floor(18*sin(c*PI/180)); } else if((bcd2bin(dat2)>45) && ((bcd2bin(dat2)<60))) { c=(6*(bcd2bin(dat2)))-270; pt2x=89-floor(18*cos(c*PI/180)); pt2y=32-floor(18*sin(c*PI/180)); } //calcula posicion horas dhora=bcd2bin(dat3); if (bcd2bin(dat3)>12) dhora=bcd2bin(dat3)-12; if (dhora==12) dhora=0; if(dhora<4) { c=90-(30*(dhora));

Page 22: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 22 de 22

pt3x=89+floor(10*cos(c*PI/180)); pt3y=32-floor(10*sin(c*PI/180)); } else if((dhora>3) && ((dhora<7))) { c=(30*(dhora))-90; pt3x=89+floor(10*cos(c*PI/180)); pt3y=32+floor(10*sin(c*PI/180)); } else if((dhora>6) && ((dhora<10))) { c=90-((30*(dhora))-180); pt3x=89-floor(10*cos(c*PI/180)); pt3y=32+floor(10*sin(c*PI/180)); } else if((dhora>9) && ((dhora<12))) { c=(30*(dhora))-270; pt3x=89-floor(10*cos(c*PI/180)); pt3y=32-floor(10*sin(c*PI/180)); } glcd_line(89,32,pantx,panty,0); glcd_line(89,32,ptx,pty,1); glcd_line(89,32,pant2x,pant2y,0); glcd_line(89,32,pt2x,pt2y,1); glcd_line(89,32,pant3x,pant3y,0); glcd_line(89,32,pt3x,pt3y,1); pantx=ptx; panty=pty; pant2x=pt2x; pant2y=pt2y; pant3x=pt3x; pant3y=pt3y; } if (grabext==1)//graba a temperatura exterior minima //ma memoria eeprom { dat1=read_pcf(0x02); dat2=read_pcf(0x03); dat3=read_pcf(0x04); dat4=read_pcf(0x05); dat5=read_pcf(0x06); init_ext_eeprom(); write_ext_eeprom(5000, mes1); write_ext_eeprom(5001, mes2); write_ext_eeprom(5004, dat1); write_ext_eeprom(5005, dat2); write_ext_eeprom(5006, dat3); write_ext_eeprom(5007, dat4); write_ext_eeprom(5008, dat5); delay_ms(300); grabext=0; } if (grabint==1)//graba a temperatura exterior maxima //ma memoria eeprom { dat1=read_pcf(0x02);

Page 23: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 23 de 23

dat2=read_pcf(0x03); dat3=read_pcf(0x04); dat4=read_pcf(0x05); dat5=read_pcf(0x06); init_ext_eeprom(); write_ext_eeprom(5002, mes1); write_ext_eeprom(5003, mes2); write_ext_eeprom(5009, dat1); write_ext_eeprom(5010, dat2); write_ext_eeprom(5011, dat3); write_ext_eeprom(5012, dat4); write_ext_eeprom(5013, dat5); delay_ms(300); grabint=0; } //menu xeneral con todos os datos if (xeral==1) { temp=0; menu=0; if (dosvez==0) { GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON GDispClrTxt(); GDispClrGrh(); GDispDefCGPat(); //read data from eeprom, write to LCD's CG RAM for for DOG picture GDispCGPat(0, 0); dosvez=1; } sprintf(str,"%f",tempe); sprintf(str2,"%f",tempe2); sprintf(hor,"%u",bcd2bin(dat3)); sprintf(min,"%u",bcd2bin(dat2)); sprintf(seg,"%u",bcd2bin(dat1)); sprintf(dia,"%u",bcd2bin(dat4)); sprintf(mes,"%u",bcd2bin(dat5)); // temperatura exterior i2c_ds1624_inicia(); GDispGoto(2,2); GDispChar(str[0]); GDispGoto(2,3); GDispChar(str[1]); GDispGoto(2,4); GDispChar(str[2]); GDispGoto(2,5); GDispChar(str[3]); //temperatura interior GDispGoto(5,2); GDispChar(str2[0]); GDispGoto(5,3); GDispChar(str2[1]); GDispGoto(5,4); GDispChar(str2[2]); GDispGoto(5,5); GDispChar(str2[3]); //Mostrar hora if ((hor[1]<'0') || (hor[1]>'9')) { hor[1]=hor[0];hor[0]='0';} GDispGoto(7,0);

Page 24: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 24 de 24

GDispChar(hor[0]); GDispGoto(7,1); GDispChar(hor[1]); GDispGoto(7,2); GDispChar(':'); if ((min[1]<'0') || (min[1]>'9')) { min[1]=min[0];min[0]='0';} GDispGoto(7,3); GDispChar(min[0]); GDispGoto(7,4); GDispChar(min[1]); GDispGoto(7,5); GDispChar(':'); if ((seg[1]<'0') || (seg[1]>'9')) { seg[1]=seg[0];seg[0]='0';} GDispGoto(7,6); GDispChar(seg[0]); GDispGoto(7,7); GDispChar(seg[1]); //Mostra data if ((dia[1]<'0') || (dia[1]>'9')) { dia[1]=dia[0];dia[0]='0';} GDispGoto(7,10); GDispChar(dia[0]); GDispGoto(7,11); GDispChar(dia[1]); GDispGoto(7,12); GDispChar('-'); if ((mes[1]<'0') || (mes[1]>'9')) { mes[1]=mes[0];mes[0]='0';} GDispGoto(7,13); GDispChar(mes[0]); GDispGoto(7,14); GDispChar(mes[1]); // lee a temperatura minima na memoria init_ext_eeprom(); mem1=read_ext_eeprom(5001); mem2=read_ext_eeprom(5000); dat1=read_ext_eeprom(5004); dat2=read_ext_eeprom(5005); dat3=read_ext_eeprom(5006); dat4=read_ext_eeprom(5007); dat5=read_ext_eeprom(5008); dec=convertir(mem2); valor=mem1+dec; if (mem1>127) { valor=valor-256; } // lee a temperatura maxima na memoria init_ext_eeprom(); Mim1=read_ext_eeprom(5003); mim2=read_ext_eeprom(5002); dat1=read_ext_eeprom(5009); dat2=read_ext_eeprom(5010); dat3=read_ext_eeprom(5011); dat4=read_ext_eeprom(5012); dat5=read_ext_eeprom(5013); dec=convertir(mim2); valor2=mim1+dec; if (mim1>127)

Page 25: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 25 de 25

{ valor2=valor2-256; } //amosa a temperatura minima GDispPixFontAt(75,0,&dd[0],1,BLACK); sprintf(str,"%f",valor); GDispGoto(1,9); GDispChar(str[0]); GDispGoto(1,10); GDispChar(str[1]); GDispGoto(1,11); GDispChar(str[2]); GDispGoto(1,12); GDispChar(str[3]); sprintf(hor,"%u",bcd2bin(dat3)); sprintf(min,"%u",bcd2bin(dat2)); if ((hor[1]<'0') || (hor[1]>'9')) { hor[1]=hor[0];hor[0]='0';} GDispGoto(2,9); GDispChar(hor[0]); GDispGoto(2,10); GDispChar(hor[1]); GDispGoto(2,11); GDispChar(':'); if ((min[1]<'0') || (min[1]>'9')) { min[1]=min[0];min[0]='0';} GDispGoto(2,12); GDispChar(min[0]); GDispGoto(2,13); GDispChar(min[1]); //amosa a temperatura maxima GDispPixFontAt(75,24,&dm[0],1,BLACK); sprintf(str,"%f",valor2); GDispGoto(4,9); GDispChar(str[0]); GDispGoto(4,10); GDispChar(str[1]); GDispGoto(4,11); GDispChar(str[2]); GDispGoto(4,12); GDispChar(str[3]); sprintf(hor,"%u",bcd2bin(dat3)); sprintf(min,"%u",bcd2bin(dat2)); if ((hor[1]<'0') || (hor[1]>'9')) { hor[1]=hor[0];hor[0]='0';} GDispGoto(5,9); GDispChar(hor[0]); GDispGoto(5,10); GDispChar(hor[1]); GDispGoto(5,11); GDispChar(':'); if ((min[1]<'0') || (min[1]>'9')) { min[1]=min[0];min[0]='0';} GDispGoto(5,12); GDispChar(min[0]); GDispGoto(5,13); GDispChar(min[1]); dibujalinea(tempe2,tant,43,44); dibujalinea(tempe ,tant2,19,20); }

Page 26: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 26 de 26

if (menu==1) { menu=0; unavez=0; dosvez=0; tresvez=0; relox=0; GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON GDispClrTxt(); GDispClrGrh(); GDispPixFontAt(2,2,&me23[0],1,BLACK); GDispPixFontAt(2,11,&me3[0],1,BLACK); GDispPixFontAt(2,20,&me4[0],1,BLACK); GDispPixFontAt(2,28,&me5[0],1,BLACK); GDispPixFontAt(2,37,&me6[0],1,BLACK); GDispPixFontAt(2,48,&me7[0],1,BLACK); opcion=devolv(6,6); if (opcion==1) temp=1; else if (opcion==3) conf=1; else if (opcion==4) relox=1; else if (opcion==5) xeral=1; } } }//end of main() /* ********************************************************************************************************* */ /* ********************************************************************************************************* * SET CUSTOM DEFINED ICON OF 32x32 MATRIX FROM EEPROM DATA * * Description : This function assigns LCD's CG RAM with a custom icon pattern of 32x32 matrix with * ********************************************************************************************************* */ void GDispDefIcon32X32(unsigned int8 icon_id) { unsigned int16 i, col, row; for(row=0; row<4; row++) { for(col=0; col<4; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(32*row + i*4 + col + (unsigned int16)icon_id*128); } GDispDefCGChar(col+4*row+icon_id*16,&CGBuffer[0]); } }

Page 27: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 27 de 27

} /* ********************************************************************************************************* * DISPLAY AN ICON OF 32x32 MATRIX AT ROW, COL FROM CG RAM * * Description : This function shows a pre-defined 32x32 ICON in CG RAM at (row, col) coordinates * Arguments : 'icon_id' is the identifier for the pattern created. Range of 'id' is 0...8 in 8 font * 'row' row = 0...(MAX_ROW_PIXEL/8 - 1), the cell number in 8 bits height * 'col' col = 0...(COLUMN-1), is the column position in font width (6/8 font) * Returns : none * Notes : ********************************************************************************************************* */ void GDispIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 icon_id) { unsigned int8 id=0; unsigned int16 row_cnt, col_cnt; id = id + icon_id*16; GDispGoto(row, col); for(row_cnt = row; row_cnt < (row+4); row_cnt++) { for(col_cnt = col; col_cnt < (col+4); col_cnt++) { GDispCGCharAt(row_cnt, col_cnt, id++); } } } /* ********************************************************************************************************* * HIGHLIGHT AN ICON OF 32x32 MATRIX AT ROW, COL * * Description : This function highlight an icon at a position row, col. * Arguments : 'mode' = ATTR_REVERSE, ATTR_INHIBIT, ATTR_BLINK_REVERSE, ATTR_BLINK_INHIBIT, * ATTR_NORMAL, ATTR_BLINK (all modes defined under t6963.h file) * 'row' row = 0...(MAX_ROW_PIXEL/8 - 1), the cell number in 8 bits height * 'col' col = 0...(COLUMN-1), is the column position in font width (6/8 font) * Returns : none * Notes : ********************************************************************************************************* */ void GDispSelIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 mode) { unsigned int16 row_cnt, col_cnt; for(row_cnt = row; row_cnt < (row+4); row_cnt++)

Page 28: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 28 de 28

{ for(col_cnt = col; col_cnt < (col+4); col_cnt++) { GDispSetAttrb(row_cnt, col_cnt, mode); } } } /* ********************************************************************************************************* * SET CUSTOM DEFINED CG RAM CHARACTERS OF SIZE X*Y MATRIX * * Description : This function assigns a custom pattern of X*Y matrix. In this case for Dog_rowx[] * x = 1 to 8, 9x8 CG RAM characters required * Arguments : none * Returns : none * Notes : ********************************************************************************************************* */ void GDispDefCGPat(void) { unsigned int16 i, row, col, id; for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+384+col*8); } GDispDefCGChar(col,&CGBuffer[0]); } for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+456+col*8); } GDispDefCGChar(col+9,&CGBuffer[0]); } for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+528+col*8); } GDispDefCGChar(col+18,&CGBuffer[0]); } for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+600+col*8); } GDispDefCGChar(col+27,&CGBuffer[0]); } for(col=0; col<9; col++) {

Page 29: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 29 de 29

for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+672+col*8); } GDispDefCGChar(col+36,&CGBuffer[0]); } for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+744+col*8); } GDispDefCGChar(col+45,&CGBuffer[0]); } for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+816+col*8); } GDispDefCGChar(col+54,&CGBuffer[0]); } for(col=0; col<9; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+888+col*8); } GDispDefCGChar(col+63,&CGBuffer[0]); } } void GDispDefCGPat2(void) { unsigned int16 i, row, col, id; for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1000+col*8); } GDispDefCGChar(col,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1128+col*8); } GDispDefCGChar(col+16,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1256+col*8);

Page 30: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 30 de 30

} GDispDefCGChar(col+32,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1384+col*8); } GDispDefCGChar(col+48,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1512+col*8); } GDispDefCGChar(col+64,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1640+col*8); } GDispDefCGChar(col+80,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1768+col*8); } GDispDefCGChar(col+96,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+1896+col*8); } GDispDefCGChar(col+112,&CGBuffer[0]); } } void GDispDefCGPat3(void) { unsigned int16 i, row, col, id; for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3000+col*8); } GDispDefCGChar(col,&CGBuffer[0]); }

Page 31: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 31 de 31

for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3128+col*8); } GDispDefCGChar(col+16,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3256+col*8); } GDispDefCGChar(col+32,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3384+col*8); } GDispDefCGChar(col+48,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3512+col*8); } GDispDefCGChar(col+64,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3640+col*8); } GDispDefCGChar(col+80,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3768+col*8); } GDispDefCGChar(col+96,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+3896+col*8); } GDispDefCGChar(col+112,&CGBuffer[0]); }

Page 32: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 32 de 32

} void GDispDefCGPat4(void) { unsigned int16 i, row, col, id; for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6000+col*8); } GDispDefCGChar(col,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6128+col*8); } GDispDefCGChar(col+16,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6256+col*8); } GDispDefCGChar(col+32,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6384+col*8); } GDispDefCGChar(col+48,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6512+col*8); } GDispDefCGChar(col+64,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6640+col*8); } GDispDefCGChar(col+80,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++)

Page 33: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 33 de 33

{ CGBuffer[i] = read_ext_eeprom(i+6768+col*8); } GDispDefCGChar(col+96,&CGBuffer[0]); } for(col=0; col<16; col++) { for(i=0;i<8;i++) { CGBuffer[i] = read_ext_eeprom(i+6896+col*8); } GDispDefCGChar(col+112,&CGBuffer[0]); } } /* ********************************************************************************************************* * DISPLAY CUSTOM DEFINED CG RAM CHARACTERS OF SIZE X*Y MATRIX * * Description : This function displays a custom defined pattern of X*Y matrix from CG RAM. * In this case for Dog_rowx[] data that has been stored by previous project * x = 1 to 8, 9x8 CG RAM characters required * Arguments : none * Returns : none * Notes : ********************************************************************************************************* */ void GDispCGPat(unsigned int16 row, unsigned int16 col) { unsigned int16 id=0, row_cnt, col_cnt; GDispGoto(row, col); for(row_cnt = row; row_cnt < (row+8); row_cnt++) { for(col_cnt = col; col_cnt < (col+9); col_cnt++) { GDispCGCharAt(row_cnt, col_cnt, id++); } } } void GDispCGPat2(unsigned int16 row, unsigned int16 col) { unsigned int16 id=0, row_cnt, col_cnt; GDispGoto(row, col); for(row_cnt = row; row_cnt < (row+8); row_cnt++) { for(col_cnt = col; col_cnt < (col+16); col_cnt++) { GDispCGCharAt(row_cnt, col_cnt, id++); } } }

Page 34: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 34 de 34

6.- OS MÓDULOS: - modulo 1: eeprom.c /* *********************************************************************************************** * CONTROL CONSOLE EXERCISE * Use a T6963C 128x64 monochrome LCD for display. * * * File name : eeprom.c * IDE: Microchip's MPLAB v7.01 * Project name: eepromdat.mcp * CCS C complier PCM version 3.170 * Programmer : John Leung, eMed Technologies Ltd. Hong Kong * Web presence : www.emed-technologies.com * Date : Version 0.0, 5th Jan 2006 *********************************************************************************************** * DESCRIPTION * * Graba na memoria eeprom os iconos empregados no LCD *********************************************************************************************** */ #include <18f452.h> #fuses HS,NOWDT,NOPROTECT,NOLVP #use delay(clock=4000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) #include "Dog.h" #include "icons.h" #include "ico_temp.h" #include "sirenita.h" #include "reloxio.h" #define EEPROM_SDA PIN_C4 #define EEPROM_SCL PIN_C3 #include <24256.c> main() { unsigned int16 i = 0; init_ext_eeprom(); for(i=0; i<128; i++) write_ext_eeprom(i, cygwin_icon[i]); //byte 0-127 for(i=0; i<128; i++) write_ext_eeprom(i+128, flash_icon[i]); //byte 128-255

Page 35: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 35 de 35

for(i=0; i<128; i++) write_ext_eeprom(i+256, outlook_icon[i]); //byte 256-383 for(i=0; i<72; i++) write_ext_eeprom(i+384, Dog_row1[i]); //offset = 384, byte 0-71 for(i=0; i<72; i++) write_ext_eeprom(i+456, Dog_row2[i]); for(i=0; i<72; i++) write_ext_eeprom(i+528, Dog_row3[i]); for(i=0; i<72; i++) write_ext_eeprom(i+600, Dog_row4[i]); for(i=0; i<72; i++) write_ext_eeprom(i+672, Dog_row5[i]); for(i=0; i<72; i++) write_ext_eeprom(i+744, Dog_row6[i]); for(i=0; i<72; i++) write_ext_eeprom(i+816, Dog_row7[i]); for(i=0; i<72; i++) write_ext_eeprom(i+888, Dog_row8[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1000, sirenita1[i]); //offset = 384, byte 0-71 for(i=0; i<128; i++) write_ext_eeprom(i+1128, sirenita2[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1256, sirenita3[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1384, sirenita4[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1512, sirenita5[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1640, sirenita6[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1768, sirenita7[i]); for(i=0; i<128; i++) write_ext_eeprom(i+1896, sirenita8[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3000, icotemp1[i]); //offset = 384, byte 0-71 for(i=0; i<128; i++) write_ext_eeprom(i+3128, icotemp2[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3256, icotemp3[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3384, icotemp4[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3512, icotemp5[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3640, icotemp6[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3768, icotemp7[i]); for(i=0; i<128; i++) write_ext_eeprom(i+3896, icotemp8[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6000, reloxio1[i]); //offset = 384, byte 0-71 for(i=0; i<128; i++) write_ext_eeprom(i+6128, reloxio2[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6256, reloxio3[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6384, reloxio4[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6512, reloxio5[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6640, reloxio6[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6768, reloxio7[i]); for(i=0; i<128; i++) write_ext_eeprom(i+6896, reloxio8[i]); for(;;){ ; } } - modulo 2: .font5x7.h /* ********************************************************************************************************* * 5x7 FONT ASCII, Copyright (c) 2004 Sentinel Systems Corporation * From http://www.ccsinfo.com/forum/viewtopic.php?t=20597 * All Rights Reserved * Date : 01-05-2004 * Version: 1.0

Page 36: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 36 de 36

********************************************************************************************************* */ const unsigned char FONT1[51][5] = { 0x00, 0x00, 0x00, 0x00, 0x00, // SPACE 0x00, 0x00, 0x5F, 0x00, 0x00, // ! 0x00, 0x03, 0x00, 0x03, 0x00, // " 0x14, 0x3E, 0x14, 0x3E, 0x14, // # 0x24, 0x2A, 0x7F, 0x2A, 0x12, // $ 0x43, 0x33, 0x08, 0x66, 0x61, // % 0x36, 0x49, 0x55, 0x22, 0x50, // & 0x00, 0x05, 0x03, 0x00, 0x00, // ' 0x00, 0x1C, 0x22, 0x41, 0x00, // ( 0x00, 0x41, 0x22, 0x1C, 0x00, // ) 0x14, 0x08, 0x3E, 0x08, 0x14, // * 0x08, 0x08, 0x3E, 0x08, 0x08, // + 0x00, 0x50, 0x30, 0x00, 0x00, // , 0x08, 0x08, 0x08, 0x08, 0x08, // - 0x00, 0x60, 0x60, 0x00, 0x00, // . 0x20, 0x10, 0x08, 0x04, 0x02, // / 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0 0x04, 0x02, 0x7F, 0x00, 0x00, // 1 0x42, 0x61, 0x51, 0x49, 0x46, // 2 0x22, 0x41, 0x49, 0x49, 0x36, // 3 0x18, 0x14, 0x12, 0x7F, 0x10, // 4 0x27, 0x45, 0x45, 0x45, 0x39, // 5 0x3E, 0x49, 0x49, 0x49, 0x32, // 6 0x01, 0x01, 0x71, 0x09, 0x07, // 7 0x36, 0x49, 0x49, 0x49, 0x36, // 8 0x26, 0x49, 0x49, 0x49, 0x3E, // 9 0x00, 0x36, 0x36, 0x00, 0x00, // : 0x00, 0x56, 0x36, 0x00, 0x00, // ; 0x08, 0x14, 0x22, 0x41, 0x00, // < 0x14, 0x14, 0x14, 0x14, 0x14, // = 0x00, 0x41, 0x22, 0x14, 0x08, // > 0x02, 0x01, 0x51, 0x09, 0x06, // ? 0x3E, 0x41, 0x59, 0x55, 0x5E, // @ 0x7E, 0x09, 0x09, 0x09, 0x7E, // A 0x7F, 0x49, 0x49, 0x49, 0x36, // B 0x3E, 0x41, 0x41, 0x41, 0x22, // C 0x7F, 0x41, 0x41, 0x41, 0x3E, // D 0x7F, 0x49, 0x49, 0x49, 0x41, // E 0x7F, 0x09, 0x09, 0x09, 0x01, // F 0x3E, 0x41, 0x41, 0x49, 0x3A, // G 0x7F, 0x08, 0x08, 0x08, 0x7F, // H 0x00, 0x41, 0x7F, 0x41, 0x00, // I 0x30, 0x40, 0x40, 0x40, 0x3F, // J 0x7F, 0x08, 0x14, 0x22, 0x41, // K 0x7F, 0x40, 0x40, 0x40, 0x40, // L 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M 0x7F, 0x02, 0x04, 0x08, 0x7F, // N 0x3E, 0x41, 0x41, 0x41, 0x3E, // O 0x7F, 0x09, 0x09, 0x09, 0x06, // P 0x1E, 0x21, 0x21, 0x21, 0x5E, // Q 0x7F, 0x09, 0x09, 0x09, 0x76 // R }; const unsigned char FONT2[44][5]= { 0x26, 0x49, 0x49, 0x49, 0x32, // S 0x01, 0x01, 0x7F, 0x01, 0x01, // T 0x3F, 0x40, 0x40, 0x40, 0x3F, // U

Page 37: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 37 de 37

0x1F, 0x20, 0x40, 0x20, 0x1F, // V 0x7F, 0x20, 0x10, 0x20, 0x7F, // W 0x41, 0x22, 0x1C, 0x22, 0x41, // X 0x07, 0x08, 0x70, 0x08, 0x07, // Y 0x61, 0x51, 0x49, 0x45, 0x43, // Z 0x00, 0x7F, 0x41, 0x00, 0x00, // [ 0x02, 0x04, 0x08, 0x10, 0x20, // \ 0x00, 0x00, 0x41, 0x7F, 0x00, // ] 0x04, 0x02, 0x01, 0x02, 0x04, // ^ 0x40, 0x40, 0x40, 0x40, 0x40, // _ 0x00, 0x01, 0x02, 0x04, 0x00, // ` 0x20, 0x54, 0x54, 0x54, 0x78, // a 0x7F, 0x44, 0x44, 0x44, 0x38, // b 0x38, 0x44, 0x44, 0x44, 0x44, // c 0x38, 0x44, 0x44, 0x44, 0x7F, // d 0x38, 0x54, 0x54, 0x54, 0x18, // e 0x04, 0x04, 0x7E, 0x05, 0x05, // f 0x08, 0x54, 0x54, 0x54, 0x3C, // g 0x7F, 0x08, 0x04, 0x04, 0x78, // h 0x00, 0x44, 0x7D, 0x40, 0x00, // i 0x20, 0x40, 0x44, 0x3D, 0x00, // j 0x7F, 0x10, 0x28, 0x44, 0x00, // k 0x00, 0x41, 0x7F, 0x40, 0x00, // l 0x7C, 0x04, 0x78, 0x04, 0x78, // m 0x7C, 0x08, 0x04, 0x04, 0x78, // n 0x38, 0x44, 0x44, 0x44, 0x38, // o 0x7C, 0x14, 0x14, 0x14, 0x08, // p 0x08, 0x14, 0x14, 0x14, 0x7C, // q 0x00, 0x7C, 0x08, 0x04, 0x04, // r 0x48, 0x54, 0x54, 0x54, 0x20, // s 0x04, 0x04, 0x3F, 0x44, 0x44, // t 0x3C, 0x40, 0x40, 0x20, 0x7C, // u 0x1C, 0x20, 0x40, 0x20, 0x1C, // v 0x3C, 0x40, 0x30, 0x40, 0x3C, // w 0x44, 0x28, 0x10, 0x28, 0x44, // x 0x0C, 0x50, 0x50, 0x50, 0x3C, // y 0x44, 0x64, 0x54, 0x4C, 0x44, // z 0x00, 0x08, 0x36, 0x41, 0x41, // { 0x00, 0x00, 0x7F, 0x00, 0x00, // | 0x41, 0x41, 0x36, 0x08, 0x00, // } 0x02, 0x01, 0x02, 0x04, 0x02 // ~ }; - modulo 3: .reloxio.h //reloxio.bmp //128 x 64 matrix //Is different from normal bmp hex data dump, this array runs //in 8 font cells, with convenience for CG RAM character def. //Data converted by shareware FastLCD designer by Bojan I. MICRODESIGN, version 1.2.0 const unsigned int8 reloxio1[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

Page 38: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 38 de 38

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00,0x03,0x1C,0x60,0x80, 0x00,0x00,0x01,0x1F,0xE0,0x00,0x00,0x00, 0x00,0xE0,0xF0,0xFF,0x40,0x40,0x40,0x00, 0x00,0x00,0x00,0x00,0xF8,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x30, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //9th CG character, 0 row, 8 col }; const unsigned int8 reloxio2[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08, 0x07,0x08,0x30,0xC0,0x00,0x00,0x00,0x00, 0x00,0x80,0x40,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, 0x4C,0x82,0x01,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x80,0x60,0x10,0x08,0x04,0x02, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; const unsigned int8 reloxio3[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01, 0x10,0x30,0x48,0x44,0x80,0x80,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x01,0x02,0x04,0x00,0x00,0x00,0x00, 0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10 }; const unsigned int8 reloxio4[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0x02,0x02,0x04,0x0C,0x0C,0x1C, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,

Page 39: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 39 de 39

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x04,0x06,0x07,0x07 }; const unsigned int8 reloxio5[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x1F,0x1C,0x1C,0x0C,0x0E,0x02,0x02,0x02, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x7F,0x07,0x06,0x04,0x08,0x08,0x08,0x08 }; const unsigned int8 reloxio6[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x80,0x80,0x40,0x42,0x24,0x18, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x02,0x01,0x00,0x00,0x01, 0x10,0x10,0x20,0x20,0x40,0xC0,0x80,0x00 }; const unsigned int8 reloxio7[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x04,0x02,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xC0,0x30,0x08,0x06, 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x20,0x11,0x0A,0x0C, 0x02,0x04,0x08,0x10,0x60,0x80,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

Page 40: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 40 de 40

}; const unsigned int8 reloxio8[128]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xC0,0x60,0x1C,0x03,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xE0,0x1F,0x01,0x00,0x00, 0x00,0x40,0x40,0x40,0xFF,0xF0,0xE0,0x00, 0x00,0x00,0x07,0xF8,0x00,0x00,0x00,0x00, 0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; - modulo 4: .sirenita.h //sirenita.bmp //128 x 64 matrix //Is different from normal bmp hex data dump, this array runs //in 8 font cells, with convenience for CG RAM character def. //Data converted by shareware FastLCD designer by Bojan I. MICRODESIGN, version 1.2.0 const unsigned int8 sirenita1[128]= { 0xFF,0xFF,0xC0,0xC0,0xDF,0xCF,0xC0,0xC0, 0xFF,0xFF,0x00,0x01,0xFF,0xFF,0x00,0x00, 0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x08,0x00, 0xFF,0xFF,0x00,0x00,0xF9,0xF9,0x03,0x07, 0xFF,0xFF,0x38,0x60,0xC0,0x80,0x00,0x00, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFE,0x0F,0x03,0x00,0x00,0x00, 0xFF,0xFF,0x00,0x80,0xE0,0x7C,0x0F,0x00, 0xFF,0xFF,0x00,0x00,0x00,0x00,0xC0,0xFF, 0xFF,0xFF,0x1F,0x00,0x00,0x00,0x00,0xC0, 0xFF,0xFF,0xC0,0xF0,0x1E,0x07,0x01,0x00, 0xFF,0xFF,0x00,0x00,0x00,0x00,0xC0,0x60, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01 //9th CG character, 0 row, 8 col }; const unsigned int8 sirenita2[128]= { 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0x0C,0x0C,0x08,0x08,0x08,0x19,0x1F, 0x01,0x02,0x00,0x07,0x3E,0xF3,0xBF,0xE0, 0xFF,0x00,0x0F,0xF0,0x00,0xE0,0x00,0x00, 0xE0,0x3F,0xC3,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xF0,0x0F,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,

Page 41: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 41 de 41

0x00,0x00,0x00,0x01,0x00,0x00,0x08,0x18, 0x00,0x1F,0x7F,0x80,0x00,0x00,0x00,0x00, 0x20,0xF8,0xFC,0x03,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x80,0xC0,0x60,0x70, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 }; const unsigned int8 sirenita3[128]= { 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03, 0x1F,0x1E,0x38,0x70,0xE0,0xC0,0x80,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x1F,0xFC, 0x00,0x00,0x00,0x03,0x7F,0xFC,0x80,0x00, 0x00,0x00,0x00,0xFF,0xFF,0x01,0x01,0x00, 0x00,0x00,0x3F,0xFF,0xF0,0x80,0x00,0x3F, 0x00,0x0F,0xFF,0xFE,0x03,0x00,0xC0,0xFC, 0xF8,0xD8,0x18,0x0C,0x8C,0xCE,0x07,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0, 0x00,0x04,0x06,0x03,0x01,0x00,0x00,0x00, 0x38,0x18,0x1C,0x0E,0xC6,0x7F,0x1F,0x03, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 }; const unsigned int8 sirenita4[128]= { 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x06,0x06,0x0C,0x0C,0x0C,0x0E,0x07, 0x03,0x07,0x1C,0x38,0x70,0x7F,0x7F,0x3E, 0xC6,0x06,0x07,0x03,0x00,0x07,0xFF,0x00, 0x00,0x7C,0xC0,0x80,0xEC,0xFF,0xFF,0x3F, 0x00,0x00,0x80,0x60,0x30,0xBC,0x7E,0x3F, 0x7F,0x1E,0x06,0x03,0x01,0x00,0x00,0x00, 0xFF,0x7F,0x7F,0x7F,0xBF,0xDC,0x70,0x00, 0x83,0xC1,0xC1,0x83,0x03,0x07,0x00,0x00, 0x70,0xDF,0xF0,0xBC,0xF7,0xAF,0x3C,0x78, 0x00,0xFE,0x07,0x00,0x80,0xF0,0x7C,0x0E, 0x00,0x00,0xF0,0x7C,0x0F,0x03,0x01,0x00, 0x07,0x00,0x00,0x00,0x00,0x80,0xC0,0x60, 0xF0,0x3E,0x03,0x00,0x00,0x00,0x00,0x00, 0x01,0x01,0x81,0xC1,0x61,0x31,0x31,0x31 }; const unsigned int8 sirenita5[128]= { 0xC0,0xC0,0xC0,0xC0,0xC0,0xC7,0xCF,0xC1, 0x00,0x00,0x00,0x00,0x00,0xFF,0xF8,0xFC, 0x03,0x00,0x00,0x00,0x00,0xFE,0x1F,0x00, 0xFF,0x3F,0x00,0x00,0x00,0x00,0xFC,0x1F, 0xFF,0xFE,0x00,0x00,0x00,0x00,0x01,0xFF, 0xFF,0xC3,0x71,0x30,0x30,0x30,0xF0,0xB0, 0xBF,0xDF,0xEF,0xB1,0xC1,0xC3,0xC1,0x60, 0x80,0x80,0x80,0x80,0x0E,0x9E,0xE0,0x00, 0x00,0x00,0x00,0x00,0x07,0x07,0x3F,0x7F, 0x00,0x00,0x00,0x00,0x80,0x01,0x03,0x03, 0x58,0x48,0x48,0xCC,0xCC,0xCC,0x8C,0x0C, 0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x80,0xC0,0xF0,0x78,0x18,0x0C,0x0E,0x06,

Page 42: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 42 de 42

0x70,0x38,0x18,0x0C,0x0C,0x04,0x04,0x04, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x31,0x31,0x31,0x31,0x31,0x61,0x61,0xC1 }; const unsigned int8 sirenita6[128]= { 0xC0,0xC1,0xC3,0xC6,0xC6,0xCC,0xCF,0xCB, 0x70,0xC0,0x80,0x10,0x70,0xE0,0xC0,0x80, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0F, 0x00,0x00,0x00,0x01,0x07,0x3C,0xE0,0x00, 0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00, 0x60,0x70,0x3C,0x0F,0x07,0x00,0x00,0x00, 0x03,0xFF,0xCF,0x87,0xF0,0xFF,0x07,0x7E, 0xFF,0xFE,0xEC,0xF8,0xC0,0x01,0xE7,0x7F, 0x06,0x0E,0x1C,0x38,0x70,0xE0,0x80,0x00, 0x0C,0x06,0x07,0x06,0x06,0x03,0x00,0x00, 0x00,0x00,0x80,0xF8,0x1F,0x03,0x00,0x00, 0x06,0x02,0x02,0x02,0x82,0xFA,0x1F,0x03, 0x04,0x04,0x00,0x00,0x00,0x00,0x00,0xC0, 0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x01, 0xC1,0xC1,0x81,0x81,0xC1,0xE1,0x39,0x1F }; const unsigned int8 sirenita7[128]= { 0xCF,0xCF,0xC2,0xC2,0xC2,0xC6,0xC2,0xC3, 0x10,0x30,0x60,0x40,0xC0,0xC0,0x80,0x80, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x10,0x20,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0x07,0x1C,0x18,0x38,0x30,0x30,0x38, 0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0, 0x00,0x00,0x00,0x3F,0x0E,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x18, 0xE0,0x70,0x38,0x1C,0x0C,0x06,0x07,0x03, 0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x80, 0x07,0x81,0xC1,0x41,0x21,0x01,0x01,0x01 }; const unsigned int8 sirenita8[128]= { 0xC3,0xC3,0xC1,0xC0,0xC0,0xC0,0xC0,0xFF, 0x80,0xC0,0xC0,0xC0,0x60,0x70,0x3C,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0x18,0x18,0x1C,0x0C,0x06,0x07,0x03,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xE0,0x70,0x30,0x18,0x0E,0x07,0x03,0xFF, 0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0xFF, 0x00,0x00,0x00,0x00,0x60,0xF8,0xF8,0xFF, 0x18,0x18,0x0F,0x0C,0x18,0x70,0xE0,0xFF, 0x01,0x00,0xC0,0xC0,0x60,0x78,0xD8,0xFF, 0x80,0xC0,0xE0,0x70,0x38,0x1C,0x0E,0xFF, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xFF };

Page 43: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 43 de 43

7.- O CIRCUITO Por unha parte temos o circuito principal formado polo PIC 18F452 e o LCD 128X64

18F452

1234567891011121314151617181920

4039383736353433323130292827262524232221

10k

+5 v

+5 v

+5 v

Rv

1 2 3 4 5 6 7 8 9 10 11 12 13 14WR

Rd0Rd1

Rd3Rd2

D3D2D1D0

SDA

SCL

+5 vRb0Rb1Rb2Rb3Rb4Rb5Rb6Rb7

RC1RC2

RC0

Fila 0Fila 1Fila 2Fila 3Col 0Col 1Col 2Col 3

O teclado4x4

RD5RD6RD7

Pulsadores

11 12 13 14RD CE CD RST D7D6D5D4 FSVddVssFG V0

RE1RE

RE2

RA4

RE RE RE RA4 RC0 RD0 RD1 RD2 RD3 RD4 RD5 RD6 RD7

RA02k2

RC6RC7RD4

RC4RC5

RC3

Al PIC 18f452

P1

Page 44: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 44 de 44

Vexamos ahora os detalles dos elementos que están conectados o bus I2C, lineas SDA e SCL do PIC, pins 23 e 18 respectivamente.Lembramos que estas lineas levan tamén unhas resistencias pull-up de 2k2. Para os sensores de temperatura:

2k2Resistencia pull-upbus I2C

+5 v

1 SDA2 SCL34 5

678

DS1624 #1

SDA

SCL

SDA

SCL

+5 v

Direccion 000

1 SDA2 SCL34 5

678

DS1624 #2

+5 v

Direccion 001

Aquí están o PCF8583 e a memoria 24LC256

2k2Resistencia pull-upbus I2C

+5 v

1 Osc2 Osc34

SCL 678

PCF 8583

SDA

SCL

SDA

SCL

+5 v

12 34 5 SDA

6 SCL78

24LC256

+5 v

SDA 5

+5 v

27 pF

Page 45: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 45 de 45

A parte correspondente o teclado:

1 2 3 A

4 5 6 B

7 8 9 C

* 0 # D

F0 F1 F2 F3 C0 C1 C2 C3

4k7Resistencia para meter señal no porto B

+5 vPorto B

RB0 RB7

Page 46: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 46 de 46

8.- IMAXENES

Imaxen de arranque (“Sirenita”)

Page 47: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 47 de 47

Menu inicial

Menu de temperaturas

Menu de Hora analóxica

Page 48: Ejemplo del uso LCD grafico 128 64

CIRCUITO PIC 18F452 CON LCD GRAFICO 128x64 Pax 48 de 48

Menu xenérico con moitos datos

Vista traseira coa pila do reloxio

Vista xeral coa sonda de temp. exterior

9.- VARIOS Para realizar os bitmaps e pasalos a hexadecimal utilizouse o programa fastlcd.

Ejemplo icono sirenita: