Quantcast
Channel: Sustainable Suburbia
Viewing all articles
Browse latest Browse all 234

More Distractions of the Mind - Building Retro Computers - Part 1

$
0
0
I2C Hex Keypad & 8 digit Display - about $2.50

Early computers traditionally had rows of indicator lamps to show the state of their registers.  This allowed the service engineer at a glance to check that a program was running, and by single stepping through the code, one could see the effect that the instructions had on, for example, the contents of the accumulator. For low level debugging and diagnostics, a row of LEDs takes some beating.

PDP-8 Front Panel - Indicator Lamps - from about 1965

However, it's about 40+ years since LEDs were fitted to the front panel of mini and microcomputers - which makes them somewhat novel these days.

As a proponent of the Neo-Retro, I set about investigating ways in which LEDs could make a comeback.

The iconic Altair 8800 - from 1975

There are already some fantastic devices out there that use LEDs to great visual effect - such as RGB matrix tiles, POV displays and 3D LED cubes.  A trawl of YouTube reveals some wonderful creations. However, lets start at the beginning and look at the illuminating relationship between computer memory and LEDs.

Shift Registers

Starting with the humble shift register - for example the inexpensive 74HC595, one of the simplest forms of memory. A string of 8 D-type flip-flops connected in series.  As the clock signal rises, whatever the state of the serial input pin at the clock transistion, is copied into the first D-type of the chain. At the same time, the output of the first D-type is copied to the 2nd stage and so on. After 8 clock pulses, all of the D-types have refreshed data, and the previous data held in the register has been clocked out of /H pin.  The diagram below illustrates this in a 4 bit shift register.

shift register
4 bit Shift Register - Internal Workings

It's taken me 5 sentences and half a lifetime, to discover and describe the elegance of the shift register. It has a low transistor count and this made it popular amongst the early computer designers.  With 74HC devices, the clock can reach the order of 100MHz - plenty fast enough for most purposes.

Shift registers are cheap - as low as around  $0.05.  Though compared to other forms of memory - this is a very high cost per bit!

The 74HC595 has the advantage of a separate 8 bit storage register, so that previous results can be held in the register, whilst other data is being clocked through.  This storage function is very useful when cascading registers, in applications such as driving RGB LED arrays.

So we have an easy to use, versatile storage element, onto which we can connect some LEDs, and we can drive it with simple bit-banged port pin output routines, or use a dedicated SPI interface.

From Paul's Electronics - wiring LEDs to 74HC595 

So on a  breadboard, we can put a shift register, 8 LEDs with current limiting resistors and start to write light sequencer patterns to the LEDs. But wait, the illuminated LEDs are only mimicking the value of the bit pattern stored in the register - so at a glance we can read the value of the data held in the storage register.

Now if we had a bunch of registers, and enough LEDs, we could set up a series of LED arrays, and use these to show the data contained in certain internal registers within the processor. Fortunately for us, there has been a small revolution going on with LEDs - and they are one of the cheapest components on the planet.  There are also some really innovative ways of packaging and driving LEDs - which makes them so much more fun - very low cost and much simpler to use.

7 Segment Displays

These have been around for about 50 years - and were certainly used to effect on the 1965 Apollo Guidance Computer DisKey unit- but not necessarily using LED technology.  They are now ridiculously cheap and available in a wide variety of colours, sizes and digit configurations.

Apollo Guidance Computer DisKey Unit - using 7 segment displays

Red is the most common colour, but green, orange, yellow blue and even white are also available.

Size refers to the visible height of the illuminated digit - available from about 2.5mm to 125mm (0.1" to 5").  Some large outdoor displays - such as fuel signs at filling stations and public clocks also use a 7-segment arrangement - sometimes LED or lamp, but also using solenoid driven reflective flaps - that appear either light or dark.

Traditionally the segments are arranged in an "8" shape and given a specific naming convention - called by lower case letters a to g.  The decimal point, if available, is often labelled as dp.

Digits are available as single units or in multiples of 2, 3 and 4 (possibly 5) - and they butt together neatly so you can build up displays of whatever pattern you wish.  The front face of the display is often painted in black - for good contrast and to reduce reflection.  7 segment displays are often placed behind coloured acrylic, masked with screenprint ink - which allows just the digits to show through, with superior contrast - but hides the workings behind.

7 segment displays have been widely forgotten - as they have a much greater power consumption than LCD technology. Allow about 20mA per segment - but remember that though multiplexing it will not be on continuously.

Here are some typical generic 7 segment displays from China.

A Single 0.56" digit - showing size, common cathode (top) and common anode (lower) - about $0.05

4 Digit - 0.56" 7-Segment Display Module - about $0.19
 So why not consider 7-segment displays for your next project, possibly your own miniature Apollo Guidance Computer on an Arduino shield or something quite different - whatever it might be.......

A little inspiration - this time from 1985!
Multiplexing

Fortunately there is a neat trick we can do, so we don't need n shift registers to display n - bits, as this could get quite expensive.  Suppose we have a 7-segment display with segments A to G, with the decimal point (DP).  We connect each of these segments to the outputs of our '595 shift register via current limiting resistors - and with a binary to 7-segment look-up encoded in our firmware, we can display up to 256 patterns of illuminated segments on our digit - of which about 50 might be useful.

If we add another digit, we could just add another 74HC595 to drive that one's segments - however, because of the persistence of vision (POV) we can quickly flash up a digit on display 1, then turn that off, and use the same '595 to drive the segments of the 2nd digit.  7-segment displays are wired internally to allow for this - and are known in the trade as either common anode (CA) or common cathode (CC).

If we have say a display consisting of 8 digits, we connect all the segments to their own "segment drive" output on one 74HC595, and then use another '595 to enable each of the digits in turn  - by pulling down and sinking current out of the common cathode of each digit in turn.  Only 1 digit is illuminated at a time - and for 1/8th of the total display cycle. POV does the rest for us - and it appears that the digits are on all of the time.

The same trick can be applied to the 8x8 LED arrays. One shift register is wired to drive the rows, and the other turns on the columns - in turn. The second shift register is driven with a series of values that only energise one column at a time.  If it is sinking current from a common cathode display it needs the following repetitive pattern:

11111110
11111101
11111011
11110111
11101111
11011111
10111111
01111111

And for common anode - we invert the polarity of the bits so that the register sources current into the common anode:

00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000

You will notice that these sequences are easily programmed in C using either repeated addition (doubling) or bit-shifting.

So just two of the 74HC575 devices will drive an 8x8 LED array - about $0.20 of hardware.

And For My Next Trick......

There's yet another neat hardware trick that we can do.  We can use the above scan pattern to generate the read sequence required for a keyboard matrix.

Assume that the keys are arranged in an 8 x 8 grid.  We apply the above scan pattern to the rows, ad then use another shift register - this time a 74HC165 wired as a parallel to serial converter,  to read the columns. When a key is pressed, it shorts a row to a column, and so the brief scan pulse appears on the column input of the '165.

In our code, we first write the scan pattern, energise the display segments, then read back the data from the '165 column shift register.  If a key is pressed it will appear as a 1 in a particular bit position of the '165 register.

This is a very economical way to multiplex  7 -segment displays and scan a key matrix. Just two output shift registers and one input register.  It has been in use at least since the mid-1970s - and possibly earlier - applied to vacuum "Nixie" tubes.

Fortunately this functional requirement is very common - for example in cash registers, and machine automation systems - so the function has been integrated into an easy to use IC - available from various manufacturers for a few cents.  Each offers different numbers of display capabilities and keyscan matrix options. Whilst you can drive these from shift registers, there are some really neat, low cost ICs available to make your job a lot easier.  These communicate generally via I2C and are useful for driving either arrays or 7 segment displays. Some also have the means to scan an array of keyswitches. It all makes interfacing to your microcontroller a lot easier.


Display Driver ICs

The Holtek HT1632C is typical of the low cost display driver ICs - and will drive 24 rows by 16 commons.  It's worth a look at the datasheet for full details.  The HT1632C is a ubiquitous IC in the Shenzhen markets - costing around $0.50 in 1 off. It is however available only in a 48 pin or 52 pin LQFP - so you will need a LQFP adaptor to use this in a breadboard.  Having recently paid $8 for a QFN adaptor from the US - I was delighted to see these available in China for around 11 cents!

There are other driver ICs available - from Holtek and other manufacturers.  The HT16K33 will drive up to 128 LEDs and scan up to 39 keyswitches. Conveniently there is a little breakout board available from Adafruit for the 16K33.  It's $6 in the US or under $1 in China for a lovely purple pcb - a rapidly becoming popular colour choice for pcb solder resist.

HT16K33 Breakout - An Adafruit Design - Significantly cost reduced in China!

If you don't have many LEDs to drive - there is the very economical TM1638.  This is about 12 cents and will scan up to 24 keyswitches.  It's available as a built up board containing 7-segment displays and low cost tact switches. It will drive 8 x 7 segment digits plus 16 individual LEDs - all for under $2!
I2C driven TM1638 on a pcb with 8 x 7 segment, 8 LEDs & 8 Switches Yes - that really is $1.86!
The TM1638 has a sister device - the TM1639 that will run 8 x 8 LEDs and scan up to 16 switches - this time in a more breadboard friendly  DIP24 package.  The datasheet in Chinese has suffcient diagrams and English text to allow you to make a good understanding of how it is deployed - including example circuit diagrams.

Another useful part is the TM1628 - It will scan 20 keys and drive up to 10  segment digits - see below






You can but these ICs already fitted to a board complete with 7 segment displays and switches. The innovatively named "LED & KEY" pcb - below, is one example of a fairly generic design - from as little as $2 in the markets.


All of these items were located via TaoBao.com - the Chinese equivalent of Ebay. The TaoBao search engine now recognises English text - and for the reverse translation - let Google translate the page.  So lots of cheap hardware is available - you just need to know where to search online for it!

LED Arrays

For a few tens of cents, you can buy a variety of LED arrays - either with single colour LED,  bi-colour or RGB. These are generally in 8x8 arrays using either 3mm or 5mm LEDs - but there are some using 1.9mm LEDs  - which means a smaller physical size - or more LEDs in a given size package.

Typical Datasheet for a common anode LED array

For, me, the 16x16 array of red LEDs in a 40mm square package holds the greatest potential - and I will look at this later - in the meantime - here's what they look like.

16x16 Red LED Array with change from a $6 bill!


16x16 array - and a HT1632 driver IC - all in one module


Finding the Chinese search term - or the generic name of the part is half the battle. For example, one item of interest is the YK-788BS 1.9mm 8x8 LED array. Adafruit sell these for $3.95 but the market price in Shenzhen is closer to $0.30.  You just need to know that a TaoBao search on 788BS is going to find most of the references to this part.

These miniature 8x8 LED arrays have a 16 pin DIL pinout - so you can breadboard them easily, and stack them side by side on stripboard to make larger arrays.  You could easily construct  a 16x 16 array, with 2 off HT16K33 driver ICs for well under $5. Here are some I bought recently, with the proposed EagleCAD layout below.

Half Size 20mm x 20mm LED Arrays $0.29 each!

8x8 LEDS arranged into a 16x16 LED Array Shield with 2 x HT16K33 drivers ICs
Shopping Around

I do a fair amount of purchasing in and around Shenzhen - so it helps to have contacts over there who understand electronics, understand the language and culture, have local knowledge of the main markets and who can do business on your behalf.

If you want to source components from Shenzhen markets - I recommend Man Friday. They are a relatively new company offering personal shopping for component sourcing and shipping services.
Contact Toby Yu for details - and mention my name, Ken.

Toby has excellent English -  he used to teach English in High School, and will go out of his way to help you with your sourcing and manufacturing logistics, as well as offering Shenzhen meet and greet, factory visits, language translation, business negotiation and overseas shipping.

Daniel Bailey's C88 - A computer with just 8 bytes of memory!

This is a neat project by Daniel Bailey of York Hackerspace. It is loosely based on the Manchester SSEM "Baby" but uses a single 8 x 8 LED matrix to show the entire contents of its 8 byte RAM.
Daniel wanted to build a simple processor  from the ground up using a FPGA.

He illustrates his project here  


Daniel has subsequently sourced a 32 x 32 RGB matrix - and is building a machine replica of the Manchester Baby SSEM.

Whilst Daniel's full colour RGB panels are still quite pricey - they can be found in China for about $30 to $45 and also through Adafruit.

For my experimentation - I will be using a more modest display - based on the 16x16 40mm module - but actually more economically constructed from 4 of the 20mmx 220mm 8x8 788BS modules with 16K33 drivers  These can be arranged quite cheaply to make a 32x 32 array, allowing the Manchester Baby to be simulated - for around $20 of hardware, or to single step through a very small window of code on your latest ARM processor.

With a 32x32 LED array with variable LED brightness control - it may also be possible to recreate an early Baird Televisor - with slowscan mechanically scanned 30 line TV!

The combination of innovative LED array products, low cost, easy to use driver ICs and access to the low cost markets of electronics Shenzhen, has made all of  these devices far more available to hobbyists.  They are now such a cheap and easy solution - that there is now very little reason not to use them in your next project.

In the next part we look at driving the 16x16 LED array - and using it as a unique insight into the inner workings of our retro computer.

Links to Related Topics.

Background on Manchester Baby SSEM








Viewing all articles
Browse latest Browse all 234

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>