Author Topic: LCD issue with PIC16F877A  (Read 12199 times)

0 Members and 1 Guest are viewing this topic.

Offline VEGETATopic starter

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: jo
  • I am the cult of personality
    • Thundertronics
Re: LCD issue with PIC16F877A
« Reply #25 on: April 18, 2013, 09:27:50 pm »
" Make sure your PIC actually runs at 20 Mhz... the datasheet also lists the crystal type as HS and you said in a previous post you set it as XT... the datasheet shows typical xt crystals are up to 4 Mhz.  page 145, section 14.2"

the downloaded program on PIC used HS.... I changed it to XT then I read the datasheet and returned it to HS.

jucole

  • Guest
Re: LCD issue with PIC16F877A
« Reply #26 on: April 22, 2013, 10:54:59 am »
In your circuit why are d0-d3 tied to ground, surely it's an 8 bit data bus?
 

Offline baljemmett

  • Supporter
  • ****
  • Posts: 665
  • Country: gb
Re: LCD issue with PIC16F877A
« Reply #27 on: April 22, 2013, 12:37:18 pm »
In your circuit why are d0-d3 tied to ground, surely it's an 8 bit data bus?

The ubiquitous HD44780-style controllers support a 4-bit mode using the top four bits of the bus only and doing two transfers per command/data byte.  Can be handy when you're short of GPIOs, and is common enough that I'd expect any halfway-respectable LCD library to handle it; can't tell from the OP's code whether there's anything he has to do to tell the MikroeC library to use 4-bit mode, though.
 

Offline VEGETATopic starter

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: jo
  • I am the cult of personality
    • Thundertronics
Re: LCD issue with PIC16F877A
« Reply #28 on: April 23, 2013, 11:40:42 pm »
and how exactly can i tell it to use 4-bit mode?

the whole project works fine now but this LCD thing is not......!!! although i checked the config bits again.

note: means voltage (220v rms ac) is fed into bridge rectifier then a 100uF/400v filtering capacitor... then is fed into a voltage divider to make it 5v @ 280 rms (which is too much cuz rated will be about 200-230v).

^

but some of you here told me that this isn't isolated! so i used a voltage follower op-amp and a zener diode to enhance the input impedance to the PIC ADC pin and make some isolation... zener is to ensure 5v max.

Do you see my choice a good one?

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: LCD issue with PIC16F877A
« Reply #29 on: April 23, 2013, 11:56:27 pm »
but some of you here told me that this isn't isolated! so i used a voltage follower op-amp and a zener diode to enhance the input impedance to the PIC ADC pin and make some isolation... zener is to ensure 5v max.

Do you see my choice a good one?

Your choice appears to show a complete lack of understanding of the problem. No one cares if you blow up your PIC, they care if someone gets electrocuted by touching it.
 

jucole

  • Guest
Re: LCD issue with PIC16F877A
« Reply #30 on: April 24, 2013, 09:42:09 am »
and how exactly can i tell it to use 4-bit mode?
According to the MikroC website you appear to be using the correct 4bit calls in your code.
http://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/lcd_library.htm

I must say I much prefer to bit-bash than use a 3rd party library as I always get a better understanding of what is going on which is great when things don't work as expected.


 

Offline metalphreak

  • Frequent Contributor
  • **
  • Posts: 815
  • Country: au
  • http://d.av.id.au
    • D.av.id.AU
Re: LCD issue with PIC16F877A
« Reply #31 on: April 24, 2013, 09:44:00 am »
You need to initialize the LCD, set it to 4bit mode, and a few other  things before it will work.

A line of blocks on the first line indicates it hasn't been configured properly (and is probably still expecting 8bit commands). I suggest you read through a datasheet for the LCD properly and have a look at some example code written for PICs. Microchip actually have an LCD routine as part of their application library.


There is a command, where the unused four bits are all 0's, which allows you to set 4bit mode (thus you can connect the unused ones to ground and are read as 0 for that one "use 4 bit mode" command). So essentially you can send that one 8bit command at the start.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf