Thursday 24 January 2013

ZX81 Acorn Electron Casemod

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Today in the blog, I answer the age old question, "what do you get if you cross an acorn electron with a sinclair zx81?". The answer it seems, is a more usable ZX81.
Whilst having a clear out, I came across two things and thought, hmm, there's a project. The first was a ZX81 board. This was a working board extracted from a ZX81 which I was asked turned into a ZX81 USB Keyboard. Normally, I only use broken ZX81's for this, and there is unfortunately a reasonable supply of these. The vision of Sir Clive to reduce it all down to 4 chips left CPU, ROM, RAM and 'everything else' and it is these ULA's which contain everything else that are the problem. They run hot, and when they fail, the only source of spares is another ZX81. So if the ULA goes, you just get another one and all that can be done is perhaps turn it into a USB Keyboard or a door wedge. But in this case, I was sent a working '81 to convert, I was told I could keep the board, so once tested, I put it aside knowing one day I'd  find a use for it, possibly installing it in a new case with a proper keyboard.
It was a slightly odd Issue 3 board, in that all the resistors were raised up by 10mm. I can only assume this was build from a kit and the builder decided that was the way to go. Very odd. The ULA has some graphics card RAM heatsinks on it to help it run cooler. The other heatsink is the standard voltage regulator heatsink, which also runs warm. This is one of the cases where 'only 4 chips' actually means 5 as there are 2 RAM chips here rather than the alternate single chip.
The second thing I found was the result of a previous idea. I'd started with the premiss that you can never have enough Acorn Electrons, then argued that perhaps I had one too many. In fact, I had several with some things slightly wrong with them. One with a dirty case, one with a slightly twitchy keyboard, and one which had an intermittently faulty ULA (yes, Acorn fell for the same trick and put much of their glue logic into a single point of failure). So I shuffled things around into a pile of working electrons and one with all the bad bits. And this was what I found.
So the plan came together. I'd put rehouse the ZX81 board in the electron case. Making the best ZX81 system I could in there. There were four main things I felt I needed to 'fix' on the ZX81:
  1. The video output is through a UHF modulator and most modern TV's can't tune into it's signal. There are a number of standard mods to convert the output to composite video which most TV's can handle.
  2. The power supply. One of the old issues with the ZX81 was the power connector, and how easy it was in some circumstances to knock it and loose what you'd been working on. It also ran hot as it was a 7805 linear regulator running on 9V, so was dissipating about 4 Watts of heat.
  3. The keyboard. Ironically, since I'd converted a few into USB keyboards, they keyboard was a bit of an issues on the ZX81. The USB one I have on my media PC is for occasional use only (and because it looks better than an old PC keyboard). For longer term use, the membrane is a bit of a pain.
  4. RAM and storage. I bought a ZXpand a while ago and I would like to use that here. This adds 32K RAM and SD card storage, so solves both issues in one.
The video mod was easier than expected because this ZX81 had the later 2C210E ULA which produced a better signal (it included the back porch pulse which was missing on the earlier versions).
All that was required was a transistor buffer to get the signals to the right levels. As with many people, I fitted the circuit in side the modulator case. I found a bit of variation in the resistor required between a few TV's I tried. The standard circuit uses 100 ohms, but 75 ohms would be a better match for the input resistance, and indeed worked better in some cases. In the end, I installed a 220 ohm variable resistor which can be adjusted through the old tuning hole.
The next challenge was the power supply. I wanted to replace the 7805 regulator as I planned to expand the system, so needed more power and it already runs hot with the standard load on. I had considered using a mains power supply, housed inside the case, but I had some issues with height, so went back to the electron supply. This was unusual in the it was a switched mode supply which ran from 19V AC and generated 5V and -5V. Almost right. A bit or modification, and it now runs on 12V DV and provides 5V for the ZX81 around 11V for the add odds (the unregulated DC is passed to the ZX81 expansion connector to add on units don't overload the onboard regulator). The 7805 was removed and replaced with a 3 pin connector.
The keyboard was always going to be interesting. I'd looked at a few options in the past, but the way the ZX81 worked made that difficult. It has 8 rows and 5 columns, with the rows split in the middle, so 1-5, 6-0, Q-T Y-P etc. The 8 rows are actually the 8 higher address lines, and the 5 columns are inputs to the ULA. The addressing scheme meant that it was read on every other input address. So the lines were scanned by setting the higher address lines and reading the 5 inputs. Any which were pulled low were considered pressed. The electron was 4 lines of 16 inputs, but was made of individual mechanical switches on a single sided PCB, so it was fairly easy to cut tracks and rewire it to the ZX81's matrix. I was even able to extract things like Delete out to a separate key (it is SHIFT+0 on a ZX81 and is called 'Rubout') by using additional diodes connecting to the rows of SHIFT and 0 as they were on the same column.
That's about as far as I've got. This is sort of work in progress as there are a few things to do. The ZXpand is unfortunately too big to fit in, I need to look at other options to fit it in, or just add 32K RAM on board. I also need to clean up the case, possibly spray it back, and look at making stickers for the keycaps.
But as it is, it's a ZX81 with a decent keyboard, proper video out and a stable power supply. I couldn't resist a final test program, and it had to be.
10 PRINT "TYNEMOUTH SOFTWARE BLOG"
20 GOTO 10
Now, where did I put the 3D Monster Maze tape?

Friday 18 January 2013

Tiny LED Clock

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Now that I have finished the new circuit for the old LED clock and that was running nicely, I got to thinking that the ATMega328 used in that was overkill, 18 pins, most of which were unused. I'd gone with that as it was fairly simple to use an Arduino for development. But back in the simple LED clock all it was doing was reading I2C from the RTC and writing it to the LED display using the same I2C bus, and that only took two pins. I decided to have a look at the ATTiny45, an 8 pin device which could do I2C. I rigged up a test circuit with the Arduino ISP programming the ATTiny45 (using the approach suggestedby high-low tech).
It looks a bit like an ode to the flying spaghetti monster, but basically, the orange wires are the ISP connections from the Arduino, running the ArduinoISP project (the capacitor is needed on UNO boards to stop the Arduino resetting). The rest are the black and red of power and the white and green and the I2C clock and data to the Adafruit RTC module and LED display. It all looked promising until I clicked build, as unfortunately the wire library used for I2C comms on the Arduino isn't supported on the ATTiny range.
I found the TinyWire library, which did provide I2C support on the ATTiny range, but the RTC lib and the Adafruit display libraries used wire and didn't work. The example which came with the TinyWire actually used the DS1307 RTC, but just made the call to read and processed the BCD response in the main code. That approach was all I really needed there for the RTC. The display was more of an issue as there I couldn't used the Adafruit library code. However, I had found a slight issue with that. Only slight, it only had a problem between 23:59 and 1:00. Basically the time is converted into an integer as hours x 100 + minutes, so 23:59 is just 2,359. The trouble comes with midnight. This adds up to 0 and so the display just shows '  :  '. A minute later we get '  : 1', nine minutes after that we get '  :10', and so on until '  :59' is finally followed by ' 1:00'. So I decided I could get around that be extracting the bits of the library I needed and converting them to use TinyWire rather than Wire, and in the process ensuring I left leading zeroes where required.
So finally, I ended up with a very simple circuit, but more complex software. I made the finished board the same size as the LED display, which sits on top. I could have used a smaller button cell, but the CR2032 is ubiquitous, and I had spare holders and cells, and it just fitted in the space. The only other components are the decoupling capacitor, pull up resistors for the I2C bus and the 32.768KHz RTC crystal.
One downside to this approach was not being able to set the RTC without writing mode code. I went with the easier option of installing the battery, then wiring up the I2C bus (without the ATTiny45 installed) via the display connector to an Arduino. This ran some simple code which set the RTC to the PC clock. I then disconnected that, installed the ATTiny45 and the Adafruit LED baclpack and the unit was complete.
I've wired this to a USB cable, and it now shows the time next to my PC. When the PC is off, the power to the USB goes off and so does the display. The RTC maintains the time thanks to the battery, and next time the PC is switched on, on comes the display with the right time on it.

Sunday 6 January 2013

LED Clock Part 4 - The Finished Product

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Following on from the previous articles on the LED Clock (a simple replacement and a teardown of the original clock and a more complicated replacement), the parts I ordered from CPC have finally arrived, I've now finished the replacement unit. And here it is.
OK, so it looks like the original. Well yes and no. Yes, it does look like the original, that was the intention. However, it is now a 24 hour clock and the time is derived from a battery backed real time clock. The colons now flash at 1Hz, previously they were on continuously - the TMS3450NL chip on the original clock does have an output to flash the colon, but the designers decided not to use that and wired them permanently on.
Inside it looks different. The original display has been reused, but this now has a row of pin headers and plugs into a new board which contains (from left to right) the CR2032 battery for the RTC, the two MCP23008s to drive the common anodes, the ATMega328P microcontroller and the DS1307RTC. Here it is with the display removed.
On the bottom right are the two common cathode drive transistors and the power supply circuitry. The original transformer wasn't ideal so I've replaced it with one of a similar size (and vintage), with a very simple rectifier, capacitor and 78L05 based power supply. More than enough to supply the 60mA it uses.

The pin header on the left pokes out of the side of the clock, where there used to be a slide switch. This allows the 'Arduino USB2Serial light' to plug in to reprogram the unit, or to set the time.
I could have just gone out and bought a new clock, but that would have been too easy. This has been an interesting project, and I'm happy with the result.