Craziest Pin-Saving LCD Trick Ever!

We love squeezing every last bit of silicon goodness out of a tiny chip, or at least we delight in seeing it done. Today’s analog/digital hack is one of the sweetest we’ve seen in a while. And it’s also a little bit of a puzzle, so don’t scroll down to the answer until you’ve given the schematic a good think-over.

[Claudio Larios] built a tachometer with LCD display, using only an eight pin PIC microcontroller for brains. (Translatrix.) Two pins are taken up by the power supply and one reads a Hall sensor, leaving only three pins to drive an LCD display which needs six signals. The problem to be solved is the fundamental mathematical issue that three is less than six. Now have a look at the schematic.

If you’ve not played with the Hitachi HD44780 LCD controller before, it has four-bit and eight-bit data modes. In four-bit, used here, you only need to send data on D4, D5, D6, and D7. RS selects between command and data mode, and E is the clock signal that latches the data in on a falling edge. Mull that over a bit before reading the next paragraph.

SPOILERS!

What [Claudio] is doing is essentially using the 10 nF capacitors as little memories! (Look into DRAM if this analogy seems a stretch to you.)

In a first pass, the PIC’s pins are set high or low for a longish period of time (500 microseconds), long enough to charge or discharge the capacitors through the 10K resistors. In a second pass, the values for D5 and D7 are set, and the E line is strobed up and down almost immediately to latch in the values on the no-capacitor lines.

The second pass happens so quickly that the capacitors can’t charge or discharge fully and RS, D4, and D6 read in whatever logic value was set during the first pass. Brilliant! (Oh yeah, this project was about a tachometer. We got distracted by the shiny pin-stretching tricks. We’re sure it’s a fine tachometer.) Did you see how he pulled that off with only three pins?! And no shift register?!?

HaD reader [danjovic] sent us the tip and did a little work on the code, verified that the technique worked, and provided the banner photos of his recreation. Many, many thanks!


Filed under: misc hacks

from Hackaday http://ift.tt/2fUYLl2
via IFTTT