Friday, 28 June 2013

USB Keyboards for sale

I've written a number of articles in the past about USB keyboards I've built from broken Sinclair ZX81's and  other old 8-bit home computers. I've had many requests since starting those articles to build keyboards for blog readers, and have build quite a few. Most of the ones I've been able to do were along the lines of 'can I send you my old X to turn into a USB keyboard'. The difficult ones have been, can you sell me an X USB keyboard. The difficulty being finding suitable source machines, when I try to stick to a policy of only using broken machine. One thing on my side is almost all of these machines have an Achilles heel, one or more custom chips. These ULA (Uncommitted Logic Array) or PLA (Programmable Logic Array) and similar chips were the ancestors of todays CPLDs and FPGAs and  were cost and complexity reduction exercises in the 1980's which allowed the ZX81 for example to be considerably smaller than the ZX80.
The size reduction was almost all due to combining multiple logic chips into a single chip. The problem with that is the chips were custom made, and no longer available. They also had a tendency to run hot and overheat. If you're looking at an Acorn Electron, a Spectrum, a ZX81 or a Commodore 64 or anything from that era that isn't running, the first things to check is the ULA or PLA. Sometimes (particularaly with Electrons), they just need clearning and reseating, but more often than not, they have gone to silicon heaven.
Unfortunately, these days the only source for a replacement ZX81 ULA is another ZX81. There are projects to build replacements, some are exact replacements, some approximate, and some add useful new feature. However, without those, you can end up with redundant machines. I normally wait until I've got something with multiple faults, so it really isn't going to come back to life, duff memory or CPU, the ULA has been passed onto another machine, etc. Or as happens with a depressing number of Commodore units, the poorly designed PSU has failed and shot 9V across the 5V rail and fried all the chips.
I picked up a number of units from ebay. I went for things advertised as 'not working', or in ebay speak 'untested' - which normally means 'I plugged it in and the light didn't come on' (as opposed to 'fully tested' which means 'I plugged it in and the light did come on'). However, I was disappointed to find a number of these actually worked or were easily reperable, so these ended up in my spares pile and I continued the search for broken units.
I have now amassed a selection of suitable computers and built up some USB keyboards, so I have setup the Tynemouth Software Etsy Store, and all the machines shown below are available to buy now. Alternatively, contact me for further information or if you have an old computer you would like turned into a USB keyboard.
The range for sale includes two Commodore 64's, one original and one C64C, although the keyboard of the C64C has been replaced by an older C64 version.
There are two Sinclair ZX Spectrums, an original rubber key version:
and a later ZX Spectrum Plus version with the better keyboard.
There is an Acorn Electron:
And, finally, a Sinclair ZX81, like the one that started this whole thing off:
All of these will work just like a normal USB keyboard, just plug and go. Windows XP / Vista / 7 and 8 are supported as are Mac and all flavours of Linux, including those running on a Raspberry Pi. Also, any tablets that support normal USB keyboards. They keyboard mappings can be customised at build time as required for any particular keys not included in the standard layouts. These are now available to buy now at the Tynemouth Software Etsy Store. Contact me for further information or requests.
Note also, most of these (barring the Spectrums) have space to install something like a Raspberry Pi inside (Pi and USB hub not included).

Saturday, 15 June 2013

Battery Powered LCD Desk Clock

Most of the clocks I have built have been mains or USB powered, but I had a request to build some battery powered ones, so I have been researching into the options. My basic LCD design was fairly simple, using an ATMega328P with a DS1307 Real Time Clock and an HD44780 based LCD display. I've built quite a few like this, here is one of the prototypes of this arrangement with an Arduino Uno and an adafruit RTC module:
My target was a pair of AA batteries. Of those, the micro will run happily run at 3V. The LCD should work at 3V althrough it is a 5V model, but the RTC requires 5V and a separate backup battery. To keep cost, size and power drain down, I have removed the RTC from the equation. It's a shame to lose the battery backed clock option. To save having to fully set the date and time each time the batteries are changed, I set it to write the date to EEPROM once a day at midnight. That at least means the date doesn't need to be set. The previous versions all used an ATMega328P running from a 16MHz crystal, but firstly that uses a lot more power, and secondly, it's only rated for that speed at 5V. I looked at running the micro from a 32768Hz crystal, but that didn't work out too well as the LCD updates were very slow. I finally went for the option of using the internal 8MHz oscillator in the micro, divided down to 1MHz, but retaining the 32768Hz watch crystal for an internal counter. This has to be set by programming the fuses in the ATMega328P microcontroller. I used avrdude and a USB Tiny ISP to set these using the following command line:
avrdude -cusbtiny -pm328p -Ulfuse:w:0x22:m -Uhfuse:w:0xd2:m -Uefuse:w:0xff:m
This sets the fuses to 22:D2:FF, selecting the internal 8MHz oscillator as the clock source, and enabling divide by 8 to get 1MHz. It also enables clock out - more on that later. This can be tricky territory as you can end up setting the clock speed to the point it isn't running fast enough to re-program. See my previous article on Reviving an unprogrammable ATMega328P. However, once set, this did reduce the current draw quite a bit from the original version running at 16MHz. The next challenge was the LCD. I went though a number of options here, I started with an MC34063 as a step up switch mode regulator. The idea was to generate 5V from the 3V input. This worked fine, but required quite a few components and took up a fair amount of space. It was also running at about 10mA, which wasn't really an option on batteries.
Having ruled that out, I looked into other options. Since the micro could run at 3V, it was only the LCD that required 5V. The next step was to look at using a voltage doubler to power the LCD. The idea is to take a square wave signal and via a couple of diodes and a couple of capacitors generate a voltage twice that of the  input. In this case, I was looking at getting up to 6V from doubling 3V. There is diode drop to consider, although with the 1N5819 schottky diodes, it's only around 100mV. To get the square wave, I had ruled out the ATMega328P PWM outputs as I'd changed the internal clocks to count the seconds (or rather 16th's of a second), so the extra fuse setting I programmed was clock out. This send the 1MHz internal clock out of PB0 (pin 14, Arduino Digital Output 8). This is a bit higher than necessary, but it's effectively free. A bit of experimenting with values gave around 5V under the load of the LCD and we were in business. There were few components to fit, so I went for mounting the circuit on a pair of small pad boards, the micro and the LCD on the front board. The crystal fits under the microcontroller to protect it. The LCD connectors via a 14 way header.
The batteries and buttons went on the second board.
I used a short ribbon cable to join the two boards, and bolted it all together.
This was using a few mA and seemed to be keeping good time, and sat nicely on the desk.
One of the tasks for this was to show the day of the week. The trouble was, it was only 8 characters, so I had to be a bit creative with Wednesday and fit 'esday' into 4 user defined characters.
I used the same 'esday' characters to allow Tuesday to be fit in the centre:
I ran this for a couple of weeks and all seemed well. As I was building another couple of these, I had another look at driving the LCD. The HD44780 chip should be able to run off 3V, the only reason the display was blank was because the contrast couldn't be turned low enough, it was already down to 0V. Various data sheets show a negative voltage as being required for this, so I made a slight modification and turned the voltage doubler into a negative voltage generator. This then generated approximately -3V from the clock signal. This was a bit high, so a switched to using standard 1N4148 diodes and 100nF capactiors (in place of 10uF) to make it less good. This ended up about -2V under load. The LCD could then be driven direct from the 3V battery supply, and the only things on the charge pump was the contrast reference of the LCD. This reduced the current consumption to less than 1mA, so should double the battery life, by just shuffling around a few components.
So there it is, a neat little desk clock / calendar that should run for many months on a pair of AA batteries.
Dave Jones over at the EEVBlog has just posted some videos on charge pumps and negative voltage generators:

Wednesday, 5 June 2013

Enough Leafs to fill an autumn

They're multiplying! The three charging bays at work were full again today, three black Nissan Leafs. Is it 'Leafs', I don't think 'Leaves' is right, although I'm not sure there are normally enough of them in the same place for anyone to have thought about a collective noun.
Not quite all charging away, as the middle one didn't have a Type 2 charging lead, and only the post on the left had a domestic three pin socket for the 'emergency' charger supplied with the Leaf, the others have the faster Type 2 Mennekes socket. Mine (on the right) is using a type 2 cable which goes direct from the post to the car. The one on the left is using the 'emergency' charger.
I'm not keen on the box that hangs down about a foot from the plug, I'm not convinced that's going to last or be waterproof. I was hoping they would have gotten around to supplying a suitable type 2 cable with the new cars, but it appears not.
1,300 miles in and I'm still enjoying mine. I'm living with the range without a problem. A couple of occasions I've had to plan in advance when I was going to charge up, in order to make longer journeys, but nothing insurmountable. I'd still recommend one to anyone who drives less than 30 miles a day and has a place to charge up.