LCD not working, Help needed please

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
A_Smith
Posts: 7
Joined: Tue Oct 26, 2010 4:59 pm
Contact:

LCD not working, Help needed please

Post by A_Smith »

Hi All,

I am new to not only flowcode and the forum but also programming in general. I have been playing with flowcode V4 for about 4 weeks (demo) and I have learned the basics which all seemed to work on simulation. I have now bought a copy as I am attempting a reasonable sized project which will include multiple PWM's for high power LED's, Real time clock, LCD display, EEPROM, Pic to PIc comms and the usual push button inputs.

I would love to explain to you exactly what my project is as I'm sure it will interest some of you but unfortunately I plan to upgrade the license and market the end product so I have to be careful. I am however happy to share successful sub routines once I get them working.

I have started on the project but I am having problems with my LCD display not working in hardware (works in simulation). As the project is quite big, I have gone back to basics and tried the example digital clock but still I can't get it to work.

The LCD is a 16 x 2 alphanumeric and the PIC is 18F2550. I am working on a bread board. The simulation runs fine but the hardware doesn't. All I get when I first supply power is the top line of the lcd displaying black squares for a second and then it goes blank but no message/time is displayed.

I have looked through similar threads and played around with the chip configurations and clock speeds. It seems like a common problem people have which is usually resolved by turning off LVP however in the configuration screen LVP is not available to select or deselect when using a PIC18F2550. Instead I have tried driving the LCD from Port C instead of B but still no Joy. I have checked the outputs by using a simple on off delay of each port and used an LED to check. All pins work fine. Im sure its nothing to do with the pic and that the problem is with how I am setting it up.

Here are my pin connections and the code. Unfortunately the LCD data sheet is too large to upload but it is a MDLS162S65SS-02 which if you google comes up with the datasheet.

Port C Bit 0 - Data 0 (Pin 7)
Port C Bit 1 - Data 1 (Pin 8)
Port C Bit 2 - Data 3 (Pin 9)
Port C Bit 4 - Data 4 (Pin 10)
Port A Bit 0 - RS (Pin 4)
Port A Bit 1 - Enable (Pin 6)
Ground - VSS (Pin 1) V0 (Pin 3) R/W (Pin 5) LED - (Pin K)
VDD (from Pickit 2) - VDD (Pin 2) LED+ (Pin A)

Any help would be greatly appreciated, I have been pulling my hair out for about 5 days now.

I look forward to sharing knowledge with you all.

Cheers
Attachments
5. Digital clock.FCF
(16.06 KiB) Downloaded 297 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: LCD not working, Help needed please

Post by medelec35 »

Hello A_Smith. This looks like a configuration settings problem. Just had a quick look at your flowchart, 1st thing I have noticed is your watchdog timer is enabled.
So disable that and try again. Also you have the chip set for internal osc, but the target clock speed you have set for 19660800Hz (set in View,project options), which does not exist as an internal osc. I will need to know if you plan to use internal osc, or an external crystal. which ever one you use I also need to know the intended clock speed.
Would you be utilising PLL on the chip so it can run at 48MHz with a different crystal osc. E.g 4,8,12,16MHz etc?
When I get a chance I will connect a LCD board up, and see if your flowchart works it OK will let you know as soon as I can.
You probably have read elsewhere but if you have any issues with LCD or other components that are time dependent, it is wise to toggle a pin at about 1Hz, and confirm it is doing that OK. You can add that 1Hz routine to the beginning of Flowchart, in this case would not have worked because of the configuration settings.
A_Smith wrote:I have tried driving the LCD from Port C instead of B but still no Joy.
Even if you alter config settings so they are all correct. You will not be able to run LCD on port C since RC4 and RC5 are digital i/p's only.
Martin

A_Smith
Posts: 7
Joined: Tue Oct 26, 2010 4:59 pm
Contact:

Re: LCD not working, Help needed please

Post by A_Smith »

Hi Medelec35

Thanks for your response.

I have moved the LCD back to port B and played around with the configurations. I have simplified the test program even further so that all I have is the LCD and an led output. The program tells the Led (which is actually the LCD backlight) to flash 10 times at 1Hz and then start the LCD and write the number 1 then loop forever. To get the Led to flash at 1Hz I had to disable the watchdog timer, change the CPU sys CLK select to no divide, change OSC select to no divide and then in global options reduce the clock speed to 100000 Hz. The Led is doing as told but still the LCD display isn't.

One thing I have noticed in the simulation is that when single stepping, after the component macro - led start, it is not A0 or A1 which lights up (red on the chip picture) but B1 and then after component macro - print number, A0 lights up. First, is this the right order, as B1 is connected to data and A0 connected to RS? Surely this is the wrong way round. Even if not, A1 which is connected to Enable never lights up. Doesn't it need enabling first?

Forgive me if these are dumb questions but as mentioned I am a beginner.

I have attached the simplified program as theres no point in trying to troubleshoot the unnecessary items on the previous one.

I appreciate your help so far.

Cheers

Andy
Attachments
5. Digital clock.FCF
(7 KiB) Downloaded 275 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: LCD not working, Help needed please

Post by medelec35 »

I have altered your flowchart so it should work with 8MHz internal osc, which is the highest speed (except 48MHz if internal PLL is enabled). So clock speed was changed from 10MHz to 8MHz. To set internal osc speed, a Cbox with osccon=0x70; was required.
Hope this will work your LCD now.
Attachments
5. Digital clock V1.FCF
(7.5 KiB) Downloaded 308 times
Martin

A_Smith
Posts: 7
Joined: Tue Oct 26, 2010 4:59 pm
Contact:

Re: LCD not working, Help needed please

Post by A_Smith »

IT WORKS.

Thanks very much Medelec35, I really appreciate it. I did have to make some other changes too so for anyone else struggling I should also mention that to get it working I had to move the data pins around because if running in 4 bit mode (which flowcode does) you have to use DB4,5,6&7 of the LCD rather than DB0,1,2&3. See below for the pin layout which works and the attached flowcode file.

Port B Bit 0 - Data 0 (Pin 11)
Port B Bit 1 - Data 1 (Pin 12)
Port B Bit 2 - Data 3 (Pin 13)
Port B Bit 4 - Data 4 (Pin 14)
Port A Bit 0 - RS (Pin 4)
Port A Bit 1 - Enable (Pin 6)
Ground - VSS (Pin 1) V0 (Pin 3) R/W (Pin 5) LED - (Pin K)
VDD (from Pickit 2) - VDD (Pin 2) LED+ (Pin A)

Once again, Thanks very much and I hope this also helps others.

Cheers

Andy
Attachments
LCD Test working on PIC18F2550.fcf
(7.5 KiB) Downloaded 333 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: LCD not working, Help needed please

Post by medelec35 »

Your welcome and Yes you are correct about 4bit mode using the upper bits.
sorry I was solely concentrating on you flowcode, and did not even look at your pin connections.
I an glad it's working for you now.
At least with correct configurations is a step in the right direction.
You know if that's OK, then rest must be hardware.
Anyway I will mention about driving LCD when I update
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
Martin

Post Reply