Author Topic: 16x2 LCD with PIC16F887 not working  (Read 6389 times)

0 Members and 1 Guest are viewing this topic.

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13382
Re: 16x2 LCD with PIC16F887 not working
« Reply #25 on: January 01, 2022, 11:36:05 am »
If you are a beginner with PIC MCU and there is no restriction set by your teachers(in case it is an academic project), I suggest you try the free version of MikroC PRO for PIC compiler. I was personally benefitted from it. MikroC pro for PIC has a library for LCD. It makes showing texts etc. very easy.

I apologies in advance if you have diagnosed short term memory loss,  but do you lack reading comprehension or are you too lazy to read through a single page topic before replying?

The O.P. posted back in reply #21:
The only thing that works for me is the mikroelectronica sample code for LCD for 4-bit interface. At least that proves that my chip and LCD are working fine. The only adjustments I had to make was to disable MCLRE pin and use the internal oscillator (INTOSCIO option)
I do not like that I cannot see the inner-workings of the library functions provided by MikroE, must be closed source, or at least I haven't figured out how.
Below is the code and circuit diagram that work for me. Of course that is not what I had in mind as mikroE hides a lot of the stuff behind their own macros which I don't like for learning purposes, but at least I can put the money I spent on the mickroC pro license to a good use...

I find MikroElektronika's walled garden software ecosystem reprehensible.   There's no reason for their 'dog in manger' lack of MPLAB compatibility for their compilers.  Other companies (even smaller ones) with their own IDEs have written MPLAB plugins for their own compilers and generally are willing to at least sell you a license to see their library source code.   Don't hold your breath waiting for either from MicroE.

OTOH they do make some nice demo boards and hardware accessories which are often better thought out and more versatile than the Microchip offerings.
 

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 711
  • Country: gb
    • Electronic controls
Re: 16x2 LCD with PIC16F887 not working
« Reply #26 on: January 01, 2022, 02:39:22 pm »
Not only does wiring need to be correct but you must follow software setup from datasheet.
Some instructions need quite long delays between them.
An oddity with the LCD display is 2nd line starts from position 40.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6544
  • Country: es
Re: 16x2 LCD with PIC16F887 not working
« Reply #27 on: January 01, 2022, 06:25:35 pm »
The code works, just copy the important lcd stuff and setup your specific Pic settings.
"Compiler errors" doesn't mean anything if you don't show them.
The project is for mplabX and xc8 compiler.
Xc8 is free and unrestricted up to O2 optimization.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 680
  • Country: us
Re: 16x2 LCD with PIC16F887 not working
« Reply #28 on: January 08, 2022, 04:02:29 am »
Have you tried leaving E in a high state then pulsing it low back to high? I believe data latch occurs on high to low transition. I'm not near my development machine at the moment but I have 4-bit, 8-bit, and 16 bit SPI libraries for the two and four line LCDs and I'm sure I leave the E line high. Also, you can wire the R/W line low and save yourself an IO line.
« Last Edit: January 08, 2022, 04:19:19 am by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6544
  • Country: es
Re: 16x2 LCD with PIC16F887 not working
« Reply #29 on: January 09, 2022, 01:42:39 pm »
Might work, but I'd rather follow the datasheet specs, so I fetch the data, wait 1us, toggle E high, wait 1us, toggle E down and wait the instruction time.
I had a 16x4 module from a decade ago lying around, worked perfectly.
Could be optimized, but these displays are slow anyways.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: Ian.M

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 711
  • Country: gb
    • Electronic controls
Re: 16x2 LCD with PIC16F887 not working
« Reply #30 on: January 10, 2022, 03:22:25 pm »
Also, you can wire the R/W line low and save yourself an IO line.
You can and I sometimes do but you then cant read busy flag.
You can get around it by using delays taken from datasheet.


 

Offline Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 680
  • Country: us
Re: 16x2 LCD with PIC16F887 not working
« Reply #31 on: January 10, 2022, 06:42:28 pm »
Might work, but I'd rather follow the datasheet specs, so I fetch the data, wait 1us, toggle E high, wait 1us, toggle E down and wait the instruction time.
I had a 16x4 module from a decade ago lying around, worked perfectly.
Could be optimized, but these displays are slow anyways.

Yea, I went back and looked at my libraries, EN high then EN low.  I was confusing the direct write to the display with the control of shift registers when using SPI.
There's no point getting old if you don't have stories.
 

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 711
  • Country: gb
    • Electronic controls
Re: 16x2 LCD with PIC16F887 not working
« Reply #32 on: April 07, 2022, 02:53:51 am »
I recently did a project using PIC and LCD.
No matter what I did the display would just roll short white lines.
Turned out to be a bad display !
I got 3 for £4 on ebay so just accepted I might get a bad one occasionally.
They are about £6 each at RS Components !


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf