A common serial interface is the Inter-Integrated-Circuit (IIC) protocol, which uses only two wires (Clock and Data) allow chip to chip communications. Unlike a full duplex UART, the IIC interface uses a master and slave approach where a master (the microcontroller) initiates transfers by creating a start bit condition the slave devices listen for. When the clock line is held high and the data line transits low, this signals all the slave devices that an IIC operation is about to take place.

From this point, the master clocks out an address of the chip it wants to communicate with along with a bit indicating if it wants to write to the chip or read from it. Then commands/status or data can be sent back and forth. An acknowledge bit from the slave chip verifies to the master that the transfer has taken place and a stop bit condition from the master ends the cycle (Clock held high while data line transits from low to high).  

Most microcontrollers have at least one IIC port implemented in hardware. If not, it is relatively easy to implement a bit bang routine to communicate over any two general purpose I/O lines that can be used to create an IIC port.

To make the display IIC driven, I use the oldie but goodie; the PCF8574. This part is available from TI and from NXP and is an 8 bit parallel to IIC converter chip (See Fig. 5). Note, the three address bits (A0-A2) determine what IIC address the device will respond to. This address is encoded into the data stream so that up to 8 PCF8574’s can be connected to the same two wire IIC bus and be individually addressable and controllable.

There is also an ‘A’ version of the chip which uses a different address. The Non ‘A’ version responds to address 4x. The ‘A’ version responds to address 7x. This allows up to 16 of these devices to connect on the same IIC bus.

Image
 

By using the PCF8574 as a data pump, it is relatively easy to pump out initialization commands, display mode commands, and write to the display simply by transferring blocks of data. These blocks can be canned prompts and messages, or be constructed in RAM and sent out in one fell swoop.

To do this, I created a notation and data structure that can easily be implemented in firmware (See Fig. 6). Note, every IIC device has its own registers and functional map. The PCF8574 is no exception. Refer to the data sheets to see the specifics.

Image
 

To implement this, I used a microcontroller board I designed with a BASIC like language. It runs interpretively so I can store programs in a serial EEPROM (also IIC) and run them through commands over the serial (RS-232) port. The operator syntax is shown in Fig. 6.

I spun a small PC board with both the SIP and DIN connectors so I could use this board for virtually any type of character display. I also added the trimpot for contrast adjustments (See Fig. 7).
Image
For hobbyist and do-it-yourself projects, I made everything through hole to make it easier to assemble and debug. I also added redundant connectors on three sides so that these boards could snap together allowing more than one display to connect without the need for an additional cable.

 

You will note that even though only four wires are needed (clock, data, power, and ground), I made my connectors six pin. One if for interrupts because I may want to have digital I/O like push buttons sharing the same four wire bus. This approach makes a great universal front panel creation technique. Another pin is a spare — Always a good idea.

You may also notice that I added the footprints for a local power supply regulator. This way, any one of these boards can hook up to low voltage AC and supply all the others with 5 volts. Jumpers enable supplying power if needed.

Advertisements