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.

Attaching a Displaytech 161A LCD to an Atmega16

Status
Not open for further replies.

Odysseas

Member
Hello everyone,

I am attempting to attach my Displaytech 161A (**broken link removed**) to an Atmega16. I have not succeeded so far. The 161A is an 8-bit display.

I have used the specs of this table found in the help file of my compiler:
Code:
LCD DISPLAY	PORT
DB7	PORTB.7
DB6	PORTB.6
DB5	PORTB.5
DB4	PORTB.4
E	PORTB.3
RS	PORTB.2
RW	Ground
Vss	Ground
Vdd	+5 Volt
Vo	0-5 Volt

As already suggested for some 8-bit displays, I have tried to both leave db0-3 unconnected or tie them to ground. Neither worked.

Just in case somethings wrong with that: Here is the code for the Atmega:

Code:
$regfile = "m16def.dat"
$crystal = 8000000

Config Lcd = 16 * 1

Do

Display On
Cls
Lcd "Hello world..."
Wait 2
Cls
Lcd "Hello me..."
Wait 2

Display Off

Loop

Can anyone help me with this?
 
Well, I can't comment on the code specifically since it appears to be BASIC.

You should verify the connections - BASIC is making assumptions about the pinout.

Secondly, check contrast. I've had the situation where I couldn't get the LCD to work and it turned out I just had to turn the contrast up.

Finally, I'm a little skeptical of the init sequence that canned LCD code does. some of the H44780 controller clones can be a bit fussy about that. If the clock frequency is different that what library code expects it won't work correctly.
 
What am I supposed to do with the left ports of the display?
 
The contrast is controlled through the voltage applied to V0, is that correct? If so, I will obtain full contrast by connecting V0 to VDD? Because that is what I have done.

I have also used a method to tell the compiler which ports of the display are connected to which ports of the microcontroller. But I still can not see anything on the display.

Is there a possibility that the atmega16 is not compatible with these 8-bit displays at all?
 
Odysseas said:
The contrast is controlled through the voltage applied to V0, is that correct? If so, I will obtain full contrast by connecting V0 to VDD? Because that is what I have done.

In that case it won't work - you MUST use a preset to adjust the contrast, strapping it either way means it doesn't work.
 
Odysseas said:
The contrast is controlled through the voltage applied to V0, is that correct? If so, I will obtain full contrast by connecting V0 to VDD? Because that is what I have done.

A LCD with proper contrast voltage(using a VR) would show a row with all black rectangles if connected to power only. I don't know if all LCDs do that but most of mine does. So this might be the first step you need to confirm and sets the VR until a row of rectangle blocks appears.

Note: Adjust to make these blocks just visible. Too dark then you might not see the actual display characters.

Odysseas said:
Is there a possibility that the atmega16 is not compatible with these 8-bit displays at all?

Absolutely not. LCDs(types with HD44780 chips and yours also) work fine with any sort of common microcontroller/microprocessors provided one follows the timing requirement of commands sent to LCD. This is especially true during initialisation. Without proper initialisation, your LCD simply won't work.
 
Last edited:
eblc1388 said:
A LCD with proper contrast voltage(using a VR) would show a row with all black rectangles if connected to power only. I don't know if all LCDs do that but most of mine does. So this might be the first step you need to confirm and sets the VR until a row of rectangle blocks appears.

Bear in mind that the black rectangles are a sign the contrast is set too high, if you back it off until they are just faint rectangles then you'll be able to see the text when you get it working (and adjust it properly after that).

Absolutely not. LCDs(types with HD44780 chips and yours also) work fine with any sort of common microcontroller/microprocessors provided one follows the timing requirement of commands sent to LCD. This is especially true during initialisation. Without proper initialisation, your LCD simply won't work.

Yes, they work with anything - including a row of manual switches!.

You shouldn't really be messing around with LCD's unless you've read (and printed out) the EPE article.

https://www.epemag.wimborne.co.uk/lcd1.pdf

https://www.epemag.wimborne.co.uk/lcd2.pdf
 
What potentiometer would I use for this (value, lin/log)? I am sorry, I can not open the PDFs right now (at work) and the datasheet for the display does not seem to reveal anything useful, but I would greatly appreciate any help with that, so I could buy the potentiometer, because there is an electronics shop close to where I work. I know, I am impatient ;)
 
Odysseas said:
What potentiometer would I use for this (value, lin/log)? I am sorry, I can not open the PDFs right now (at work) and the datasheet for the display does not seem to reveal anything useful, but I would greatly appreciate any help with that, so I could buy the potentiometer, because there is an electronics shop close to where I work. I know, I am impatient ;)

It's not terribly critical, 10K or 4.7K should be fine. Check my LCD PIC tutorial for an example, look at the hardware pages for a diagram.
 
Okay, I have connected the contrast through a pot and pulled RS high with 10k. I can see something, but it is only black blocks, no matter if a microcontroller is connected or not. I assume something is wrong with the code???
 
Odysseas said:
Okay, I have connected the contrast through a pot and pulled RS high with 10k. I can see something, but it is only black blocks, no matter if a microcontroller is connected or not. I assume something is wrong with the code???

Yes, that's a sign it's not getting initialised, have you tried looking for code to download?, AVR's aren't as popular as PIC's, but there must still be plenty of LCD code available for them.
 
Hi,

Just a tip, sometimes, using 4-bit mode...leaving D3-D0 unconnected causes problems, I think this is down to the LCD, but I don't know why people leave them unconnected...floating inputs is just a bad idea. Connect the unused inputs to GND. it can't hurt, it just stops them floating and picking up god knows what noise when you're setting up for 4-bit mode (so it ignores the lower nibble).

Is your micro running at 5v as well? Not sure if 3.3V I/O's would cut it on a 5V LCD.
As for Contrast, any preset will do, preferably 10k+, its just a voltage divider, and the Vo contrast pin hardly draws any current at all. You could add a 100k resistor in series with it (VCC side) to use the full range of the pot (usually anything above 1v to Vo is useless). When you've powered it up and initialiased it...give the pot a wiggle.....16x2 lcd's have a test pattern where the *top* line is just black blocks (unless the LCD is negative :D )....if the contrast is set too low, ALL blocks will be black. because your LCD is 16x1 the test pattern will look >>the same<< as if the contrast is set too low. I doubt thats a problem anymore though. Also, the 'RS' pin is command/data. Pulling it high will (if I'm not mistaken) only allow instructions to be written, so the best you'll get there is a blank screen (no black blocks) because you can't write data for it to dispaly, which is useful for debugging. But...as I mentioned above...you'll get the black blocks if the contrast is set too low.

To be honest, I've spent ages debugging an LCD circuit before, and in my case, its always been hardware, just silly mistakes like wrong connections. Connect everything that needs to go to GND, then the VCC pin, then contrast (Vo) so you're just left with the 4 data lines, R/W, and E. Then connect them up, fire up your micro. If you've checked everything several times, its software.

As for your micro not being 'compatable' with the LCD, I seriously doubt it.

Let us know how you get on.

Blueteeth.

Ps: Sorry if I've repeated some stuff that Nigel has suggested, don't wanna steal anyones thunder, he's probably the best person to ask about micros+LCD's anyway.
 
Blueteeth said:
Just a tip, sometimes, using 4-bit mode...leaving D3-D0 unconnected causes problems, I think this is down to the LCD, but I don't know why people leave them unconnected...floating inputs is just a bad idea. Connect the unused inputs to GND. it can't hurt, it just stops them floating and picking up god knows what noise when you're setting up for 4-bit mode (so it ignores the lower nibble).

Usually these unused D0-D3 lines are not grounded, with a good reason. If you read the HD44780 datasheet, the D0-D7 input lines are stated as "input, MOS with pullup", and thus would not float if left unconnected.

Pull these to ground would just increase the overall LCD current consumption with no benefit at all.

I have no idea about other LCD controllers except HD44780.
 
eblc1388 said:
Usually these unused D0-D3 lines are not grounded, with a good reason. If you read the HD44780 datasheet, the D0-D7 input lines are stated as "input, MOS with pullup", and thus would not float if left unconnected.

They can also be switched to be outputs, so grounding them (or connecting them to Vdd) would be a BAD idea.

It's normal to leave them 'floating', because (as mentioned by eblc1388) they already have pull-ups - so don't float!.
 
well, as I said, I guess its down to the LCD, most of the ones I have are fine when D3..D0 are left floating, but a couple get iffy. And yes, outputs to ground isn't a good idea, but I never read from them, just the usual 'maximum delay' between commands/data.

I didn't want to confused things, just trying to to help. Also, I don't usually use 4-bit mode, just a cheapy stripboard based shift-register, so I can use SPI.

All good advice though, cheers.

Blueteeth
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top