caramoan tour package

caramoan tour package

Author Topic: Using a 4x20 lcd  (Read 9301 times)

Offline RaffT

  • Technical People
  • Hydroelectric
  • *****
  • Posts: 3440
  • Pogi/Ganda Points: 103
  • Gender: Male
  • more on R-n-D
    • MY Bots
Re: Using a 4x20 lcd
« Reply #20 on: July 30, 2008, 01:04:52 PM »

@ bulate,

ngayun ko palang nakita ang simu sa MPLAB :)
Learning is CooL! BEAM robotics/DIY UCD180/PSP/AC wtmtr/digiESRmtr/PICkit™2 clone/SGTC/SSTC/DR-SSTC

Never argue with an idiot... They'll take you down to their level and beat you with experience

Philippine Electronics Forum

Re: Using a 4x20 lcd
« Reply #20 on: July 30, 2008, 01:04:52 PM »

Offline paranz

  • Moderator
  • Nuclear Reactor
  • *****
  • Posts: 4525
  • Pogi/Ganda Points: 177
  • Gender: Male
  • 1/4W resistor specialist
    • RapidSignal Electronics
Re: Using a 4x20 lcd
« Reply #21 on: July 30, 2008, 01:33:38 PM »
^ oshoncroft simulator yun, not included sa MPLAB
PIC16 Programming Tutorial using MPLAB and Hi-Tech C
www.rapidsignalph.com/tutorials/pic16-tutorials

Arduino & gizDuino Tutorials
www.rapidsignalph.com/tutorials/arduino-tutorials

Philippine Electronics Forum

Re: Using a 4x20 lcd
« Reply #21 on: July 30, 2008, 01:33:38 PM »

Offline Cute_Worm_1983

  • Size D Battery
  • ******
  • Posts: 418
  • Pogi/Ganda Points: 16
  • Gender: Male
Re: Using a 4x20 lcd
« Reply #22 on: July 30, 2008, 01:34:15 PM »
(PIC Simulator IDE) di siya part na MPLAB mas madali kasi gamitin di naka mag layout ng schematic

load mo nalang yung hex. ok na, di nga lang siya realtime simulation. proteus parin ako.  ;D

link: http://www.oshonsoft.com/

I love electronicslab.ph

Philippine Electronics Forum

Re: Using a 4x20 lcd
« Reply #22 on: July 30, 2008, 01:34:15 PM »

Offline sani_figs

  • CR2032 Battery
  • **
  • Posts: 12
  • Pogi/Ganda Points: 0
Re: Using a 4x20 lcd
« Reply #23 on: August 02, 2008, 03:32:05 PM »
Mga Sir,

Kadalasan may mga maling characters sa display. For example, when trying to display "Hello World!", display sometimes show "" Hel o W rld!", "Hello W rlt!", or "H  lo Wo ld!", minsan may mga kakaibang characters pa na pumapalit sa suppossed character. I tried longer delays sa ilang parts ng code, although, hindi rin ako sure kasi hindi ko rin completely naiintindihan yung code. Any insights? Thanks!

Philippine Electronics Forum

Re: Using a 4x20 lcd
« Reply #23 on: August 02, 2008, 03:32:05 PM »

Offline 0b00000111

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 6129
  • Pogi/Ganda Points: 398
  • There is no delight in owning anything unshared.
Re: Using a 4x20 lcd
« Reply #24 on: August 02, 2008, 03:37:15 PM »
try using proteus. It simulates MCU + LCD quite nicely  ;)

Here is a pic16f84a + 2x16 LCD



a sample code in hi-tech c

Code: [Select]

/*
LCD interfacing using 4-bit mode
*/

#include <pic.h>
#include "delay.c"

//configuration fuse
__CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);

static bit LCD_RS @ ((unsigned)&PORTA*8+0); // Register select
static bit LCD_EN @ ((unsigned)&PORTA*8+1); // Enable

#define LCD_STROBE ((LCD_EN = 1),(LCD_EN=0))

void lcd_write(unsigned char c)
{
PORTB = (PORTB & 0xF0) |  (c >> 4);
LCD_STROBE;
PORTB = (PORTB & 0xF0) |  (c & 0x0F);
LCD_STROBE;
DelayUs(40);
}

/*
 * Clear and home the LCD
 */

void lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
DelayMs(2);
}

/* write a string of chars to the LCD */

void lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}

/* write one character to the LCD */

void lcd_putch(char c)
{
LCD_RS = 1; // write characters
PORTB = (PORTB & 0xF0) |  (c >> 4);
LCD_STROBE;
PORTB = (PORTB & 0xF0) |  (c & 0x0F);
LCD_STROBE;
DelayUs(40);
}


/*
 * Go to the specified position
 */

void lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}

/* initialise the LCD - put into 4 bit mode */

void lcd_init(void)
{
LCD_RS = 0; // write control bytes
DelayMs(15); // power on delay
PORTB = 0x03; // attention!
LCD_STROBE;
DelayMs(5);
LCD_STROBE;
DelayUs(100);
LCD_STROBE;
DelayMs(5);
PORTB = 0x02; // set 4 bit mode
LCD_STROBE;
DelayUs(40);
lcd_write(0x28); // 4 bit mode, 1/16 duty, 5x8 font (0010 1000)
lcd_write(0x08); // display off (0000 1000)
lcd_write(0x0F); // display on, blink curson on
lcd_write(0x06); // entry mode
}


void main()
{
TRISA &= ~0x03; //RA2 & RA3 are output
PORTA &= ~0x03;

TRISB &= ~0x0F; //RB<3:0> are output
PORTB &= ~0x0F; //RB<3:0> are low

lcd_init(); //initialize LCD, set to 4-bit mode
lcd_clear(); //clear LCD
lcd_puts("abcde"); //display text in first line
lcd_goto(0x40); //display text in second line
lcd_puts("pogi si paranz");

while(1);

}





di ba dapat "maganda si paranz"? ;D ;D ;D
E-Gizmo Mechatronix Central: www.e-gizmo.com

Tel #: (63)(2) 536-3378
Globe +63915-973-7691
Smart +63921-779-0748

Location Map

YM: julie.egizmo  aka Born2BeWired  ;D

Philippine Electronics Forum

Re: Using a 4x20 lcd
« Reply #24 on: August 02, 2008, 03:37:15 PM »

Offline Cute_Worm_1983

  • Size D Battery
  • ******
  • Posts: 418
  • Pogi/Ganda Points: 16
  • Gender: Male
Re: Using a 4x20 lcd
« Reply #25 on: August 02, 2008, 04:01:50 PM »
 @ sani_figs

 are you refering my code?
I love electronicslab.ph

Offline sani_figs

  • CR2032 Battery
  • **
  • Posts: 12
  • Pogi/Ganda Points: 0
Re: Using a 4x20 lcd
« Reply #26 on: August 04, 2008, 08:49:07 AM »
@bulate1983

Hindi po, yung ginamit ko na code ay yung nasa Zilog book ni Doc Sison. Baka lang common problem to. Kasi sa tingin ko na-initialize ko naman ng maayos. Di ko nga lang maisip kung bakit may blank spaces.. Hmm..  :)

Offline marcelino

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Using a 4x20 lcd
« Reply #27 on: August 15, 2008, 01:50:05 AM »
balik ko to ng konti...

kailangan pala iconvert...

pero matanong ko din, pano ko icacapture yung data sa serial port... tapos dispaly sa LCD? kunyari, floating values yung pinanggalingan.
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline rdpzycho

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 10728
  • Pogi/Ganda Points: 632
  • Gender: Male
  • Respect Begets Respect
    • rdpzycho
Re: Using a 4x20 lcd
« Reply #28 on: August 15, 2008, 10:26:43 AM »
kailangan mag-convert ng digits kung floating point binary yung pinapadala. pero kung per digit na ipapadala, kunin lang yung value sa port tapos kung ano mang alignment sa LCD ang gusto tapos i-command na.

pwedeng gumawa ng character lookup table nung LCD or function na magco-convert ng ASCII to LCD characters kung masasagad yung Flash or EEPROM memory.
‎"Divide each difficulty into as many parts as is feasible and necessary to resolve it."
- Rene Descartes

"For every difficult problem there is always a simple answer and most of them are wrong."
- Clayton Paul

Offline marcelino

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Using a 4x20 lcd
« Reply #29 on: August 15, 2008, 01:47:05 PM »
kailangan mag-convert ng digits kung floating point binary yung pinapadala. pero kung per digit na ipapadala, kunin lang yung value sa port tapos kung ano mang alignment sa LCD ang gusto tapos i-command na.

pwedeng gumawa ng character lookup table nung LCD or function na magco-convert ng ASCII to LCD characters kung masasagad yung Flash or EEPROM memory.

konti lang naman ang icacapture... siguro tatlong floatng values lang naman. sa tingin ko, kakayanin naman ng eeprom. pero ganun pa din ba ang process... recieve, i-buffer tapos iconvert?

OT: kung anong bang isinend sa serial ganun din ang marerecieve?
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline paranz

  • Moderator
  • Nuclear Reactor
  • *****
  • Posts: 4525
  • Pogi/Ganda Points: 177
  • Gender: Male
  • 1/4W resistor specialist
    • RapidSignal Electronics
Re: Using a 4x20 lcd
« Reply #30 on: August 15, 2008, 02:40:21 PM »
^ yung float value dapat ma-convert muna ito a character string before it can be displayed sa LCD
PIC16 Programming Tutorial using MPLAB and Hi-Tech C
www.rapidsignalph.com/tutorials/pic16-tutorials

Arduino & gizDuino Tutorials
www.rapidsignalph.com/tutorials/arduino-tutorials

Offline necoleis

  • Size AA Battery
  • ****
  • Posts: 113
  • Pogi/Ganda Points: 0
Re: Using a 4x20 lcd
« Reply #31 on: August 16, 2008, 09:12:12 PM »
Nag poprogram din po ako ng LCD mey tanong po ako, kailangan ko po bang mag pulse sa EN pin ng LCD?






Ang ulo ay hindi lang pinapagupitan kundi ginagamit din hehehe

by: uncle jr

Offline paranz

  • Moderator
  • Nuclear Reactor
  • *****
  • Posts: 4525
  • Pogi/Ganda Points: 177
  • Gender: Male
  • 1/4W resistor specialist
    • RapidSignal Electronics
Re: Using a 4x20 lcd
« Reply #32 on: August 16, 2008, 09:26:31 PM »
^ yup kailangan yan, the pulse at EN pin will clock in the data/command sent to the data pins
PIC16 Programming Tutorial using MPLAB and Hi-Tech C
www.rapidsignalph.com/tutorials/pic16-tutorials

Arduino & gizDuino Tutorials
www.rapidsignalph.com/tutorials/arduino-tutorials

Offline necoleis

  • Size AA Battery
  • ****
  • Posts: 113
  • Pogi/Ganda Points: 0
Re: Using a 4x20 lcd
« Reply #33 on: August 16, 2008, 09:28:41 PM »
Ok maraming salamat po sir paranz. I will post may code here after I finished.
Ang ulo ay hindi lang pinapagupitan kundi ginagamit din hehehe

by: uncle jr

Offline drx2k

  • Size D Battery
  • ******
  • Posts: 326
  • Pogi/Ganda Points: 15
  • Gender: Male
    • Drx2k Network
Re: Using a 4x20 lcd
« Reply #34 on: August 25, 2008, 12:15:14 AM »
try using proteus. It simulates MCU + LCD quite nicely  ;)

Here is a pic16f84a + 2x16 LCD



a sample code in hi-tech c

Code: [Select]

/*
LCD interfacing using 4-bit mode
*/

#include <pic.h>
#include "delay.c"

//configuration fuse
__CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);

static bit LCD_RS @ ((unsigned)&PORTA*8+0); // Register select
static bit LCD_EN @ ((unsigned)&PORTA*8+1); // Enable

#define LCD_STROBE ((LCD_EN = 1),(LCD_EN=0))

void lcd_write(unsigned char c)
{
PORTB = (PORTB & 0xF0) |  (c >> 4);
LCD_STROBE;
PORTB = (PORTB & 0xF0) |  (c & 0x0F);
LCD_STROBE;
DelayUs(40);
}

/*
 * Clear and home the LCD
 */

void lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
DelayMs(2);
}

/* write a string of chars to the LCD */

void lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}

/* write one character to the LCD */

void lcd_putch(char c)
{
LCD_RS = 1; // write characters
PORTB = (PORTB & 0xF0) |  (c >> 4);
LCD_STROBE;
PORTB = (PORTB & 0xF0) |  (c & 0x0F);
LCD_STROBE;
DelayUs(40);
}


/*
 * Go to the specified position
 */

void lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}

/* initialise the LCD - put into 4 bit mode */

void lcd_init(void)
{
LCD_RS = 0; // write control bytes
DelayMs(15); // power on delay
PORTB = 0x03; // attention!
LCD_STROBE;
DelayMs(5);
LCD_STROBE;
DelayUs(100);
LCD_STROBE;
DelayMs(5);
PORTB = 0x02; // set 4 bit mode
LCD_STROBE;
DelayUs(40);
lcd_write(0x28); // 4 bit mode, 1/16 duty, 5x8 font (0010 1000)
lcd_write(0x08); // display off (0000 1000)
lcd_write(0x0F); // display on, blink curson on
lcd_write(0x06); // entry mode
}


void main()
{
TRISA &= ~0x03; //RA2 & RA3 are output
PORTA &= ~0x03;

TRISB &= ~0x0F; //RB<3:0> are output
PORTB &= ~0x0F; //RB<3:0> are low

lcd_init(); //initialize LCD, set to 4-bit mode
lcd_clear(); //clear LCD
lcd_puts("abcde"); //display text in first line
lcd_goto(0x40); //display text in second line
lcd_puts("pogi si paranz");

while(1);

}




pwede bang tanggalin yung blinking cursor?

Offline Cute_Worm_1983

  • Size D Battery
  • ******
  • Posts: 418
  • Pogi/Ganda Points: 16
  • Gender: Male
Re: Using a 4x20 lcd
« Reply #35 on: August 25, 2008, 12:43:14 AM »
paltan mo yung value ng (0x0C);

lcd_write(0x0C);        // display on, blink cursor off
I love electronicslab.ph

Offline Dandy

  • Lead Acid Battery
  • *******
  • Posts: 726
  • Pogi/Ganda Points: 31
Re: Using a 4x20 lcd
« Reply #36 on: August 27, 2008, 02:01:50 AM »
Hi mga master, kailangan ko gumamit ng lcd display pero wala akong idea pano. May massuggest ba kayong materials na pwede aralin para makagamit ako ng lcd (meron ako 4x20 lcd)? Links or kahit turuan niyo ko, ayos lang po. Thank you!

check ko lang, you need 4-bit  mode or 8-bit mode access to your 20x4 LCD?

Offline sani_figs

  • CR2032 Battery
  • **
  • Posts: 12
  • Pogi/Ganda Points: 0
Re: Using a 4x20 lcd
« Reply #37 on: August 29, 2008, 02:07:15 PM »
Update lang:

Poor grounding lang ang problema with the previous blank spaces. Hindi lang naiinterpret ng maayos yung data since panget yung grounding ko with my initial circuit.  :)

Offline drx2k

  • Size D Battery
  • ******
  • Posts: 326
  • Pogi/Ganda Points: 15
  • Gender: Male
    • Drx2k Network
Re: Using a 4x20 lcd
« Reply #38 on: August 02, 2009, 03:43:25 PM »


paano po kaya ang initialization ng lcd sa Hi-Tech C na ganito ng connection ng lcd sa pic16f877a?





Offline drx2k

  • Size D Battery
  • ******
  • Posts: 326
  • Pogi/Ganda Points: 15
  • Gender: Male
    • Drx2k Network
Re: Using a 4x20 lcd
« Reply #39 on: August 02, 2009, 04:20:30 PM »



Philippine Electronics Forum

Re: Using a 4x20 lcd
« Reply #39 on: August 02, 2009, 04:20:30 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com