Wednesday, 21 August 2013

ZX81 Clone Part 1

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

For many years, I planned to build a ZX80 clone. It's all standard parts (no custom ULA like the ZX81 or ZX Spectrum), and it's a well known and well documented circuit. However, I never quite got around to it. And then, I got my hands on an actual ZX80 (read about the repair of the ZX80), so the idea lost momentum.
Recently I've come across a few more ZX81's with dead ULA's, which is great for turning them into ZX81 USB keyboards, but not great if you play 3D Monster Maze. So back to the idea, but this time, make a ZX81 Clone. OK, it's reinventing a wheel that's already been reinvented, but it should be an interesting project, and I plan to make some modifications along the way.
The idea is to build something along the lines of a ZX81, using standard components i.e. without using the custom ULA chip. I've talked about that a few times before, it's basically all the chips on the ZX80 that weren't the ROM, RAM or CPU rolled into one. The ZX81 ULA also added some extra functionality over the ZX80, so it's even more chips to replace. It was a marvel at the time, only problem is they ran hot and eventually failed, and you can't easily get replacements. The inner working are now well understood and well documented, thanks to the work of various Sinclair fans. The following sites have provided excellent points of reference, and are well worth a read:


It seemed the fist stage was just to try to build up the ZX81 circuit away from a ZX81 board, but using the original ZX81 chips. This was just a test of how practical it would be. It worked, not particularly well due to clock issues, but sufficient to move onto the next stage.
This used parts borrowed from an issue 1 ZX81, a Z80 A CPU, Mostek MK36809N (8K mask ROM) and Mostek MK4118N (1K SRAM), and the Feranti 2C184E ULA is the one at the bottom with the heatsink on. The next step was to replace everything but the ULA with modern equivalents. I used a modern Z80 CPU, the Z84C0006PEG (which is limited to 6MHz, I need to order a faster one if I want to enable turbo mode). The mask ROM was replaced with a 27C64 (8K EPROM), and the RAM with a 62256 (32K SRAM). Although it is a 32K chip, without extra logic, only the first 16K can be used. Even though this is more RAM, the supply current is almost half with the modern chips.
I had a few problems with V1 above with the clock, and the same here on V2. I ended up building an Arduino based frequency counter to keep track of the frequency fluctuations. Since the video signal is directly tied to this frequency, if this drifts, the TV signal goes out of range. I tried both a 6.5MHz ceramic resonator on the ULA, and also a 6.5MHz crystal oscillator made with a 74LS04. I eventually traced the issues to the transistor which buffers (and inverts) the clock between the ULA and the Z80 CPU. I tried an assortment of different transistors, including a ZTX313 from a ZX81. I finally changed to using a gate from a 74LS04 inverter, and the clock issues all went away, I got a stable 6.5MHz main clock and a stable 3.25MHz CPU clock. And that lead to a stable TV display.
The video output isn't bad considering this is constructed with long wires on breadboard, with a simple transistor amplifier on the video out, and it is being displayed on a modern LCD TV. Just a word at this point about ULA versions. There were two, the original 2C184E, like the one I am using here, and the later 2C210E. The main difference between them was an improvement to the video signal, adding the missing 'back porch' signal to properly set the black level. So that's about as good as I'd expect from a lashed together circuit with the older ULA.
So now that's working it's onto the next stage....

Update:

And only 5 and a bit years later, it's here, the Minstrel ZX81 compatible computer kit.


2022 Update - I did go on to release ZX80 and a ZX81 compatible kits. There are currently a limited stocks of these left, available from TFW8b.com.

Sunday, 18 August 2013

Simple Arduino Frequency Counter

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

I've been having problems with clock drift on one of the projects I've been working on. It's meant to be 3.25 MHz, but it seems to drift down to about 3MHz on occasion. I have been monitoring it on my trusty oscilloscope, but although it can measure frequency if you move the cursors around, it can't keep track of a changing signal. The cursor needs to be moved whenever it changes to check the new reading.
I had a look around at various meters I have, but none can measure frequency over a few tens of kilohertz. I started to consider buying a dedicated frequency counter, but I noticed that some of the cheap ones on ebay looked to be nothing more than a microcontroller and an LCD display. A quick search turned up a number of projects, one of the simplest was a Frequency Counter kit from Sparkfun. This was based on the ATmega328P running at 16MHz, as used on the Arduino. The LCD was a standard HDD44780 based display (as used in my LCD Clocks). The wiring was as follows:
  • D2 - RS (LCD)
  • D3 - R/W (LCD)
  • D4 - E (LCD)
  • D5 - Frequency input
  • D6 - DB4 (LCD)
  • D7 - DB5 (LCD)
  • D8 - DB6 (LCD)
  • D9 - DB7 (LCD)
  • D10 - Backlight Control (LCD)
Other than the usual backlight contrast pot, no special parts were required, so I hooked up the circuit on an Arduino.
The code provided on the Sparkfun site was simple and to the point, just set one of the internal counters to use an external clock (which is fixed as pin D5, so that is used as the input), wait 1000mS and see what it has counted up to. I modified the display code to format the frequency with commas as thousands separators (as 4000000 Hz and 400000 Hz can look the same at first glance, 4,000,000 Hz vs 400,000 Hz should be clearer.
That was all there was to it, the accuracy is reasonable, certainly good enough for indication of the clock remaining stable or starting to drift again. There is no input stage, other than the built in protection on the ATmesg328P, and building things up with long wires and breadboards isn't fantastic when working with higher frequencies due to all that stray capacitance, but it does seem to work quite well. I will probably build this up into a box as it's turned out quite handy, but I think I would add a FET input stage to reduce the loading on the circuit under test.
My clock issues have also been sorted out, and work on the other project continues. Yes, the label on the EPROM does say ZX81. More on that at a later date.....

Saturday, 10 August 2013

Free Electric Vehicle Charging Point

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

When I got my Nissan Leaf (see my Review of the Nissan Leaf Part 1, Part 2 and Part 3), I knew that one thing that was going to be a bit of an issue was charging the Leaf at home. The best I had come up with was using the 'Emergency Charger', plugged into a normal 13A socket and run out of the door.
This wasn't ideal as the charger box either hangs down from the socket, or is precariously balanced on a nearby shelf.
As I'm using this more, I've been thinking about some different options. The first was to attach some sort of cradle to the wall beneath that socket to better hold the charger up. But that would still leave it running under the door. The next option I considered was to get a box fitted to the outside wall with a 13A socket and a space for the charger. That seemed like the best option, but I thought I should have a look around and see what other solutions had been found. During that process, I found that British Gas were offering to install free charging points for electric vehicles. Don't worry, it's not the traditional meaning of the word 'free' on the internet, it is actually government funded, so no cost to me. Other than information, it contains a GSM device which provides information about how I use the charging point. Seems fine to me. They could gather the same information by looking a the back of my house every day and seeing if there car was there and plugged in or not.
The device was installed in the same place I'd been planning to put my box, but is self contained, and wired direct to the mains, so can charge at 16A rather than the approximately 10-12A limit of the 'emergency' charger.
I can then close all the doors and leave the car on charge. No needs to prop the door closed with a half brick, or use extension leads and have to worry about rain.
More details of the British Gas Free electric vehicle charging package. The program is running until March 2015, so get your free charging point now!

Update:
The unit really is in exchange for data provided, and unfortunately that means you need to have a good mobile signal at the location you plan to have the charging point installed. If there isn't a sufficiently strong signal, they won't install it, so best check first.

Wednesday, 7 August 2013

OUYA Review

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

OUYA is a neat idea, it's another in the line of ARM based Android devices, which are essentially an Android tablet without a screen, such as the Raspberry Pi. This one was targeted at the living room TV with a games store and a bundled wireless controller. Netflix and Youtube integration are also apparently on the cards, and there are loads of games to 'try for free' on their store.
What? can't you see it? Well, I pre-ordered one from their website when they started accepting orders for overseas customers. That was on the 11th June. I haven't heard anything from them since then. I've tried email, raising a support case, and even lodged a Pay Pal dispute. However, all I have to show is that empty space and a small but unappreciated dent in my bank balance. I've been waiting as long as possible to give them a chance to reply, but Pay Pal have deadlines for dealing with disputes, if you leave it too long, they won't get involved. The initial case was lodged shortly before the deadline, and it is now time to escalate the case and get Pay Pal involved and get a refund. I'm disappointed that I have to do that, but I can't see any other options.

Update #1:
I escalated the Pay Pal dispute at 07:19 this morning. Just over at hour later at 08:33 I received a dispatch notification. So it took involving Pay Pal to demand the money back to get them into action, but I now have a tracking number. But hang on, what's going on with the tracking?
It appears to have left China yesterday (even thought I only got a dispatch note today?), been to East Midlands airport, then to Hong Kong, back to East Midlands, back to Hong Kong, then onto Dubai and is now in Germany! What are they doing, part funding the project with Air Miles? Is this a joke? I don't know.

Let's see if comes back anywhere near the UK again!

Update #2:
It finally arrived at my door, but UPS requested Cash On Delivery, an additional £28.19 in import duty and 'brokerage fees'. That's almost half the original cost of the unit! The original OUYA price included US tax and shipping, and there was an additional charge for international orders, which was about what the tax would have been, so I paid that expecting everything was now covered. Whenever I've ordered from the US in the past, the supplier had added VAT at the time of purchase, thus avoiding this sort of thing. 

Sorry, but after complete lack of action or communication until I tried to claim back via Pay Pal, and now this, I'm really not interested any more. The OUYA might be turn out to be a good product, but I don't I think I'll be getting one any time soon.

Update #3:
Paypal had no response from OUYA, so provided a full refund (less a bit due to currency conversions). Shortly afterwards, OUYA emailed to let me know my console was waiting to be collected at the UPS depot (still presumably with duty to pay). I've explained the situation to them, and I think the OUYA console is going off for yet another around the world trip on it's way back to the suppliers.

Wednesday, 31 July 2013

Cooler Master Elite 431 Plus Review

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

I get quite a lot of requests to build custom PC's, normally based on the best spec for a particular budget, or simply a requirement for a gaming PC or an office PC etc. I usually put together a parts list based on past experience of combinations of parts I know work well together, and manufacturers I trust. Recently I had a request where the spec and even the parts list were provided, so I was basically putting it together and testing it. This was quite interesting, as many of the parts were not ones I would normally have used. The main difference I noted was in the case, a Cooler Master Elite 431 Plus case, which is one of their higher end models. I normally stay away from cheap cases and go for manufacturers like Corsair and Fractal, where I know what I am getting, and I know I'll get an good end product.
So, here we have the assembled parts. The system was based on an AMD FX6350, with an MSI 970A-G43 motherboard and an MSI GT640 video card. 8GB RAM, a 1TB hard drive and a DVD-RW drive completed the list. I upgraded the power supply from the one specified to a Corsair CX500, as cheap power supplies are never a good idea.
On first impressions, the case looked OK, less 'bling' than many at that sort of level, apart from the side panel window, but overall fairly neat and tidy. The front panel had 2 USB 2 connectors and a single USB3. I'm never sure why they do that. I remember the first cases with USB 3 support had a single port, and a USB 3 plug out the back to plug into the motherboard or an add on card, but this one had an internal USB 3 header. The internal header is capable of supporting 2 ports, so I'm not sure why they have missed out the second one - seems a bit of a waste, although I've seen this in cases like the Fractal Arc as well.
The 'plus' element by the way, appears to be the SATA docking bay at the front. This is designed for 3.5" drives only, 2.5" drives fit electrically, but there is nothing to support them mechanically.
The drive when fitted is fully recessed, so no danger of it being knocked (as with some of the SATA drive bays I reviewed previously).
My main complaint about the case is the lack of cable management. The cases I normally use have good clearance on the back panel, so the cabling call all be neatly routed around the back of the case. Not only does this look neater, it's better for air flow as there is nothing to impede the air from the front fan. This was not an option with the Cooler Master, so the cabling is all on show.
Unfortunately, there is no room on the rear tray for any cabling:
Compare the CM Elite 431 Plus above to a similar system constructed in a Corsair 600T below.
The majority of the cabling has been passed through to the rear panel, thus leaving the front clear.
I also removed the hard drive cage on the 600D and mounted the single SSD to the base to further improve airflow.
Here is the final product, a lot of the wiring is visible through the panel, as is the green PCB of the SATA dock, I think I would have preferred a plain side.


Saturday, 15 June 2013

Battery Powered LCD Desk Clock

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

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 although 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.
Update:
Dave Jones over at the EEVBlog has posted some videos on charge pumps and negative voltage generators:



Wednesday, 5 June 2013

Enough Leafs to fill an autumn

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

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.

2022 Update: I am pleased to say when I bought my second Leaf in 2016, they did supply a Type 2 charging lead with the car.