Autor Tema: Ayuda con libreria para LCD 4x16  (Leído 5700 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado huichoman

  • Colaborador
  • PIC16
  • *****
  • Mensajes: 186
    • Pequeñas piezas para grandes proyectos.
Ayuda con libreria para LCD 4x16
« en: 12 de Noviembre de 2006, 06:58:18 »
Hola amigos. Alguien conoce alguna librería que funcione para un display LCD de 4x16. chequé la de LCDTESTE.C pero no me funcia, la simulé en proteus pero me saca nada. Saludos

Desconectado huichoman

  • Colaborador
  • PIC16
  • *****
  • Mensajes: 186
    • Pequeñas piezas para grandes proyectos.
Re: Ayuda con libreria para LCD 4x16
« Respuesta #1 en: 12 de Noviembre de 2006, 16:26:11 »
Encontré una página donde vienen varias rutinas pero son para el compilador Hi-tech. Si alguien usa Hi-tech, espero le sea de ayuda la info, y si alguien puede modificar esas rutinas para ccs que es la mayoría usamos, estaría requetebien, pero agradecería mucho la librería para display LCD 16x4, mis conocimientos son aun pocos para modificarlo por cuenta propia. Saludos

Esta es la página:  http://www.ece.ndsu.nodak.edu/~glower/software/pic/c.htm
« Última modificación: 12 de Noviembre de 2006, 16:29:16 por huichoman »

Desconectado huichoman

  • Colaborador
  • PIC16
  • *****
  • Mensajes: 186
    • Pequeñas piezas para grandes proyectos.
Re: Ayuda con libreria para LCD 4x16
« Respuesta #2 en: 13 de Noviembre de 2006, 01:21:18 »
Me vuelvo a responder a mi mismo, y también hago una nueva pregunta ( que posiblemente me vuelva a responder :mrgreen:) ) jejeje

Probé el siguiente código que puso en un post que colocó nordestecnica

Código: [Seleccionar]
//GUARDAR CON ESTE NOME LCDTESTE.C
#use delay(clock=20000000)

//PARA USAR A PORTA D CONVENIENTE PARA 16F877A
#define LCD_D0  PIN_D2   
#define LCD_D1  PIN_D3
#define LCD_D2  PIN_D4
#define LCD_D3  PIN_D5
#define LCD_EN  PIN_D1
#define LCD_RS  PIN_D0
//O PIN R/W LIGADO A GND SENAO NAO FUNCIONA

// EXPECIAL PARA LCD 4x20 //
//#define LINHA_1 0x00
//#define LINHA_2 0x40
//#define LINHA_3 0x14
//#define LINHA_4 0x54

// EXPECIAL PARA LCD 4X16 //
//#define LINHA_1 0x00
//#define LINHA_2 0x40
//#define LINHA_3 0x10
//#define LINHA_4 0x50

// EXPECIAL PARA LCD 2x20 //
#define LINHA_1 0x00
#define LINHA_2 0x40

// EXPECIAL PARA LCD 1X16 //
//#define LINHA_1 0x00

// EXPECIAL PARA LCD 2X16 //
//#define LINHA_1 0x00
//#define LINHA_2 0x40


#define CLEAR  0x01
void LCD_Init ( void );
void LCD_SetPosition ( unsigned int cX );
void LCD_PutChar ( unsigned int cX );
void LCD_PutCmd ( unsigned int cX );
void LCD_PulseEnable ( void );
void LCD_SetData ( unsigned int cX );
void LCD_Init ( void )
   {
   LCD_SetData ( 0x00 );
   delay_ms ( 50 );       /* COLOCAR O TEMPO PARA DIFERENTES LCD REALIZAR EXPERIENCIAS*/
   output_low ( LCD_RS );
   LCD_SetData ( 0x03 );   
   LCD_PulseEnable();
   LCD_PulseEnable();
   LCD_PulseEnable();
   LCD_SetData ( 0x02 );   
   LCD_PulseEnable();     
   LCD_PutCmd ( 0x2C );   
   LCD_PutCmd ( 0x0C );   
   LCD_PutCmd ( 0x01 );   
   LCD_PutCmd ( 0x06 );   
   }

void LCD_SetPosition ( unsigned int cX )
   {
   
   LCD_SetData ( swap ( cX ) | 0x08 );
   LCD_PulseEnable();
   LCD_SetData ( swap ( cX ) );
   LCD_PulseEnable();
   }

void LCD_PutChar ( unsigned int cX )
   {
   
   output_high ( LCD_RS );
   LCD_SetData ( swap ( cX ) );     
   LCD_PulseEnable();
   LCD_SetData ( swap ( cX ) );     
   LCD_PulseEnable();
   output_low ( LCD_RS );
   }

void LCD_PutCmd ( unsigned int cX )
   {
   
   LCD_SetData ( swap ( cX ) );     
   LCD_PulseEnable();
   LCD_SetData ( swap ( cX ) );     
   LCD_PulseEnable();
   }

void LCD_PulseEnable ( void )
   {
   output_high ( LCD_EN );
   delay_us ( 20 );   //IR MODIFICANDO O VALOR ATE CONSEGUIR O MAIS ADEQUADO
   output_low ( LCD_EN );
   delay_ms ( 20 );  //IR MODIFICANDO O VALOR ATE CONSEGUIR O MAIS ADEQUADO
   }

void LCD_SetData ( unsigned int cX )
   {
   output_bit ( LCD_D0, cX & 0x01 );
   output_bit ( LCD_D1, cX & 0x02 );
   output_bit ( LCD_D2, cX & 0x04 );
   output_bit ( LCD_D3, cX & 0x08 );
   }







esto es un teste para usar este driver con el 16f877a

#include <16F877A.h>
#include <LCDTESTE.C>
#use delay(clock=20000000)
#fuses NOWDT,RC, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, LVP, NOCPD, NOWRT




void main ( void )
   {
  LCD_Init();
  LCD_PutCmd ( CLEAR );
  LCD_SetPosition ( LINHA_1 );
  printf ( LCD_PutChar, "            LINHA1                " );
  delay_ms (500);
  LCD_SetPosition ( LINHA_2 );
  printf ( LCD_PutChar, "            LINHA2                " );
  delay_ms ( 1000);


  LCD_PutCmd ( CLEAR ); 
LCD_SetPosition ( LINHA_1 );
  printf ( LCD_PutChar, "TESTE LCD 2 LINHAS POR 40 CARACTERES";
  delay_ms (500);
  LCD_SetPosition ( LINHA_2 );
  printf ( LCD_PutChar, " PREPARADO POR XASTRE NORDESTECNICA  ";
  delay_ms ( 1000);
   }   

Lo probé en proteus y no me funcionó.

La pregunta es sobre esto    -- //O PIN R/W LIGADO A GND SENAO NAO FUNCIONA--
si el pin R/W conectado a masa no funciona, entonces a donde lo conecto???
Espero alguien tenga la respuesta o una librería para lcd 16x4 que le haya funcionado. Mientras sigo investigando y respondiéndome y haciéndo nuevas preguntas  :-/

SALUUUUDOS

Desconectado djpalas

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 595
    • Microtronic
Re: Ayuda con libreria para LCD 4x16
« Respuesta #3 en: 25 de Noviembre de 2006, 18:23:41 »
Hola Huichoman

Buenas, el driver que lleva ese tipo de pantallas alfanumericas es el HD44780. En esta dirección puedes bajarte su datasheet.
http://www.alldatasheet.com/datasheet-pdf/pdf/63673/HITACHI/HD44780.html

Sobre tus dudas del PINs

E   - para habilitar la instrucción.
RS - Si es 0 implica que te diriges al registro de instrucciones, y si es 1 al registro de datos.
RW - Si es 0 estas escribiendo, y si es 1 estas leyendo.

Por lo que si pones rw a masa, siempre estarás escribiendo en el registro, ya sea datos o instrucciones.

Saludos!!
Diego J.

Saludos desde Cádiz, España
Web personal: http://www.microtronic.es