433MHz Antenna Lengths

December 19th, 2014 by Alistair MacDonald No comments »

I use a cheap 433MHz transmitter modules often and every time I need to work out what antenna length I should use because I never write it down. This blog post is me writing it down. The length needs to be an harmonic of the wavelength. The wavelength is speed of light divided by the frequency, or 299,792,458 m/s divided by 433,000,000, or 692.361334873 mm for short.

So the acceptable lengths are…
433MHz Transmitter Module

  • 692.36 mm
  • 346.18 mm
  • 173.09 mm
  • 86.545 mm
  • 43.273 mm
  • 21.636 mm
  • 10.818 mm
  • 5.4091 mm
  • 2.7045 mm
  • 1.3523 mm
  • 0.6761 mm

In reality I normally go for 87 mm, or 43 mm if I am tight for space and don’t need a strong signal. I did once use a 17.3 cm antenna and the coverage was amazing.

What version of Ubuntu am I on?

November 12th, 2014 by Alistair MacDonald 1 comment »

This is a question that I ask myself a lot and keep having to look up almost every time. Sometimes I am not certain what distribution I am actually using. Here is the summery version that hopefully will save me having to look the command up each time, and perhaps help you as well.

To find out all the version information about the Linux kernel you are running run the command…

uname --all

To find out the OS release (such as the Ubuntu version) have a look in the os-release file…

more /etc/os-release

…and on most systems you can look at that same information neatly formatted using…


Spectrum Emulator (full screen) on the Raspberry Pi

August 10th, 2014 by Alistair MacDonald No comments »

As part of my ZX Keyboard project I wanted to run a Spectrum emulator in full screen on the Raspberry Pi.

Fuse Spectrum emulator running on the Raspberry PiThe good news is the Spectrum emulator Fuse has already been ported to the Raspberry Pi and is easy to install if you are using Raspbian. The bad nest is that all the guides I found were to install the “GTK” version that runs under X windows, and I wanted to run in full screen on an old CRT TV. To install the Fuse “SDL” version (that will run in full screen from the command lane) just log in and from the command line run the following command…

sudo apt-get install fuse-emulator-common fuse-emulator-sdl fuse-emulator-utils spectrum-roms

Next we should make it start in full screen. From the console type in “fuse-sdl” and the emulator will start. Next press F1 (yes, sorry, the ZX keyboard does not have an F1 key so you will need to use another keyboard for now), select “Options”, and “Full Screen”. To make this the default press F1 and select “Options” again, then select “Save”. To exit use the F10 key.

Now I think we will need a good old game to play. The best place to look for Spectrum games that are distributed legally is at http://www.worldofspectrum.org/ . The simple way to load a game using the ZX Keyboard is from the command line. For example we can load Manic Miner (assuming we downloaded the game and extracted it to the working directory) with the following command.

fuse-sdl –tape “Manic Miner.tzx”

Annoyingly I have come across one problem with Fuse and the ZX Keyboard. Fuse maps each key to a Spectrum key, letter to letter, number to number, shift becomes Caps Shift, and Ctrl become Symbol Shift. All other keys are ignored. This is a problem as we are interpreting and translating the symbols already. For example the Symbol Shift P as a double quote (a shifted 2), but the emulator treats this as the Caps Lock being pressed. We could make the ZX Keyboard work flawlessly by turning off our translation, but we would lose compatibility with PC software. I might look at building in a way to changing modes but we will have to cope with this for now.

ZX Keyboard

July 31st, 2014 by Alistair MacDonald 24 comments »
A ZX Spectrum converted in to a USB keyboard on show at Manchester Mini Maker faire.

The ZX Keyboard, a USB keyboard made from an old ZX Spectrum on show at Manchester Mini Maker Faire.

Several year ago I decided that I wanted to make an old ZX Spectrum keyboard work with an emulator and ended up making one in to a USB keyboard. This is the rather waffly history of the project with a few tips and links for building your own. I have also created a Hack a Day page for the basic build instructions and a GitHub repository for the files.

Although I have never owned a working rubber keyed ZX Spectrum (mine was a Spectrum+ with a more solid tactile keyboard) I was given a broken rubber keyed one many many years ago. It was in a bit bashed up and did not work, and I have used a few of it’s components to fix other machines, but surprisingly the keyboard was okay.

Back in the start of 2012 I wanted to mount a soon to be released Raspberry Pi inside and emulate a full ZX Spectrum, as well as a Commodore 64 just to mess with people’s heads. I waited until the Model B was Pi eventually available but it would not fit without making more modifications than I wanted, and the smaller Model A was a long way off becoming a reality. I then decided that instead of mounting the Pi inside I should turn it in to a USB keyboard so I could use it with a Pi or a normal desktop PC. Naturally I then forgot about it for another couple of years, until for some reason just now.

Several people have asked why I did not use Bluetooth (some more criticising that asking, but whatever) and there was a Kickstarter making new Bluetooth ZX Spectrum style keyboards, but the project was to use an original ketboard, get it working with the Pi, and to do it myself.

Anyway, the build…

The hardware was surprisingly easy with the big unknown being the USB communication to which I considered a few solutions. Lots of projects use  a Arduino Leonardo that can natively emulate a USB keyboard, or reprogramme the Arduino Uno’s serial controller that requires zero extra hardware, but will prevent the Arduino from being programmed via the USB port. I was keen to use a low cost (the one used cost £1.30) Arduino Pro Mini clone and a small number of basic components.

Having decided on the Arduino Pro Mini (yes, I have my cart pull the horse for pet projects) the easy solution (for me because of prior knowledge) was to get the Arduino to emulate a PS2 keyboard and use a cheap PS2 to USB converter. If it was a one off commercial project, or I was against the clock then this is what I would do as it is the quick and easy solution that adds pennies to to cost of the project. This however is a daft pet project that is an ideal excuse to use as a learning experience, so I decided to play with the V-USB library from Objective Development.  In the end I found the VUSB for Arduino library that had done a lot of the porting work for me, although I am bypassing the top levels of the library to increase compatibility and allow multiple keys to pressed. Now I have thins knowledge my default may well be to opt for USB for future projects.

Connecting to the keyboard hardware was easy enough as I reused the original connectors from the old motherboard that already had components missing. The flat cable from the membrane was very tarnished and had cracks across the connections but I chopped an inch off the end and this solved the problem. The connections have been well documented by hobbyists over the years so there was no backwards engineering required. The way it is wired to the Arduino is not just to make things look neat mind. I will also help the software. Instead of having to check each button of each column at a time it is arranged so multiple values can be read in an operation.

The key mapping took a lot of thought and I have tried to make the keyboard usable for normal operations while keeping full compatibility for Spectrum Emulators. I think I have managed that and have written a little about how it works on the hackaday page mentioned at the top of this post.

So that is it. I will be taking the keyboard to future hack days, Bar Camps, and Mini Maker Fairs if you would like to see it. I hope you are inspired to have a go at building one, perhaps a better one than mine. Do let me know if you do. If you want one but don’t have the time or skills to convert your old ZX Spectrum (or any other machine for that matter) then I am happy to do it for a few quid so get in touch.

Update: It appears that the latest Arduino IDE (version 1.6) will not compile the VUSB library because of an old big in it. A quick work around is to install an older version of the Arduino IDE. It works for me with version 1.0.5.

Scratch Bikes Data

July 13th, 2014 by Alistair MacDonald No comments »

Scratch Bikes in Newcastle

In this post I reveal a little secret about Newcastle’s now defunct cycle hire scheme and make the cycle location data collated over two years available.

Until the end of 2013 Newcastle had a cycle hire scheme called Scratch Bikes operated by Grand Scheme (formally both WhipBikes Ltd and Scratchbikes Ltd). Back in 2011 I decided to use the cycle location information on the Scratch Bikes web site to make an amazing animation like the animation done using data from the Boris Bikes in London. Sadly I found that the data was anything but live so I could not.

When I pointed out the web site and phone app were inaccurate Scratch Bikes were quite honest and came clean that the numbers were in fact entered manually when the bicycles were checked at the start of the day. I did offer to help link the systems together but sadly they did not respond to my offer. They did however try and hire a friend instead but I guess they had their reasons.

So the data…. In 2011 I set up a server intermittently checking the Scratch Bikes web site to find out how many cycles were at each station. As mentioned the data only changed once a day and was not enough for my needs, but I had already coded up the scraper to discover this so decided to leave it running just in case it was useful. This ran continually for 2 years. I do not know if it is useful.

You can download the Scratch Bikes Usage Data here. The time stamp is from the site and appears to be the time when the data was entered on to there system. There is a separate table with the location information in. One note is that I do not have the official data for Malcolm Street and Cuthbert House (presumed to be 3400 and 3405) so I have made a best guess. If you can fill in the blanks then please get in touch. Please take the data and do cool things with it, and let me know what you do with it.

I will just close by saying that reimplementing the phone service and building a web service is not hard for someone like me to do. In fact I can have it up and running within a couple of weeks, the web site and app will be live and accurate, and you would be able to book out cycles by text, voice, from a smart phone, and a PC as well. If someone wants to team up make this happen again in Newcastle then get in touch.

Where are the comments?

February 16th, 2014 by Alistair MacDonald 1 comment »

Recently this blog has been the target of a silly amount of spam comments and I am having trouble keeping it up because of that, so I have disabled comments for now.

4 years ago my blog received about 200 spam comments a month caused me to install Akismet. The spam continued to increase slowly until it got to an average of 2,000 comments a month. Even with this number Akismet was doing a good job and blocking almost all of it, leaving just a handful of comments for me to moderate manually.

Annoyingly things have rocketed now and last month I received 68,897 spam comments. That is around 90 spam comments every hour. This I could still cope with easily, but they tend to come in short waves and I am having trouble keeping my site responsive when that happens. If you have experienced an unexpected wait for up to 20 seconds and them the site just works again, then this is why. Ironically it is using Akismet that is causing the delay, but not using something like this would be clearly be impractical.

The truth be told I do not blog as much as I did, and that most people interact with my blog externally on Twitter and Facebook instead of the comments, so I have just disabled all comments for now. I am considering using nginx instead of Apache to better cope with this kind of traffic, or using a service such as Cloud Flare, but for now I hope disabling comments will keep the site fully responsive all the time.

Update: I am experimenting with some WordPress plugins to block some bot nets before Akismet is called. Fingers crossed this will reduce the spam to a level that my server and Akismet can cope with again. Very few users should be blocked in error but if they are then they can click back, wait a minute, and try again.

Fancy another laugh at my expense?

January 30th, 2014 by Alistair MacDonald No comments »

Bright ClubWell this is your opportunity on Tuesday evening.

A couple of year ago I preformed at Bright Club Newcastle, a “geek” style stand up comedy night. Well for some odd reason I have been asked back again. I guess they are desperate. Anyway, I will talking about my pet plastic duck on Tuesday 4th February.

If you want to come along there are details on the Centre for Life web site.

SnapCam to Close

December 21st, 2013 by Alistair MacDonald No comments »

snapcamlogoSnapcam is a simple Windows web cam application and web service I produced in 2003 as a pet project. It simply took an image at a set interval and uploaded it to the web service. The (almost) live image could then be embedded in the user’s web page. It is now outdated and sadly I need to close the free service down.

It was designed to be very easy to install without a complicate signup process, and it initially ran entirely on a free hosting service available at the time. Use has fallen away over the years as most people have move on to a more modern web cam solutions, or stopped completely. Today I don’t feel it worth updating the software or moving the service on to new hosting that I need to do. I am really pleased people found and used the service useful over the last decade and part of the code does live on in some time lapse experiments.

New users have not been able to start using the service for a while, and current users should have been receiving a warning message through the software. The service will stop functioning on or after December 24th 2013. If you wants to keep using the service after that date then please get in touch and I will see if I can come up with a low cost solution for you.

Farewell Rails Playground

December 21st, 2013 by Alistair MacDonald 1 comment »

Most of my web sites, including this blog, and various experiments have been hosted on Rails Playground that I migrated to 6 years ago. On the whole things have gone well with only one short outage in the first 5 years, but sadly over the last year there have been a lot of problems including outages, data loss, and security issues. This post is a quick summery of the problems. I will be posting about some other related changes in the very near future.

It all started when another of their customers started relaying spam email, perhaps because of a security floor, or perhaps they were just a spammer. Because of this all outgoing email was blocked without notice. I have to say I am not at all happy about the way this was done and it stopped all my services that use email dead without any prior notice or notification. I was also not best pleased at the attitude that this was not a critical part of the service and I was initially expected to adapt my services to another email system.

After this happened for a second time and a lot of moaning my sites were migrated to a new server. They did all the migration for me although it would have been easer to do myself. They inconsistently screwed up the dates when porting the databases. Being a US focused company with technicians in Asia migrating UK sites between servers in goodness knows where I can see how it happened, but it is not an excuse for the error.

Another problem is this new server was running the security mod called suEXEC that will allow email to be blocked per user, but unless some effort is put in it opens up a gaping great security hole. The way suEXEC was set up, and in fairness this is becoming quite common with the lower end hosting companies, will allow someone who can find a small exploit in any code to completely take over my sites. I like to think my production code is secure, but no one can 100% promise this, and holes in WordPress and PHPBB are being found all the time.

My general advice is if your ISP uses suEXEC, and the account you use to upload files is the same account that the web server uses to access the files, then just go to another ISP. If you have a separate user account for the upload and the server then this is the prefect setup, but if not you are better without suEXEC at all.

Anyway, the new server was also resulting in a huge percentage of cron jobs failing and I can not login using SSL most of the time. After a few more significant outages things got a little out of control and I decided I had to move away.

I have now moved everything that I am not culling to a new virtual machine hosted with Digital Ocean (and that is a referral link so if you are thinking of signing up then please use the link). Although I am a fan of managed shared hosting (despite it not being popular in some circles) I am having trouble finding a good and reliable ISP at a decent price. As a result I have had to go the self hosted route that will take a little more effort than I would like, but having done it before I feel I have the sys admin skills to keep things secure, efficient and a lot more stable than things have been recently.

I am truly am sad to have to be moving away from Rails Playground as they really have been good in the past and I have been happy to say so, but I need an ISP I can rely on and sadly I can not do this any more. :-(

Upgrading to Ubuntu 12.04 LTS and the MATE Desktop

November 12th, 2013 by Alistair MacDonald No comments »

I have had a lightweight “nettop” computer on my desk running Ubuntu 10.04 LTS for quite some time. I use this almost exclusively for accessing the web with Chrome, and doing some admin tasks that are just more simple to do on a Linux machine. Unfortunately Ubuntu 10.04 LTS has not been fully supported since earlier in the year, and more recently Google stopped updating Chrome for it so I decided it was time to move on to something more modern.

One reason I have not updated yet is that the desktop has changed from Gnome 2 to Unity that is like moving from Windows XP to Windows 7. I don’t dislike the new interface like many, but it does take up more memory and processing power, and this little machine does not have much of either. I was originally intending to migrate it to Linux Mint using the MATE desktop but decided to give Ubuntu 12.04 LTS a try first as it was a simple auto upgrade. Granted it took a few hours in the end but did mention this machine is low on processing power.

The update went smoothly but needed a lot of confirmations over the process so needed checking on frequently. Unfortunately it was a little laggy as predicted and used a large percentage of the small machine’s memory.

I then had the mad idea of trying to install the MATE desktop on top of the Ubuntu installation I already had instead of a complete reinstall. I followed the install instructions on the MATE web site and it all went very smoothly. My exact script is below but I would recommend checking back to the original web site in case the distribution changes.

sudo add-apt-repository "deb http://repo.mate-desktop.org/ubuntu precise main"
sudo apt-get update
# Ignore the error. We were expecting it.
# The following line will fix it but we needed to do the update first.
sudo apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring
sudo apt-get update
sudo apt-get install mate-core
sudo apt-get install mate-desktop-environment

After logging out I needed to select MATE from the cog icon by my name before logging in again, and then I was up and running with MATE. I did need to change almost all the desktop colour settings to be able to read all the text, but most of the other menu setup has been brought across from the old setup. I still need to tweak the font settings to improve the general look and feel further, and some of the apps still have colour settings so there is some tweaking to be done, but all this is a lot less hassle than a complete reinstall.

Also most importantly it did the trick with only 230MB RAM being used (approximately the same as before give or take a few meg) and the boot time is only a little slower at 100 seconds. Shutdown is about the same at 15 seconds. Chrome also works as well as it did and that is what I was after.

Granted it is annoying to have to do this at all, but to keep the security patches coming I needed to do something, and I would find it tricky to argue that it would have been sensible for anyone to support such old systems. If you are in the same position then give it some thought and I hope this proves useful.