12AX7 tube preamp review and information. A low cost, high-performance project originally from Silicon Chip Online.
Articles
Services
Embedded hardware     design

Embedded software

PCB design

Schematic design

Prototype assembly

Kit assembly

PCB component replacement

Audio speaker crossover design/builds

Custom wiring harness design & assembly

Miscellaneous soldering/assembly small custom work
A Better PIC 2-Wire Hitachi LCD 44780 Interface
(2-wire microcontroller serial-to-parallel output expander)

Some time ago when working on a number of projects I was using very limited pin-count microcontrollers such as the PIC12F679 and so on (6 GPIO, 8-pin devices) however I wished to interface the micro to a standard Hitachi 44780 type LCD display.

I ran across Myke Predko's design, but after testing I discovered that it doesn't necessarily work reliably in all cases.  "Glitches" may occur...and in fact did!  I noticed that a spurious waveform occurred across the diode and after some time wasted on the design I realized that there was a much less painful method.  Additionally, he doesn't provide source code examples in C.  Oh, for shame! :(

I came up with the design for a 4-bit mode LCD interface: (click for .pdf file)
The design centers around inexpensive & commonly available parts:  74HC164 serial-parallel shift register and an AND gate.  Thanks to the AND gate, data can only be latched in on the LCD buss when latch signal "E" is active, which is controlled in software and requires the least significant bit of the shift register to be a "1".

Rev.1 as shown in the schematic shows the transistor-based AND gate design (optional) or the use of a common 74HC08 quad AND gate IC, although it leaves several gates unused.  Other ICs provide 1, 2, or more ANDs as needed (and are inexpensive).

My Rev. 2 schematic shows this using a tiny SN74AHC1G08 AND gate chip.

How It Works

E_ENABLE serves as one of the 2 inputs into the AND gate, and is the most significant (last) bit seen on the Qh output pin after shifting 8 bits of data into the shift register.  To ensure it is always low until we need it to be high, I initially shift 8 bits of data into the 74HC164.  Hence E_ENABLE is low, and toggling SCLK will not cause latch signal "E" to be generated.

SCLK & SDATA are simply two bit-banging signals used to place data on the input pin to the shift register and then clock it in (on rising edge of SDATA).  After every time I bring SCLK high, I bring it back to zero afterwards.

Data is "assembled" and I control the LCD by keeping the LCD signals & data in an 8-bit variable to be shifted out: 4-bit nibble data (DB7-DB4), signals RS & R/W.  Before sending I then always OR the most significant bit b7 with a "1" to produce signal E_ENABLE.

After 8 bits of data are shifted out LSB first, I then bring SCLK high, which causes latch E to go high and the LCD display latches in its data.  Therefore data is not latched until after it is present on the shift register's output pins, and the process repeats as needed.

Software Functionality

I compiled & tested the code some time ago (before I was using code templates and other standardization, so don't hold it against me!) in Hi-Tech PICC Lite for the PIC12F509.  The function:

void write_nibbles_LCD_2wire()

...is all that is required.  Calling this mean passing the 8-bit byte we want to write to the display, a high or low indicator for the RS (register select) pin, and a high/low for the R/W pin.  Latching is handled by the function.

Advantages & Disadvantages

An obvious drawback is that it takes 2 x the amount of time to serial shift 8 bits of data as the 0x00 values are always sent first, not even counting the additional time required to use a 4-bit mode with the 44780!  However, LCDs by comparison to other devices are slow, and this is a small price to pay for the benefits if you need it.  Unless the code used is really slow, your eyes should never notice.

Getting More Pins

Also the design can be "streched" for more output pins by adding additional 74HC164 devices in series by first calling

serial_data_shift(0x00) x the number of data bytes to be sent, then...
serial_data_shift([data byte])  ...for each byte to be sent

The nibble-handling code can be deleted if not using an LCD display & you only want an output pin expansion.  Keeping the remaining E_ENABLE bit handling code in write_nibbles_LCD_2_wire() should be enough.

Source Code

Microchip MPLAB PIC12F509 project (compiled in older Hi-Tech PICC Lite C compiler) is here.  It should equally apply to the PIC12F629 family & similar.

I hope you find this helpful. :)
Intronix Logicport Review

Sensible Source Code Organization

A Vacuum Tube Preamp You Can Build 
NEW!




About
Contact
Examples
Values
Services
About
Services
Contact
Values
Examples
Embedded hardware     design

Embedded software

PCB design

Schematic design

Prototype assembly

Kit assembly

PCB component replacement

Audio speaker crossover design/builds

Custom wiring harness design & assembly

Miscellaneous soldering/assembly small custom work