Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 16f628A -LCD Control

Status
Not open for further replies.
Hi Sarma. I changed the code again in V3 to have a 20ms delay on all actions. It's maybe too long for many of the actions but it will do for now. The specification sheet says that timings can be a lot less. I have this running now in simulation but not on the PCB I made. Is there something wrong with the configuarion word? Do I need to switch pullups on / off. This is very frustrating. All the circuits i have seen are very similar to mine.

hi Paul,
Ref delay loops, download this calculator from:
http://www.biltronix.com/picloops.html
 
Hi Eric. Thanks for that. Very useful. However I still can't get this thing to work on the PCB. Can anyone tell me why there is no reading on PORTB with a logic probe on just the PCB. However when I connect the LCD board PORTB goes high all pins?
Something is clearly being pulled high - why?
 
Hi Eric. Thanks for that. Very useful. However I still can't get this thing to work on the PCB. Can anyone tell me why there is no reading on PORTB with a logic probe on just the PCB. However when I connect the LCD board PORTB goes high all pins?
Something is clearly being pulled high - why?
hi,
This image from the LCD controller IC, note most pins are internally pulled up.

Do you have a wiring diagram to post.?
 

Attachments

  • AAesp02.gif
    AAesp02.gif
    34.1 KB · Views: 211
Only what I posted originally.

Here it is again.

hi,
I did find that original.
I see that you have pins 15 and 16 connected to +V and 0V, where is the LED back light current limiting resistor, you seem to be shorting out the +5V.???

Disconnect 15 and 16 and retry.
 
15 & 16 have a 10k variable resistor across them. This just adjusts the contrast. Surely without 15 & 16 you want see anything on the LCD at all?
 
believe me, if everything works at the first stretch, either one should be perfect in the approach , having fully got a grip of the parameters of various items under use, or otherwise he becomes overconfident that what all he does, works
.
We learn only by mistakes. Frustration should NOT ride on your mind. develop logical thinking. Every time you are doubting the hardware. You have used the MCLR pin also as an output. please check how to use a generally defined input, as output.

Any software, it is Joked, will do what written lines say, and NOT what one wants.
 
Last edited:
15 & 16 have a 10k variable resistor across them. This just adjusts the contrast. Surely without 15 & 16 you want see anything on the LCD at all?

hi Paul,
Without the back light pins connected you should see the pixel blocks or the characters on the display, the back light is only required in a dark environment
EDIT:
Do you see the pixels when you adjust the pot.???
 
Last edited:
To prove my sanity I built this test rig and can prove that the LCD is working ok. I can set the control signals and data and everything works as it should. So I know the LCD is fine. ;-)
 

Attachments

  • LCD_Tester.jpg
    LCD_Tester.jpg
    118.7 KB · Views: 292
Yes I can see all of line 1. It's dark. I can also adjust the contrast.

That's an indication that the LCD isn't getting initialised correctly, once initialised you don't get the line of solid blocks on the first line. Even if you don't connect the LCD to a processor, adjusting the contrast produces the solid blocks on line one.
 
Ok so I have now put a stop after the LCD Initialise.

.....
functionset bcf PORTA,0 ;RS line to 0 (Port A, bit0 - Pin 17 pic to pin 4 LCD)
bcf PORTA,1 ;R/W line to 0 (Port A, bit 1 - Pin 18 pic to pin 5 LCD)
movlw 3C ;Function set command (00111100 - 8 bit transfer, 2 line mode, 5x10 dot format)
movwf PORTB ;Put this code on the data lines Port B
call pulse_E ;Call the routine to pulse the E line (Port A bit 2)

call Delay20ms ;Give it time to get it

stop goto stop ;Stop the program


......

So I should see the control signal on PortB.

Nothing at all showing on the logic probe with the LCD disconnected. Connect the LCD and all pins on PORTB go high.
 
Ok so I have now put a stop after the LCD Initialise.

.....
functionset bcf PORTA,0 ;RS line to 0 (Port A, bit0 - Pin 17 pic to pin 4 LCD)
bcf PORTA,1 ;R/W line to 0 (Port A, bit 1 - Pin 18 pic to pin 5 LCD)
movlw 3C ;Function set command (00111100 - 8 bit transfer, 2 line mode, 5x10 dot format)
movwf PORTB ;Put this code on the data lines Port B
call pulse_E ;Call the routine to pulse the E line (Port A bit 2)

call Delay20ms ;Give it time to get it

stop goto stop ;Stop the program


......

So I should see the control signal on PortB.

Nothing at all showing on the logic probe with the LCD disconnected. Connect the LCD and all pins on PORTB go high.

hi Paul,
Lets take a step back.
Write a simple noddy program to set PORTB high and low with a 0.5Sec delay between each high/low, connect an LED via a 300R resistor to a PORTB pin and 0V and lets see if the PIC is running.

EDIT:
This is your V3 program in Oshonsoft.
Note: 0x48 ['H'] on the PORTB output
 

Attachments

  • AAesp04.gif
    AAesp04.gif
    16.2 KB · Views: 318
Last edited:
Hi Eric. I use a Velleman programmer which has 6 led's on port B RB0-RB5. I can run the program with stops on the velleman and see everything fine. (Except the control lines). As you say the code is running on the simulator and I can see the hello message. I have stopped it after the initial setup for 8bits etc... and see 001111 (cant see the next two bits but im sure theyre ok) and done subsequent stops through the program until the letter H (48 hex - 000100 on the velleman). Everything looks fine.
 

Attachments

  • LCD_PaulV3_stop.asm
    4.5 KB · Views: 184
hi,
I dont see any decoupling caps on the circuit diagram across the+5V and 0V, you should have 100nF and a 10uF.
 
Cracked it! - Having borrowed an oscilloscope last night I have found the problem. The Xtal was dead. I have replaced the xtal (which was bought new from maplin) and hey presto away it flew with HELLO on the LCD. I'd like to give everyone a big thank you for helping me. My next phase is to get a menu system working. Button1 displays message 1, button2 displays message 2 etc... Anyone have any ideas? ;-)

Many thanks - Paul
 
Cracked it! - Having borrowed an oscilloscope last night I have found the problem. The Xtal was dead. I have replaced the xtal (which was bought new from maplin) and hey presto away it flew with HELLO on the LCD. I'd like to give everyone a big thank you for helping me. My next phase is to get a menu system working. Button1 displays message 1, button2 displays message 2 etc... Anyone have any ideas? ;-)

Many thanks - Paul
hi Paul,
Sometimes it a good idea to check the basics by using simple diagnostic test program.
What are you asking for regarding the push buttons.????
Program or wiring ?
 
Its really the asm I guess. I have the 3 switches wired as per the circuit on RA3 RA4 RA5. So I guess I need to iniialise the pins for input etc etc, and then instead of running the existing program run a routine first that wil look for a button press and then then call a routine that displays message 1 etc etc. There is a lot of code that could be reused here so I just need to 'phathom out if then else'.

I guess it goes something like

Set all ports
Initialise LCD
Dispaly Welcome message with button options
Wait for button press
If button 1 then message1
If button 2 then message 2
If button 3 then message 3
Go back to display welcome message.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top