16X2 LCD
Moderator: Benj
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
16X2 LCD
Hi there,
I am trying to run 16x2 LCD which runs fine when i connect it with port B. but with port A the enable bit is a little problematic, all connections of LCD on port A including rs bit and enable bit does not work, but if i connect the enable bit with some other port it works fine, my hardware needs the lcd to be connected to port A, how can i resolve this?
I am trying to run 16x2 LCD which runs fine when i connect it with port B. but with port A the enable bit is a little problematic, all connections of LCD on port A including rs bit and enable bit does not work, but if i connect the enable bit with some other port it works fine, my hardware needs the lcd to be connected to port A, how can i resolve this?
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: 16X2 LCD
Hi
Using the LCD on Port A is dependant on what device you are using
I have used it on Port A with the 16F877A, but it cannot be used with the 16F88 for example
See Martins comments on a similar question I posted a while ago
http://www.matrixmultimedia.com/mmforum ... lcd#p24562
Using the LCD on Port A is dependant on what device you are using
I have used it on Port A with the 16F877A, but it cannot be used with the 16F88 for example
See Martins comments on a similar question I posted a while ago
http://www.matrixmultimedia.com/mmforum ... lcd#p24562
1 in 10 people understand binary, the other one doesn't !
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: 16X2 LCD
Hi greentech,
RA4 is open Drain, which means you need a pull up resistor connected between RA4 and +5V.
Something like 4K7 or higher. (will only need to be lower if driving a LED)
So when RA4 is at logic 1 the output transistor is switched off, so its pin is allowed to be pulled high since it acts like an open switch.
When RA4 is at logic 0 , the output transistor is switched on so the pin is like a short circuit to GND
The odd thing is the enable is connected to RA5 by default.
If you have an LED board you can connect that up, and set port to 255 and flash at 1Hz, to check RA4 and RA5. (RA4 will be dimmer as stated above)
So if RA5 doe not light, faulty connection/chip etc. You could try continuity tests to determine this.
Martin
RA4 is open Drain, which means you need a pull up resistor connected between RA4 and +5V.
Something like 4K7 or higher. (will only need to be lower if driving a LED)
So when RA4 is at logic 1 the output transistor is switched off, so its pin is allowed to be pulled high since it acts like an open switch.
When RA4 is at logic 0 , the output transistor is switched on so the pin is like a short circuit to GND
The odd thing is the enable is connected to RA5 by default.
If you have an LED board you can connect that up, and set port to 255 and flash at 1Hz, to check RA4 and RA5. (RA4 will be dimmer as stated above)
So if RA5 doe not light, faulty connection/chip etc. You could try continuity tests to determine this.
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: 16X2 LCD
Have you toggled the the whole of port A at 1Hz and checked each pin goes from 0 to 5V and back to 0V?
Also could you have two pins shorted together?
A good way would be to create a simple light chaser.
If was me and I can't get the LCD to work on a port, then I would first confirm each pin is capable of going high then low. If it can I would concentrated on wiring between target device and LCD. I would check connections between each pin of microcontroller and LCD, for continuity, and shorts across adjacent pins.
Do you get the usual row of black squares?
I may have access to 16f877a on Monday, If so I can confirm if LCD eblock works on portA ok although I don't see why it won't.
Did You want me to take a look at your flowchart?
Although I can't see there being an issue with that.
Sorry Can't think of anything else to try.
Edit just remembered:
Sorry about that.
Martin
Also could you have two pins shorted together?
A good way would be to create a simple light chaser.
If was me and I can't get the LCD to work on a port, then I would first confirm each pin is capable of going high then low. If it can I would concentrated on wiring between target device and LCD. I would check connections between each pin of microcontroller and LCD, for continuity, and shorts across adjacent pins.
Do you get the usual row of black squares?
I may have access to 16f877a on Monday, If so I can confirm if LCD eblock works on portA ok although I don't see why it won't.
Did You want me to take a look at your flowchart?
Although I can't see there being an issue with that.
Sorry Can't think of anything else to try.
Edit just remembered:
So in theory that pull-up is not necessary since the pull-up resistor is built in to LCDmedelec35 wrote: Whereas with 16F877A RA0 - RA5 are bidirectional.
Although RA4 is open drain, all lines of LCD except Enable (RA5) have pull-ups.
That's why LCD works on port A
Sorry about that.
Martin
Martin
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
Re: 16X2 LCD
I HAVE WITTEN A VERY SIMPLE PROGRAM IN A WHILE LOOP
LCD INITIALIZE,
PRINT ASCII "HELLO WORLD" and i get the usual row of black squares
I Haven't tested the light chaser prog, but i will do that now and let you know the updates.
thanks for looking into the problem.
LCD INITIALIZE,
PRINT ASCII "HELLO WORLD" and i get the usual row of black squares
I Haven't tested the light chaser prog, but i will do that now and let you know the updates.
thanks for looking into the problem.
- DavidA
- Matrix Staff
- Posts: 1076
- Joined: Fri Apr 23, 2010 2:18 pm
- Location: Matrix Multimedia Ltd
- Has thanked: 58 times
- Been thanked: 258 times
- Contact:
Re: 16X2 LCD
Hello,
Make sure your "Start LCD" macro call is outside of the loop and is only called once at the start of the program, else you will get the black squares.
Make sure your "Start LCD" macro call is outside of the loop and is only called once at the start of the program, else you will get the black squares.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 16X2 LCD
Hello,
Please can you attach your program and I will have a look for you. I'm guessing the problem is with the clock speed or config settings.
Any further component macro calls to the start function will have the effect of resetting and clearing the display. This can be used to recover the display in cases where interrupts or other non synchronous code is used to drive the display and the display has become corrupted due to two commands colliding.
Please can you attach your program and I will have a look for you. I'm guessing the problem is with the clock speed or config settings.
What David says is true as far as the LCD will not start up without calling the LCD Start macro in your program before sending any other commands to the display.Make sure your "Start LCD" macro call is outside of the loop and is only called once at the start of the program, else you will get the black squares.
Any further component macro calls to the start function will have the effect of resetting and clearing the display. This can be used to recover the display in cases where interrupts or other non synchronous code is used to drive the display and the display has become corrupted due to two commands colliding.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
Re: 16X2 LCD
BENJ I SOLVED IT, AND IT SEEMS TO WORK FINE NOW. I placed a pull up resistor at RA4 and now its working fine. clockspeed and other configs were alright.