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.

LCD Displaying an odd character

Status
Not open for further replies.

tom_pay

Member
Hi All,

I have built a 2 wire LCD interface, which takes two pins from a PIC, clock and data, and with a shift register converts the signal to the parallel format required by the LCD.

After building this I tried to get it to display something, however it did not completely work. All of the characters, bar one, display perfectly fine. Though, one character (2nd on bottom row) displays a random character which occasionally changes. It does not matter what is supposed to be there, but something odd almost always comes up. I tried a different PIC chip and it worked, but when power was disconnected and reconnected the odd character was back.

Can anybody point me in a direction that can resolve this problem? Do I need a new LCD module? Or is it something simple in the program?

Thanks heaps,

Tom

PS I have attached a copy of the circuit and program.
 

Attachments

  • 2 Bit LCD Display.c
    1.6 KB · Views: 288
  • Circuit.jpg
    Circuit.jpg
    52.3 KB · Views: 415
First I would try the lcd module connected in 8 bit mode connected directly with the chip using KNOWN working software.

Secondly.. Try a pullup resistor on RA4 (the only pin on the chip that is open collector)

If it's not the display... try to AND the Data and E signals using two transistors, rather than the diode / resistor setup you are using
 
Last edited:
Thanks for that, I shall try that in the morning.

Adding a pull up resistor to RA4, will this affect the diode/resistor AND gate?

Tom
 
Probably.... I've never had success with two wire hookups, I always use a separate 'E' pulse...

That's why I recommend two transistors as an AND gate then you should have a clean 'E' pulse.

test the display first though... It MIGHT be faulty...
 
This is one of those things where I'm gonna suggest a more suitable part for the job. The 74LS174 is a D-type flip flop. Not a serial shift register. A 74HC595 SPI In/Parallel Out latch would be much better suited for this IMO as this chip is a serial shift register.

**broken link removed**

Also, this would be a much better way of coding a software SPI bit bang routine -

Code:
void LCDWriteSPI(unsigned char a)
{
    unsigned char b = 0;
    for(b = 0; b < 8; b++)              //do 8 times
    {
        DAT = 0;                        //default MSB = 0
        if(a & 0b10000000)             //does MSB = 0?
        {
            DAT = 1;                    //no, send 1
        }    
        CLK = 1;                        //strobe clock
        CLK = 0;
        a = a << 1;                     //shift bits
    }
    CLK = 0;                            //default clock low
    DAT = 0;                            //default data low
}

It defaults the data line to 0 unless the bit to be sent is a 1. It does this before the clock line is strobed so the SR won't even see that the data line is being defaulted to 0.
 
Last edited:
Jon,

Tom's circuit and code look correct. If you're interested, the source for this very old and rather clever method comes from Myke Predko and is documented here.

Regards, Mike
 
I'm just curious as to WHY. Why wire up a part into something it isn't when you can just buy the actual part that's made to perform the function?
 
Because he had one on the bread board and was to lazy to change it. Or just because he was old school and like wiring them up as a shift register.

Or just to show he could. They are made so as to be used as a shift register and are sold as such. But I really think Myke Predko used it because it worked great as a two
wire interface.

Here what he had to say about it
I normally use a 74LS174 wired as a shift register (as is shown in the schematic diagram) instead of a serial-in/parallel-out shift register. This circuit should work without any problems with a dedicated serial-in/parallel-out shift register chip, but the timings/clock polarities may be different. When the 74LS174 is used, note that the data is latched on the rising (from logic "low" to "high") edge of the clock signal.
**broken link removed**

And the rest of the story great reading
**broken link removed**
 
I'm just curious as to WHY. Why wire up a part into something it isn't when you can just buy the actual part that's made to perform the function?

Because that's the part Myke Predko used. When I tested that circuit several years ago I used a 74HC164 instead of a 74HC174.

Anyway, your 74HC595 circuit makes a good LCD interface too. I sometimes use a 74HC595 interface variation like the one shown below just to get a little more functionality from the part, but at the cost of yet another I/O pin.

Regards...
 

Attachments

  • 74HC595 4-bit Interface.png
    74HC595 4-bit Interface.png
    36.9 KB · Views: 502
  • 74HC595 8-bit Interface.png
    74HC595 8-bit Interface.png
    17.1 KB · Views: 391
Last edited:
I have been slowly working through one of Myke Predko’s books, he is a very good author, and this 2 bit interface was one of the projects in it. I had experimented and changed the coding and eventually I got it to work, to become more familiar with the C language and to try and make it a tiny bit smaller.

As to the flip flop instead of the shift register, I live in a regional town and due to the scarcity of components I flicked through the future chapters of the book to see what I needed and when I was in the city bought the necessary bits. So the flip flop was the only available component I had that would fit the role. Anyway, where is the fun in using a component for what it was designed for? :D

Is it possible that in all my testing and re-using of this screen that I have damaged it? It has spent most of its time in either an anti-static bag or on the breadboard.

Thanks for your help,

Tom
 
Last edited:
tom_pay said:
As to the flip flop instead of the shift register, I live in a regional town and due to the scarcity of components

This is why we have Mouser ;)

https://www.mouser.com/ProductDetai...=sGAEpiMZZMutXGli8Ay4kI528CFa1ljGXnIIpebTik4=

Anyway, where is the fun in using a component for what it was designed for? :D

Quite honestly, I get much more satisfaction out of being productive in my design work and minimizing the head scratching/hair pulling/headache factor and just see my stuff work as it is designed to work. Lord knows there are more than enough of the headaches in debugging software...not much need to compound it with hardware issues that stem from the "But it MUST work because that's all I have available/can afford" attitude. ;)
 
Last edited:
The dilemma of why I used the flip flop is getting a bit repetitive and is quite trivial. The way it is connected works as it is supposed to.

Any ideas on how to fix the strange character on the LCD?
 
After a bit of head scratching and testing.............

I tested the LCD on a 4 bit transfer method and the problem was still there. However, I made up a different program to send in one message and then another. The first message goes through perfectly fine, whereas the second message has the same odd character in the same place.

Does this mean anything? Other than more head scratching :D
 
That is a bit tricky, it is supposed to be an 'r' however it was a blank, then after disconnecting the power and shorting the caps it changes. None of these are proper characters on the datasheet.

It is the same spot every time, but only on the second message.
 
Done that, every character worked.

After writing and displaying the message if I tell it to go back and rewrite the dodgy digit, it works.

Does this mean that the display is no good?

Im so lost. Good fun though :D
 
Last edited:
Hmm OK,

I dont have another one at hand, Ill have to order one online soon. That Mouser website looks good.

How can I avoid this happening next time?
 
Status
Not open for further replies.

Latest threads

Back
Top