LOADING ...

How a Character LCD works Part 1

672K+ views   |   32K+ likes   |   220 dislikes   |  
13:59   |   Apr 26, 2017

Thumbs

How a Character LCD works Part 1
How a Character LCD works Part 1 thumb How a Character LCD works Part 1 thumb How a Character LCD works Part 1 thumb

Transcription

  • Welcome to another episode of the 8-Bit Guy.
  • So, in this episode I want to show you how character LCDs work.
  • Now, these things have been around since at least the 1980s.
  • You can find them in all kinds of electronics like old computers, music keyboards, synthesizers,
  • calculators, early mobile phones, laser printers, and are still widely used today on servers,
  • and for hobby projects with microcontrollers.
  • In fact, they are ridiculously cheap now and you can find them all over ebay for just a
  • few Dollars in just about every shape, size, and color you could want.
  • They come in as small as 8 by 1 characters.
  • Some other common sizes are 8 by 2, 16 by 2, and 20 by 4.
  • These screens should all have either 14 ot 16 pins on them.
  • They can be arranged in different ways, but they should be labelled 1 through 14.
  • I’m going to start by showing you what each of the 14 pins do.
  • The first pin is ground.
  • The next pin is +5 Volts.
  • So these two wires are essentially what gives the screen power.
  • The next pin receives an analog voltage to set the contrast of the screen.
  • Typically this is done by connecting it to the middle pin of a potentiometer.
  • Then the other two leads on the potentiometer go to +5 volts, and ground.
  • So the signal you are feeding it will always be somewhere in between those numbers depending
  • on where you turn the knob.
  • The next pin is register select.
  • So the screen can accept two types of information, one is text data.
  • That’s basically just putting ASCII characters on the screen, the other option is instructions,
  • which tell the screen to do stuff like turn the cursor on, initialize the display, create
  • graphics characters, things like that.
  • So imagine you had a toggle switch you could hook up this pin to the center of the switch
  • and then connect 5 Volts to one side, and ground to the other.
  • That way when you move the swtich back and forth it will pull the line high or pull the
  • line low, telling it which type of data you want to send it.
  • The next pin is for read/write.
  • Yes, besides just sending information to the screen, you can actually read information
  • from the screen.
  • And you have to pull it high for reading, or low for writing.
  • The next pin is the enable pin.
  • I’ll come back to this in just a minute.
  • The next 8 pins are the data bits 0 through 7 which represent an 8-bit binary number.
  • All of these pins need to be set either high or low, just like the last few.
  • So back to that enable line.
  • This is the final piece of the puzzle.
  • Basically, once you’ve set all fo the other pins exactly how you want them, then you set
  • this line high and that will feed all of the information into the screen.
  • Also, some screens have 16 pins, and those are to accomodate a backlight and so that’s
  • just the power source for the backlight.
  • I’ve hooked these screens up to all sorts of things, and I plan no showing you how to
  • hook one up to a Commodore 64 here shortly.
  • But, before I do that, it occurred to me that it might be possible to control these screen
  • without any sort of computer at all, using nothing but toggle switches.
  • So I set out to construct such a device.
  • So I played around with my design here in a paint program and this is what I came up
  • with.
  • Obviously I’ll connect these two pins to power and ground.
  • This one for contrast.
  • A toggle switch for register select.
  • The read/write pin will go straight to ground because I’m not going to be reading anything,
  • I’m only going to be writing data.
  • Then I’m going to use a pushbutton on the enable line. and then, of course, 8 toggle
  • switches for the data lines.
  • So,I went to my local Fry’s Electronics to pick up some toggle switches.
  • I could have gotten them a lot cheaper on line but I didn’t want to wait for shipping.
  • This single pole double throw ought to work fine.
  • I would also need a push button for the enable line, so I picked this one.
  • So here’s all of the stuff I picked up.
  • I got this nice little project box to mount everything in.
  • I’m going to use this 16 by 2 LCD that I pulled out of an old ISDN modem years ago.
  • I’m just going to test-fit the LCD screen.
  • OK, so here’s all the switches mounted.
  • This reminds me of an old Altair computer, only this will be a lot simpler.
  • So here’s the potentiometer for the contrast control.
  • And here’s the pushbutton.
  • I also have a nice little knob to fit on the contrast control.
  • I printed out some labels so that I could better see what each switch is for.
  • And here’s what it looks like so far.
  • Now it’s time to start wiring up the inside.
  • So I’m just going to use a big piece of solid core wire and mount it across all of
  • the leads on these switches.
  • Now that those are all soldered on, I can actually use the spaces in between to connect
  • all of the other wires that need to connect to either ground or +5 volts.
  • I’m also going to need a power cable.
  • Since USB is 5 Volts, I’m just going to cut the end off of those USB cable, then I’m
  • going to wire up a barrel jack to the end.
  • And, of course, I’ll need a barrel jack on the back of the box so I’ll install that
  • too.
  • When I need a bunch of small wires of different colors, I usually just take an old scrap multi-conducter
  • cable like this one and strip it back and cut off a bunch of wires.
  • Unfortunately, when I started soldering wires to the LCD, I noticed that one of the solder
  • pads was missing and I couldn’t solder to it.
  • So, I’ve had these little screens around forever and desoldered and resoldered to them
  • probably dozens of times because I’ve used them in a lot of different projects, you know,
  • just temporarily.
  • And that’s an unfortunate side effect of continually desoldering and soldering to those
  • little pads.
  • Sometimes they just pull right off.
  • However, I do have another one just like it so I’ll use that one inside.
  • But it does have some ribbon cable still attached so I’ll need to desolder that.
  • So after I removed the ribbon cable and cleaned up the flux on the board I noticed that it
  • was also missing not one, but TWO solder pads.
  • So I simply won’t be able to use those.
  • I do have another LCD but it is a smaller 8 by 2 character display and much too small
  • for the hole I made.
  • So it looks like I’ll have to use this larger 20 by 4 character display instead.
  • It will barely fit.
  • It does have a pin header soldered into it, but after the bad luck I just had with the
  • other two screens, I’m just going to leave that in place and solder wires directly to
  • the pins like this.
  • And once I’m done I’ll run some heat shrink over the pins just to be on the safe side.
  • I think that’s going to work out just fine.
  • So, I’ve cut a larger hole in the box.
  • It’s not as elegant as the first one because I had too much stuff in the way this time.
  • Now all that’s left is to connect up all of these wires to the right switches.
  • There is one problem, though.
  • The push button switch only has 2 leads, not 3.
  • So there is no way to alternate a signal between high and low.
  • If you leave a pin unattached, it’s called a floating pin, and that’s bad because it
  • can randomly pick up static in the air and alternate between high and low on its own.
  • So what I’ll do is attach a resistor to ground.
  • That will keep it pulled low.
  • Then when I push the button it will over power the resistor and pull the line high.
  • So let’s try it out.
  • I’ve got a chart printed out to show me binary digits for ASCII characters, and a
  • few sheets showing all of the instructions for the screen.
  • But things didn’t go exactly to plan.
  • All right.
  • So, here’s the deal.
  • So this is actually a normal thing to see when you fire up an LCD screen.
  • Just have these little two lines kind of lit up.
  • The contrast does work.
  • However, I couldn’t get anything else to work, until eventually I realized that all
  • of my buttons are upside-down.
  • My switches are upside down.
  • This is upside-down.
  • All of these are upside-down.
  • So, I’m going to have to think about this for a moment.
  • So, I want to turn on the display.
  • So I’m going to move, I want it on instruction, so yeah, it’s actually going to be opposite
  • of where I need.
  • And this should be the sequence to initialize the display.
  • And bam!
  • It works!
  • It looks like we need to adjust the contrast a little bit.
  • So, now we want to set the data path.
  • OK.
  • Now let’s see if we can send some data.
  • OK, so one of the things you’re probably going to notice is that every time I push
  • one of these, I get more characters than I wanted to.
  • And that’s because of a bounce problem.
  • So let’s talk about bounce.
  • When you have two pieces of metal on a switch coming together, now it may seem like the
  • touch instantaneously, but in reality they actually bounce every so slightly when they
  • first touch.
  • Now, it’s imperceptible to use humans, but digital electronics are fast enough they can
  • actually see the bounce and to them it seems like you’ve pushed the button multiple times.
  • So what we need to solve that is to add a capacitor to the switch.
  • That slows down the transfer of power because it takes a short delay for the capacitor to
  • charge and discharge, thus smoothing out the behavior of the switch.
  • So let’s test it out again.
  • All right, so we’re going to try this again.
  • Power it on.
  • There we go.
  • OK, we’ll set the font.
  • And now, let’s try sending some characters.
  • OK.
  • It looks like our debounce is working.
  • We’re sending characters without repeats now.
  • OK, so this is the inside after everything is done.
  • Now It’s time to finally screw the bottom plate on.
  • I can’t easily rotate my switches around, but I can change the labels on here so that
  • the register select is showing correctly.
  • Unfortunately my data bits are still upside down.
  • I’ll put the contrast knob on now.
  • All right, so I’ve written out my name here.
  • So, one of the interesting things that I’m going to show you is if you want to cursor
  • around, you’re going to want to set to instruction mode and then zero zero zero one.
  • OK, that should let me move the cursor to the left.
  • And I can change direction by flicking this switch and I can move it back to the right.
  • However, instead of moving the cursor, I can move the entire screen by moving this switch.
  • Look at that.
  • And I can move it back the other direction.
  • So that’s just some of the interesting things that you’ll learn playing with this.
  • And you can see the contrast adjustment seems to work pretty well.
  • So here’s one final look at this device.
  • And here’s what it looks like in the dark, since this particular screen is backlit.
  • All right, so I think this is a pretty cool little educational device.
  • You know, learning how to use the binary information and key it into the screen is probably a really
  • good learning tool for someone getting into digital electronics.
  • Anyway, I was going to show you how to connect this up to a Commodore 64 both on the cartridge
  • port and on the user port.
  • However, this video is getting a little long.
  • So I’ve decided to split that off into a part 2.
  • So, hopefully you’ll stick around for that.
  • And I hope this episode wasn’t too technical or boring or anything like that.
  • Because, I’d kind of like to make a little more technical videos like this every now
  • and then but you know I run the risk of going too deep, and that might not work for some
  • people, so let me know what you think in the comments, and I’ll see you next time!

Download subtitle

Description

Support this channel on Patreon
https://www.patreon.com/8bitguy1

Visit my website:
www.the8bitguy.com

In this episode I take a look at Character LCD screens and how to control them.

Trending videos