Author Topic: A 2-wires LCD with HD44780 and 3 x 74LS74 (put 2 shift registers on same 2 pins)  (Read 567 times)

0 Members and 1 Guest are viewing this topic.

Offline RoGeorgeTopic starter

  • Super Contributor
  • ***
  • Posts: 6202
  • Country: ro
Found in the scrap boxes a few 2x16 text LCDs and many KM555TM2 (74LS74).  :D

The HD44780 controller of the LCD will need at least 4 data bits, an RS and an Enable pin, so a total of 6 microcontroller pins.  This is also the minimum number of DO pins the LiquidCrystal library (from Arduino) will use.


LCD pinout

The number of DO pins can be reduced to only a CLK and a DATA pin, if a shift register is used.  Even so, an Enable would still be needed if we are to obey the HD44780 requirements for data hold timing.  The nice part is shift registers here are shifting on the raising edge of CLK.  That makes possible a trick where two shift registers can be independently controlled with the same 2 pins, by swapping the DATA and CLK for the second shift register.


2-wire to 6-wire shift registers schematic with 74LS74 D-type flip-flops

First, the RS bit and the 4 data bits D7..D4 are pushed in a 5 bits shift register implemented with 5 D-type flip-flps (FF) from the 74LS74 chips.  Then, the 6th FF is used to pulse the Enable pin of the HD44780 controller, while the other 5 bits are kept without shifting.  It is possible to do so if DATA line is used as a clock for the 6th FF.

The existing 'LiquidCristal' Arduino library was modified to use only two Arduino pins instead of six, so to keep backward compatibility with already existing Arduino code and examples that are using the current LiquidCrystal library.  The modified files were renamed to 'TwoWireHD44780_LCD'.  Tested on Ubuntu 22.04, with Arduino IDE 2.0.3 AppImage and an Arduino Nano board.


Breadboard circuit and TwoWireHD44780_LCD library test

The modified library can be packed as a standalone Arduino lib, if the original LiquidCrystal.h and LiquidCrystal.cpp are replaced by 'TwoWireHD44780_LCD.h' and 'TwoWireHD44780_LCD.cpp'.  The easy way is to copy the TwoWireHD44780_LCD header and C++ files in the same directory with the main ino sketch, as they are in the attached code example.
« Last Edit: January 30, 2023, 04:19:13 pm by RoGeorge »
 
The following users thanked this post: bingo600, spostma

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 792
Seems a bit excessive using so many '74 FF when a single 74HCT164/74LS164/etc.  or 74HCT175/etc. would do the job.
« Last Edit: January 31, 2023, 03:01:22 pm by SuzyC »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Or use an 8 bit I2C I/O expander and share the pins with other I2C devices: https://github.com/duinoWitchery/hd44780/wiki
The library can do Deep Magic to auto-detect and configure an I2C HD44780 LCD, including autodetecting how its wired, even including the backlight!  Run the sketch that searches for LCDs then 'bake' the correct configuration into your firmware.

Roman Black's single wire shift register also deserves an honourable mention, although the risetimes are out of spec for the '595 shift register: https://www.romanblack.com/shift1.htm
« Last Edit: January 31, 2023, 03:34:45 pm by Ian.M »
 

Offline RoGeorgeTopic starter

  • Super Contributor
  • ***
  • Posts: 6202
  • Country: ro
It has to be one shift register of 5 bits, and yet another independent FF to control the Enable pin of the LCD.  The 5 data bits are sampled by the LCD at the falling edge of the Enable signal.

164 and 165 has all FF tied internally at the same CK, so a second IC would be needed (with at least one independent FF) where the D and CK inputs can be swapped, in order to control the Enable pin of the LDC.

Either way, it happened that I was already heaving 20-30 of LS74 sitting in a box waiting for a project since the '90s.  ;D

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3707
  • Country: nl
An interesting approach for sure, but far easier with a module like available here: https://nl.aliexpress.com/item/1005001395324663.html

But boy did they go up in price. In March 2021 I bought 5 for a total of 3 euro.  :-DD

Offline RoGeorgeTopic starter

  • Super Contributor
  • ***
  • Posts: 6202
  • Country: ro
That's cheap indeed.  Mine was disregarding the price.  With the price of 3 NOS TTL from 1990 it would probably be possible to buy a brand new serial LCD with backlight (the LCDs I found have no backlit).  The built was for the fun, using only whatever parts were found through the scrap boxes (trying to inventory all the boxes, and thus bumping into all kind of parts).

The nicest idea I've seen about the minimum of wires for an LCD was this project (not mine), where a single wire was used to control the data pin, and the same wire was user as Vcc phantom power, so the whole LCD is connected by only 2 wires, one of which is the GND:  https://blog.vinu.co.in/2019/04/16-x-2-lcd-controlled-via-power-line.html

 
The following users thanked this post: pcprogrammer

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3707
  • Country: nl
The nicest idea I've seen about the minimum of wires for an LCD was this project (not mine), where a single wire was used to control the data pin, and the same wire was user as Vcc phantom power, so the whole LCD is connected by only 2 wires, one of which is the GND:  https://blog.vinu.co.in/2019/04/16-x-2-lcd-controlled-via-power-line.html

I have used power schemes like that way back using RS232 signals as the source for the power. It is also the way one wire (Dallas/Maxim) can work. Just ground and the data line. The chips have build in capacitors to keep them going during bidirectional communication.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf