+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 16

Thread: Attaching a Displaytech 161A LCD to an Atmega16

  1. #1
    Odysseas Newbie
    Join Date
    Sep 2006
    Location
    Kaufbeuren, Germany
    Posts
    71

    Default Attaching a Displaytech 161A LCD to an Atmega16

    Hello everyone,

    I am attempting to attach my Displaytech 161A (Datasheet here) 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?
    Seize the time, and seize it now!


  2. #2
    philba Good philba Good philba Good
    Join Date
    Mar 2006
    Location
    Seattle
    Posts
    1,887

    Default

    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.

  3. #3
    Odysseas Newbie
    Join Date
    Sep 2006
    Location
    Kaufbeuren, Germany
    Posts
    71

    Default

    What am I supposed to do with the left ports of the display?
    Seize the time, and seize it now!

  4. #4
    philba Good philba Good philba Good
    Join Date
    Mar 2006
    Location
    Seattle
    Posts
    1,887

    Default

    if you mean db0-db3, do nothing.

  5. #5
    Odysseas Newbie
    Join Date
    Sep 2006
    Location
    Kaufbeuren, Germany
    Posts
    71

    Default

    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?
    Seize the time, and seize it now!

  6. #6
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,769

    Default

    Quote Originally Posted by Odysseas
    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.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  7. #7
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    Default

    Quote Originally Posted by Odysseas
    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.

    Quote Originally Posted by Odysseas
    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 by eblc1388; 16th October 2006 at 08:44 AM.
    L.Chung

  8. #8
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,769

    Default

    Quote Originally Posted by eblc1388
    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.

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

    http://www.epemag.wimborne.co.uk/lcd2.pdf
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  9. #9
    Odysseas Newbie
    Join Date
    Sep 2006
    Location
    Kaufbeuren, Germany
    Posts
    71

    Default

    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
    Seize the time, and seize it now!

  10. #10
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,769

    Default

    Quote Originally Posted by Odysseas
    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.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  11. #11
    Odysseas Newbie
    Join Date
    Sep 2006
    Location
    Kaufbeuren, Germany
    Posts
    71

    Default

    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???
    Seize the time, and seize it now!

  12. #12
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,769

    Default

    Quote Originally Posted by Odysseas
    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.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  13. #13
    Blueteeth Good Blueteeth Good Blueteeth Good
    Join Date
    Oct 2003
    Location
    Hertfordshire, UK
    Posts
    691

    Default

    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 )....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.
    Inconsistency is the key to flexibility!

  14. #14
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    Default

    Quote Originally Posted by Blueteeth
    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.
    L.Chung

  15. #15
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,769

    Default

    Quote Originally Posted by eblc1388
    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!.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

+ Reply to Thread
Page 1 of 2
1 2 Last

Tags for this Thread