Go Down

Topic: ATTINY & LCD (Read 5 times) previous topic - next topic

pratto

thanks for the good tips fellas. i have since been reading, both on adafruit and newhaven about I2C LCD displays.
with the adafruit version in mind, do i understand correctly that the LCD plugs into the backpack, and that only 2 wires (plus vdd & grd) connect the backpack to the m.c. ?
if so, will an attiny (8 pin) do the trick and allow me to output text to the LCD ?

strykeroz

#6
Nov 22, 2012, 04:53 am Last Edit: Nov 22, 2012, 05:07 am by strykeroz Reason: 1

do i understand correctly that the LCD plugs into the backpack, and that only 2 wires (plus vdd & grd) connect the backpack to the m.c. ?  if so, will an attiny (8 pin) do the trick and allow me to output text to the LCD ?
Yes for how it's connected, though you will need a pair of 4k7 pull-up resistors on the two communications lines (read about I2C and you'll find out what that is about).  I've not actually tried what you're attempting but it looks feasible.  

The TinyWireM library will provide the I2C master functionality for you - I have the required bits here so tonight I'll run up a sketch and see what headaches emerge - will report back here.

Cheers ! Geoff

Edit: it must be possible - there's even a library modified to run the LCD on ATtiny85 :) here (link from this playground article).
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

bperrybap

pratto,
It is no problem.
You can drive it with only 2 pins including backlight on/off control.
It will take some additional external hardware : a shift register a resistor, a diode,
and a transistor another resistor and a cap, if you want backlight control.
but it is cheap since shift registers cost about 20 cents and resistors, diodes
and caps are about 1 cent.

Go get this library: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
You will want to use the LiquidCrystal_SR2W interface.
(I'm the author of the SR2W code)
If you look at the file LiquidCrystal_SR2W.h it has a wiring diagram with parts.

The SR2W code will drive a hd44780 display faster than the stock LiduidCrystal can
even though the SR2W code is using a shift register and the stock LiduidCrystal code is
using 4 bit mode.

Below is a more recent set of diagrams that are not yet available in the release:
Code: [Select]
// Wiring for a 74LS164
// ---------------------
//                          4.7k
//              +--------[ Resistor ]--------+---(LCD Enable)
//              |                            |
//              |          74LS164    (VCC)  |
//              |        +----u----+    |   _V_ diode 1N4148
// (data pin)---+---+--1-|A     VCC|-14-+    |
//                  |    |         |         |
//                  +--2-|B      Q7|-13------+
//                     3-|Q0     Q6|-12--(LCD D7)
// (BL circuit)--------4-|Q1     Q5|-11--(LCD D6)
// (LCD RS)------------5-|Q2     Q4|-10--(LCD D5)
// (LCD D4)------------6-|Q3    /MR|--9--(VCC)
//                   +-7-|GND    CP|--8--(clock pin)
//                   |   +---------+
//                   |      0.1uf
//                 (gnd)-----||----(vcc)
//
// ---------------------------------------------------------------------------
//
// Wiring for a 4094
//-------------------
//
// NOTE: pin 1 is not connected to pin 2
//
//                          4.7k
//                 +----[ Resistor ]----------------+---(LCD Enable)
//                 |                                |
//                 |      74HC4094                  |
// (data pin)------+       HEF4094    (VCC)         |
//                 |     +----u----+    |           |
// (clock pin)+----|---1-|STR   VCC|-16-+           |
//            |    |     |         |    |           |
//            |    +---2-|D      OE|-15-+          _V_ diode 1N4148
//            |          |         |                |
//            +--------3-|CP    QP4|-14--(LCD D5)   |
//                     4-|QP0   QP5|-13--(LCD D6)   |
// (BL circuit)--------5-|QP1   QP6|-12--(LCD D7)   |
// (LCD RS)------------6-|QP2   QP7|-11-------------+
// (LCD D4)------------7-|QP3   QS2|-10
//                   +-8-|GND   QS1|--9
//                   |   +---------+
//                   |      0.1uf
//                 (gnd)-----||----(vcc)
//
//
// ---------------------------------------------------------------------------
//
// Wiring for a 74HC595
// --------------------
// NOTE: the 74HC595 is a latching shift register. In order to get it to operate
// in a "non latching" mode, RCLK and SCLK are tied together. The side effect of this
// is that the latched output is one clock behind behind the internal shift register bits.
// To compensate for this the wiring is offset by one bit position lower.
// For example, while the backlight is hooked to Q0 it is still using bit 1 of
// of the shift register because the outputs are 1 clock behind the real internal shift
// register.
//
//                         74HC595    (VCC)
//                       +----u----+    |  +-----------------------(BL circuit)
// (LCD RS)------------1-|Q1    VCC|-16-+  |  +--------------------(data pin)
// (LCD D4)------------2-|Q2     Q0|-15----+  |      4.7k
// (LCD D5)------------3-|Q3    SER|-14-------+---[ Resistor ]--+--(LCD Enable)
// (LCD D6)------------4-|Q4    /OE|-13--(gnd)                  |
// (LCD D7)------------5-|Q5   RCLK|-12-------+                 |
//                       |         |          |                 |
//              +------6-|Q6   SCLK|-11-------+--(clock pin)    |
//              |      7-|Q7    /MR|-10--(VCC)                  |
//              |    +-8-|GND   Q6'|--9                         |
//              |    |   +---------+                    diode  _V_ 1N4148
//              |    |      0.1uf                               |
//              |  (gnd)-----||----(vcc)                        |
//              +-----------------------------------------------+
//
//
// Backlight Control circuit
// -------------------------
// Because the shift resiter is not latching the outputs, the backlight circuitry
// will "see" the output bits as they are shifted into the shift register which
// can cause the backlight to flicker rather than remain constantly on/off.
// The circuit below slows down the transitions to the transistor to remove
// the visible flicker. When the BL input is HIGH the LCD backlight will turn on.
//
//                (value depends on LCD, 100ohm is usually safe)
// (LCD BL anode)---[ resistor ]---(vcc)
//
// (LCD BL cathode)-------------------------------+
//                                                |
//                                                D
//                                                |
// (BL input)----[ 4.7k Resistor ]----+-------G-|-<  (2N7000 FET)
//                                    |           |
//                          (0.1uf)   =           S
//                                    |           |
//                                  (gnd)        (gnd)



BTW, with a couple of more caps and resistors, and some fancy, very timing precise code,
it is even possible to use the same shift register and drive it with only 1 wire/pin!


--- bill

dhenry

Quote
some fancy, very timing precise code,


I don't think they are fancy at all - you can take a regular driver and change it quickly for this purpose.

Timing sensitive? yes.

bperrybap


Quote
some fancy, very timing precise code,


I don't think they are fancy at all - you can take a regular driver and change it quickly for this purpose.

Timing sensitive? yes.

Fancy... perhaps not. So, Ok, I'll give you that.
But you definitely can't take a "regular driver" and change it quickly for this.
Doing a 1 wire interface that gets good performance using a cheap shift register
requires carefully designing a pair of RC networks for the hw,
doing port i/o, and using cycle accurate timing delays.
Port i/o and cycle accurate timing delays are things
that are not offered by Arduino or the AVR libC that currently ships with the Arduino s/w.

The times I'm dealing with are sub 5us, which is shorter than the time
for a single digitalWrite() and requires higher delay resolution than the standard minimum delays
provided by <util/delay.h>
The beauty of this is that the final implementation
using 1 wire is actually faster than the LiquidCrystal library using 4 bit mode.

--- bill

Go Up