Thursday, 5 June 2014

Unnecessary Complexity

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

My entry for the 'What Dave doesn't like about modern life' round on Room 101 would be Unnecessary Complexity. By that I mean that things seem to become more complex all the time, just because they can. The example I usually give is word processors. I remember writing my university dissertation on a BBC Micro, using Wordwise. That was fine, it did the job, all that was needed really.
Later onto a DOS PC running Protext, again, did the job, added a few whizzy features like fonts and bold / italic, although they were more a feature of the printer than the word processor itself. Later again Microsoft Word on Windows 95. WYSIWYG editor, so it looked lot fancier. More fonts, more effects. Today I'm using Office 2010 on Windows 7. Even more fonts, even more features and buttons I never press.

The final step is Office 365 on Windows 8, and I've seen a lot of people stare at that very confused, because they have somehow managed to overcomplicate it even more by trying to make it simple.

But at the end of the day, all these things basically do the same job, type in some text, modify it, save it and print it. And bring in all the new feature like autocorrecting words (you might not want autocorrecting), autocapitalising (how many times have you missed the 't' out of 'it' and gone back to find the I had been capitalised?). Lets' not mention the office paperclip.
Wordwise ran on the 2MHz BBC in 32K (well, more like 20K if you remove screen RAM etc.). Protext runs in 640K on the 8MHz PC. Word 6 runs in 32MB on the 200MHz PC. Office 2010 is running on a 16GB machine with a quad core 3.1GHz processor. But they are all doing basically the same job, and actually the old ones are sometimes easier to use.

I came across another example yesterday, when talking about approaches to averaging. When you have a limited resolution reading, you can improve it by taking a number of them and averaging the readings. I used this approach for the temperature sensor on the LCD Clocks.
A very efficient way, suggested by a friend, is written in assembler. Take the 8 bit readings and add repeatedly to a 16 bit register, and at the same time increment an 8 bit register. Every 256 readings, the 8 bit register overflows. When that happens, take the top byte of the 16 bit register. Then clear the register and start again. This is a very efficient way of taking 256 readings and dividing by 256.

A little less efficient is the way I do it in C code for the LCD clock is to create an array of 100 bytes, each reading, set an array entry, increment the index, if it's at the end, move it back to the start. Then go through the whole array, adding the values to a floating point number and dividing by the number of readings. Less efficient, but it achieves the same thing.

In a desktop application, I need to do a similar thing to average readings on a chart, but here I'm writing in C#, and using the .net framework linq library. I create a linked list of readings, each time I add a reading, I go through the list removing any entries over a particular age. Then use the built in averaging of the linked list to get the average. This is a lot less efficient in terms of memory and processing.
All three of those involved probably a dozen lines of code in their relative language, and they are achieving the same thing, but the amount of code generated and complexity is increasing each time. The assembler version uses a couple of registers and no memory. The C version uses 101 bytes, the C# version uses considerably more for a linked list of floats,  but the code, memory and processing requirements are a drop in the ocean on a modern PC. The new code has lots of inbuilt safety checks, the old code relied on the author getting it right.

I think that is why I like working with vintage computers and amplifiers and things like that because the beauty in simplicity is thrown into sharper focus against the complexity of their modern equivalents. Older amplifiers had several transistors, modern ones have several thousand. The BBC's 6502 had 3510 transistors, where as the i5 in here has about 2 billion.

Sunday, 25 May 2014

Improved Arduino Frequency Counter

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

I built a Simple Arduino Frequency Counter last year, and it's been quite a useful project. Over the time it's been in use, I've been tinkering with it to improve the display and accuracy. This started off with a simple display of the frequency in Hz. I modified the code slightly to add some commas to make it easier to read:
That's how it stayed for a while. I'm now building a signal generator, and I thought it would be good to include this on the front panel, so I tidied the layout further and added a display of the signal period (1 / frequency).
I had noticed it seemed to read a little low, so I revisited the code to improve performance. The original worked by setting up an internal counter to count pulses coming into one of the pins. It waited one second, then read the counter. The count was taken as the frequency, the display was updated and the counter reset. I've now gone for a different mechanism, an interrupt driven approach, similar to that in this forum post.

I've altered that slightly, and now what it does is enable an interrupt on change on a pin. When that is triggered, it stores the start time. It then changes the interrupt to go to a different routine, and when that is called, counts pulses and stores the time of the last pulse. It then waits one second again and calculates the frequency, based on the time between the first and last pulse, to improve accuracy. As per the follow up to that forum post, I've taken into account ignoring the initial isr call as this may happen if the pin is high when the interrupt is enabled. I've done this with a third isr, again trying to keep the code in there down. The new code can be downloaded here.
The circuit remains very simple, basically connect the input to pin 2 (interrupt 0), and connect an LCD display however is most convenient, and alter the setup call to the standard Liquid Crystal library as appropriate. On breadboard, I used the pins nearest the display.
When transferred to a circuit board, all that is required is the ATMega328P, 16MHz crystal and 22pF caps, some 100nF decoupling caps and a main 47uF cap. The 10K multiturn pot is LCD contrast, overkill for what is required, but it fits neatly with the layout.
Add connectors for power, signal and the LCD. I used two 6 pin connectors as the central 4 pins of the LCD are unused. Again, these are wired using the  nearest and most convenient pins. The R/W pin is optional as it is always pulled low, but again for convenience, I connected that to a pin on the boarded version. The 6 pin 'stackable' connectors are used for arduino shields, but are ideal here as the long pins can be bent to make contact with the ATmega328P, reducing the amount of wiring to very little, mainly point to point using component leads.
I programmed the ATmega328P using the Arudino IDE and 'upload with programmer' and my trusty USBTinyISP. Then just install the LCD module, a standard HDD44780 based 16X2 LCD (in this case white on blue for a change) and connect up an input.
There is no input protection here, as it is intended to be used where the input is coming from a TTL chip in the same piece of equipment, using the same power supply. If you plan to use this with an external input, some protection and buffering would be required. This is left as an exercise for the reader.

Monday, 28 April 2014

Plustron TVR5 TV

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

One of the problems with fixing old computers is dealing with the TV out. Most of the time, I used an LCD TV which has a variety of inputs, HDMI, VGA, SCART, components, composite, analogue and digital TV. This does a decent job with all but the analogue TV for older computers where it is sometimes a struggle to tune in, particularly having to use the remote to tune in. Most of the time, I use a composite video or RGB output which many of those computers provide. Here is a nice crisp clear colour video output from a rather poorly VIC20.
However, things like the ZX81 and the Spectrum there is no video out, only TV out. I normally have to open up and clip on a little booster circuit to the modulator to get a decent composite video out. The alternative was to keep an old style TV for testing, and indeed I do, but it takes up a lot of space on the bench, so I tend not to use it.
However, I've recently been given a solution to this, it having been lurking in someone's loft for many year.
This is a plustron TVR5, a combined UHF TV and VHF/MW/LW Radio.
The TV side of it is only 5", but that's fine for the sort of use it will be put to. The tuning is nice and easy with an old fashioned dial, so no problem finding the computers signal. Here's that VIC20 with some 2114's replaced.
Analogue TV has been turned off in the UK, so there is nothing else on the dial, but again, that's fine for me, the only signal I'm looking for is this one.
The other advantage of this set is the size, it fits neatly on top of my trusty old Hitachi V-665 scope.
Could't resist the compulsory 10 print "Hello World".....

Monday, 7 April 2014

Nissan Leaf Review - One Year On

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

12 months and 6,000 miles later, the leaf is still going strong. It's still a great car to drive and is still very practical. 

The car itself is great, it just works, and it is the way things are going. It’s sort of like the change from mechanical hard drives to solid state hard drives. Initially, SSD’s were faster and quieter, but were more expensive and had lower capacity and a few teething troubles, but now they are getting faster and cheaper and a very viable alternative to traditional hard drives. Yes, the mechanical drives are still cheaper and offer large capacity, but are still noisy, slow, higher power and vulnerable to shock. 

The electric car / SSD analogy does hit a lot of similar points, the early adopters pay more and get more limitations and need to tell the world about how good they are. There are still people who will prefer multi terrabyte mechanical drives or 3 litre petrol engines, but for general day to day use, you don’t really need either of them. There are also hybrids that try to offer the benefits of both solutions, but purists don’t like them. And like the combined VHS recorder and DVD player, may not be around for ever.

There are still a few annoyances, the dashboard instrumentation, at least as far as the battery charge meter, is still rubbish, and the website, although better that it has been, is still flaky. The range I am getting in practical terms, is about 70 miles driving around town, 50 miles if you include motorways. So given this, it is really important to know how much is left and frustrating that the information is not available. What you get is 12 bars. 12 bars lit is 100% charge, 1 bar means alarm bells flashing and get somewhere to plug in very soon. And that's it, not much details. It does also give an estimate of the mileage remaining. This is usually somewhat optimistic. It is based on your current useage, so if you are driving on country roads, it will be higher than on motorways, even if you're on a long downhill bit, it will be higher than an uphill bit. So unless all your journeys are on roads which remain identical, the estimates are usually way out.

As an example, I had one of my longer journeys, 29 miles each way. As I left home, I had 12 bars and the estimate was 105 miles. So that should be easy right? Well, as I go there, 29 miles later up the A1, driving slower that usual to improve the range, I was down to 6 bars and 45 miles estimated remaining. The tricky thing, is was that 7 just dropped to 6 which would mean there would be enough left, or was it 6 just about to drop to 5, which would mean I wouldn't make it home.

It’s a bit like having a digital watch and someone putting some tape over the last two digits, so rather than 10:30, all you can see if 10:##. If you depart on a journey and it says 10:## when you leave, and when you arrived it still shows 10:##. All you know is you have travelled for less than 1 hour. If, when you arrived, it read 11:##, then again, it’s you don’t have enough information to work out if you could make the same journey again before lunchtime. It may been 10:59 to 11:00 and have only taken one minute, or it could be been 10:00 to 11:59 and been nearly two hours, or anywhere in between. So yes, the instrumentation is a bit rubbish.

Pushing the limits of the range, I've managed 80 miles in one day, on one charge, and that's as much as I generally need to drive. To achieve that, I did need to drive a bit like a pensioner on a day trip, keeping to below 60 MPH, and I had to keep the air con off as the heater uses quite a bit of energy. When you drive in such a way, the dashboard slowly lights up segments of pine trees, and you accumulate theses over a journey. On that, I got three or four on the way there and another three on the way back!

These days I'm not commuting as much so it's fine, I just jump in the car and go. Press a button to open the car, press a button to start, then just press one pedal to go faster, one to slow down and turn the wheel. On the odd occasions I've driven other cars it amazes me how much effort is involved, using keys, having to constantly change gear to keep the revs in the small practical range of the engine and so on.

Living in a terraced property, it's not always easy to plug in and charge. Some of my neighbours are very considerate, some less so. These days, I just plug in when I visit my parents, so free lunch are a charge up at the same time, but at less that 1p pre mile, it's not that draining on the electric bill.

So with production having moved to Sunderland, and with more than 100,000 sold the Leaf is going from strength to strength. 

Wednesday, 26 March 2014

Google Chromecast Review

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

Although it has been out in the states since last year, the Google Chromecast has recently been released in the UK.
The chromecast is basically an HDMI dongle which turns a less than smart TV into a smart TV, in a very usable way. Inside the box is the unit itself and a very minimal set of instructions for use.
Also included are other parts, a 5V mains adapter and USB - MicroUSB cable (required to power the unit) and an HDMI extension lead (optional to improve fit behind a TV and / or wifi reception).
That's basically it, put all those together and plug it in.
The unit then needs to be configured, so you take your phone, tablet or laptop and go to the website to get the appropriate software.
So the instructions on the box were all that was needed to get going, it all seemed to work without a problem, with only the wifi network details to setup. Once connected, my unit then went away and updated itself.
After that, it's just a case of pressing the 'chromecast' button on any supported app to transfer it to the TV. A good example is the Netflix app, your phone or tablet basically becomes the remote control for viewing content.
It's not that the movie is going from Netflix to the tablet and then to the TV, the tablet tells the chromecast what to do and it goes to Netflix itself and gets the content and shows it. All the tablet has to do is update the scroll bar and wait for you to press pause, so it can go to sleep and save power.
The only problem I had was having to wake up my Nexus 7 to move onto the next episode each time as I was binge watching House of Cards Series 2. (that and I didn't seem to be capable of taking decent photos of it in operation, sorry about that).

Tuesday, 18 March 2014

Commodore 264 (C16 and Plus 4) Diagnostic Cartridge

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

A while ago I made up a Diagnostic Cartridge for a Commodore 64, by replacing the ROM in a spare Cartridge. I've have a few Commodore Plus/4 computers in for repair, so I looked around for a similar ROM image for the 264 series of computers. I found and excellent page from someone who wrote their own, Diag264. Next I found a donor cartridge, in this case a duplicate 'Atomic Mission' with a peeling label, and carefully removed the original ROM.
I then burned an EPROM with the DIAG264 image and installed it in a socket on the original board.
Finally, it needs a suitable label.
This can then be used with any of the 264 series computers, the Commodore 116, the Commodore 16 and the Commodore Plus/4.
The Commodore Plus/4 never really took off, it wasn't compatible with any of the Commodore 64 software, nor many of the peripherals due to different connectors being used for cassette ports and joysticks. It did have some built in software (the 'Plus/4' in the title), but I've not used those much.
DIAG264 tests the RAM and the 4 ROMs in the Plus/4, as well as various other hardware. Some of these test fail as I have yet to build suitable loopback adapters required for some tests.
Although in the same case style case, the  Commodore 16 is not as it may appear a cut down version of the Commodore 64, but in fact a cut down version of the Commodore Plus/4, and so was also not compatible with any of the C64 software.
Testing skips the two extra ROMs present only in the Plus/4. It also correctly detected my Commodore 16 which I have upgraded to 64K (which means it can run Plus/4 software, but I still can't call it a Commodore 64).
Finally it includes various graphics tests for the TED chip at the heart of all these 264 series machines.
So there it is, another test cartridge to add to the toolkit, with thanks to the original author of DIAG264.

Sunday, 9 February 2014

Setting the time

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

I've had a query about how I have been setting the time on the LED clocks I've made. Well, it depends. When I replaced the LED driver board on my old Cascade LED clock radio, I didn't bother with any buttons etc., so the only way to set the time is to reprogram it.
So every 6 months, I plug it into the PC via an FTDI cable (as shown here) or an Arduino USB Serial Light (as in the original article). I then upload the code with the following line uncommented.

  RTC.begin();
  //RTC.adjust(DateTime(__DATE__, __TIME__));

This sets the time to the system time and date at the point of programming. I then comment the line out again and immediately reprogram it, or it would reset to that that time each time power was applied.
That's fine for me, but for the ones other people have to use, I tend to add buttons to set the time, such as on this LCD clock. Note in this case, I use the USB cable for power, there is no data connection.
So I suppose it's down to how complicated you want to make it. I'm happy to reprogram a few clocks twice a year to cope with daylight saving. But obviously the average user would prefer buttons to change the time. You could use serial (directly or via USB) to set a time from a PC, but that's probably more work that reprogramming it. You could even use an Arduino Ethernet and get the time over the internet via NTP, or connect to a rugby radio module if you wanted to.