A new mod for Mega Drive 60Hz colour correction

A well known difference between European and US/Japanese Mega Drives is that European models run with a 50Hz display update while US/Japan models get a 60Hz update. This is because US and Japanese TVs use the NTSC video standard at 60Hz, and here in Europe we use PAL at 50Hz.

What this means is that most games actually run slower on European consoles, which sucks if you want to play the games as they were originally intended to be played.

Fortunately for us, some clever clogs discovered that you can actually switch the console from 50Hz to 60Hz by changing an input on one of the chips inside the device from 0V to 5V. You generally want to be able to actually switch between 50 and 60Hz rather than fixing your console as one or the other, because some games were designed for the European consoles and others for the US/Japanese.

Adding a switch is pretty straightforward:

  1. Cut the trace that runs just above resistor R73
  2. Solder a wire to the right hand side of the cut trace (white/blue)
  3. Solder wires to the nearby sources of 0V (black) and 5V (red)
  4. Add a switch to give the white/blue wire 0V or 5V

Adding a switch to a MD2 to choose between 50 and 60Hz

Welcome to the 60s

So far so good, we can switch our MD to 60Hz and enjoy the games as they were intended – huzah! But, as is often the case in life, there’s a catch. Switch your MD to 60Hz and, unless your TV actually is black and white only, you’re going to notice that your MD is only sending out a black and white picture. Apparently my great Grandfather used to really swear at his black and white TV when he was watching the snooker, and when I loaded up Sonic and his hair was grey instead of blue I knew exactly how he felt. Shit man, what happened!?

To generate a composite signal for your TV, the Mega Drive takes the RGB signal its video circuitry produces, and passes it to a composite video encoder chip. The encoder chip has a clock input that it uses as the carrier frequency for the colour information in the composite signal it outputs. This colour carrier actually has to be a very precise frequency; for PAL systems it is 4.43361875MHz, while NTSC systems require 3.579545MHz. If the frequency is off by more than a small amount, the TV wont pick up the colour information at all and you get a black and white picture.

To generate this frequency, an NTSC Mega Drive takes its system clock of 53.6931Mhz, and divides it by 15 to get the required 3.57954Mhz signal. A PAL Mega Drive instead has a system clock of 53.203Mhz, which it divides by 12 to get 4.433583Mhz, close enough to the correct carrier frequency for PAL. So here we have the crutch of the problem: when you tell the PAL Mega Drive to run at 60Hz, it thinks it is an NTSC model and sets the clock divider to divide by 15. This gives a carrier frequency of 53.203/15 = 3.546867MHz, which is not a correct colour carrier for NTSC or PAL, so you get a black and white picture.

More modding

Well of course, this is also a well known issue. The easiest way to fix it is to buy an RGB cable and connect your MD to your TV with that. However, if you’re like me, it will itch at you that there’s a flaw in your system… or maybe your TV doesnt have an RGB input or something. Whatever the reason, if you want to find out how to fix this properly you fire up the all knowing google and discover there are loads of guides out there for how to fix this, great, we’re saved!

Wrong. Well, for me anyway. Let me explain. The idea behind the fix is pretty simple, what we need to do is generate the 4.43361875MHz clock signal the video encoder needs, then cut the trace that supplies it with the system generated clock and feed our new signal in instead. However, this is harder than it sounds, because you need to actually generate that clock. Many of the guides available on the net tell you to get a 4 pin crystal oscillator like the one below:

4 pin oscillator

These are really neat little devices, you connect them up to ground and 5V, and they have a pin that outputs the frequency written on the top of the can. Now go find one that runs at 4.43361875MHz. Any luck? Didn’t think so. These bastards are damn near impossible to find, and when you do the price is stupid (£30, WTF?). I guess since no one uses composite video any more, they don’t make them any more. Well that sucks.

Update: User fluxcore over on the assembler games forums pointed me to a cheap source of PAL oscillators – D’oh! Anyway, this page still describes a fairly cheap way to achieve the same thing. If you want to go the oscillator route though, try here: http://www.aliexpress.com/item/10PCS-Lot-4-433619M-Crystal-Oscillator-4-433619MHz-13-21-13-21-5-08mm-Square-active/949416078.html

Oscillator circuits

The next logical thought is, “can I make my own oscillator”, and the answer is, in theory at least, yes, and a few of the guides and many forum posts explain how to do it.

You basically get an actual quartz crystal of the right frequency (which is actually not that easy for PAL), and make a little oscillator circuit with some resistors and capacitors that should generate the right frequency clock signal. Most people use Pierce oscillators, you have to tune them, and they are a bitch. The internet is full of people trying and failing to make these things work. Somehow, through voodoo, luck, or genius, some people have actually made them work, but the gods alone know how because I’ve tried many times to make a number of different oscillator designs and none of the worked. The problem is that 4.43361875MHz is really very fast, and to tune an oscillator circuit properly you need very small capacitances. So if you make a little circuit running at that speed on breadboard, the parasitic capacitance of the board is going to screw up the tuning. I’ve tried making them with wires and deadbugging too, I just can’t make it work.

Time division

At this point I basically gave up for a while. I consider myself fairly good at electronics, certainly not bad, and I had failed miserably five or six times to make this work. However, after coming back to it recently (and failing once more) I had an idea. Why mess about with all these impossible arcane analogue circuits when we can handle the problem another way completely – we know that if we divide the system clock by 12 we get the right frequency. So let’s make a clock divider instead!

My A level electronics project was based on clock dividers, and they’re very straightforward to build out of flip flops. Division by 2 is easy, just a single D-type flip flop as follows:

Divide by 2 counter

From there you need to do division by 6, which is a bit more complex but can be achieved with a Johnson counter:

Mod 6 Johnson counter

Mod 6 Johnson counter

And there it is. All that remained was to find some fast enough flip flops. I found the 74ACT175, quad D-types that will run up to 150MHz. A slight shame is that the divide 2 and divide 6 parts of the circuit need separate clock inputs, so two chips are needed even though only 4 D-types are actually used. The circuit itself is really simple:

Div12 Circuit

I decided to build it without using any actual breadboard to make it really small. Below are some pictures, I’m afraid they aren’t great as I was having trouble getting my camera phone to focus.

The picture below shows where the signal is fed in to the encoder. You can just see where I’ve cut the trace, it’s the middle one of the three I’ve exposed. Note that I took this capacitor off later, as I realised it wasn’t at all necessary (it was a remnant from an earlier attempt with an oscillator circuit).

encoder input

This low quality pic shows where you get the clock source from:

Clock source

Here’s the whole thing just before I put the lid back on:

Finished mod

One neat thing about the Mega Drive 2 is that there’s this hole at the back that is basically ready made for a toggle switch, so I didn’t have to drill a hole in the case or anything:

Toggle switch toggle2

This should work on the Mega Drive 1 as well. You should also be able to do a similar mod on an NTSC Mega Drive too, but your circuit will need to divide by 15 instead of 12.

Finally, thanks to all those out there who wrote guides and gave information on forums that helped me figure this out. I hope this in turn can help some other people!

Posted in Uncategorized | 1 Comment

BarCamp Canterbury 2013 round-up

A great time was had at BarCamp Canterbury 2013, held at the University of Kent, In Canterbury, on the weekend of 27th and 28th April! Around 100 attendees made it a fantastic event, with a huge range of talks, workshops and discussions. If you’d like to get a feel for the topics and activities, see our Twitter feed. We have been lucky enough to be featured in some brilliant write-ups, please see below for details…

Thank you to all the attendees to came along, took part in, promoted and wrote about BarCamp Canterbury. Thank you again to our sponsors, without whom BarCamp Canterbury would not be possible. We look forward to seeing you next year!

Posted in Events | Tagged , , , | Leave a comment

PiPurr – The Remote Cat Interaction Server

PiPurr Server

PiPurr Server

All the best hacks and open-source projects come about by scratching personal itches. In fact when asked by friends and acquaintances “How do I start with coding – what should I write?“, that is my usual answer – “Find something you don’t like or would like to improve and do that“.

This brings us to the idea of PiPurr, what I like to call the Remote Cat Interaction Server.

Whenever we go on holiday, we never really get to relax, because Hannah is always asking me things like “Do you think the cats are OK?“, “What do you think the cats are up to?” etc. PiPurr is the solution to this problem.

The goal is not just to be able to keep an eye on what the cats are doing when away from home, but also to interact and play with them remotely too.

PiPurr is a simple client-server solution. The server runs on a Raspberry Pi, for low power consumption and provides the functionality – capturing images, dispensing treats, making sounds play from the speakers etc, and clients connect to this over HTTP and request those actions.

PiPurr for Android

PiPurr for Android

The server is implemented as a small Python web server, using HTTPServer that, instead of serving static files from a directory, exposes a small number of URIs that correspond to those actions. This means that all that is required to access it is a browser. A summary of the actions are:

  • /cats.jpeg – Capture and return a photo from the webcam. Uses OpenCV.
  • /sound – Play the sound out the speakers to entice the cats over.
  • /treat – Dispense a cat treat – Currently in development, and will use a PicoBorg stepper motor to drive a treat dispenser. Keep a look out for another blog post about this in the future.

The decision to use the (rather large and fiddly to get working on Raspberry Pi) OpenCV for image capture is down to the fact that in the future I am going to write a cat detector, and possibly other vision-based functionality.

A neat addition to the server is the LedBorg, which is an RGB LED add-on, set to flash different colours depending on what happens when requests come in. Red for 403s, 500s etc., green for 200 on the image URI and blue for 200 on the sound URI.



For ease of use, I also developed an Android client that allows easy access to PiPurr whilst out and about. The app also allows for sharing of the captured images over email, Facebook etc.

I will be adding more functionality to the solution as time goes on. Some of the things I have planned are:

  • / – Implement a web UI to control it easier with a web browser.
  • /laser – Move a laser pointer or similar cat to about with motor control.
  • /video – Stream live video.

I plan to talk about this project at BarCamp Canterbury on the 27th April 2013 if you would like to find out more, or have any cool ideas.

Posted in Hardware, Programming, Software | 7 Comments

Introducing ‘The Sin’: Edd’s YM2612 MIDI Instrument

And because I am a slacker, I forgot to thank matth for the chip holders and Mex for being a Boris. Cheers!

Posted in Arduino, Hardware | 4 Comments

OggCamp 12

OggCamp LogoHere at CantHack, we’ve always been fans of Barcamp type unconferences, and between us we have attended many Barcamps over the years, and have even organised one ourselves.

OggCamp is a Barcamp-like event that focuses on free and open culture that has just hosted its fourth annual event in Liverpool.

Some of us from CantHack had attended last year’s event in Farhham, where we delivered talks on reverse engineering and HGD, and this year two of us (Tris and Han) travelled the long journey to Liverpool to once again spend two days meeting, socialising with and learning from a wide cross-section of the geek community.


RFID Rhythm Generator

Han was on the crew for this year’s event, which meant early starts and lots of helping out, although that did mean that I got chance to wander around finding talks to go to.

There were so many interesting talks on the schedules that it was impossible to see all the talks that I wanted to.

I did get to watch about many different subjects including QR Codes, OggBox (an open hardware Ogg player) to Nanode (an Arduino clone with built in networking and RF communications, more on that in a bit).

I also really enjoyed some of the more light-hearted talks such as Alex Martindale‘s look at error messages over the years (inlcuding a huge screen showing the Sinclair Spectrum start screen – which brought back many happy memories!), and an interview with Stephen Fry which, although pre-recorded, was very engaging and more interesting than I would have initially thought it would be.

This year’s OggCamp was also the first to feature an Open Hardware Jam, where we witnessed many awesome hardware hacks like an RFID rhythm generator, DIY retro computers, 3D printing and textile hacking.

I also bought myself the awesome Nanode RF, which as mentioned before, is an embedded development platform similar to an Arduino but with integrated Ethernet and an RF transceiver for wireless connectivity to sensor nodes.



It is sold in kit form so I have all the fun ahead of soldering the components together to make the board. When finished, I plan to hack together some home automation/monitoring with this and a Raspberry Pi. Of course those hacks will also appear here in the near future.

I also took a few photos of the event, which are located on my Flickr page. It’s also worth searching Flickr for ‘oggcamp’ and ‘oggcamp12′ to find more.

Thanks so much to the organisers from Linux Outlaws and Ubuntu UK Podcast, and to Les Pounder for organising the crew! See you all again next year! CantHack will be back!

Posted in Events | Leave a comment

CantHack presents at Digibury.


Thanks to everybody who came to Digibury this week, we had a great time and we hope the people who came enjoyed the session. The slides are available below, as well as the light painting pictures you made! I am probably going to reuse the session for TinkerSoc at some point so please leave any feedback you have in the comments with any way I can improve the talk.

Posted in Arduino, Events, Hardware, Programming | 3 Comments

hgdc-x 0.5.3

I know it’s been quite a while since the 0.5.3 release of the hgd server, but I finally got around to completing the latest version of hgdc-x, the cross-platform GUI hgd client. It is compatible with any of the 0.5.x versions of the server.

hgdc-x 0.5.3

hgdc-x 0.5.3

Changes include numerous bugfixes, a redesigned GUI and a better user experience. There are pre-compiled binary versions for Linux, Windows and Mac (Universal binary for Tiger 10.4 and later).

Get it from http://hgdcx.canthack.org

Posted in Programming, Software | 4 Comments


I would like to introduce WolfBot, a new IRC bot that moderates a game of Werewolf.

Werewolf is a social game in the ilk of Mafia and has become very popular at un-conferences such as BarCamps. There are many rule variants of Werewolf, but this bot probably most closely matches the rules set out in ultimate werewolf, with some changes to make it fit better to IRC, the voting system is slightly different for example.

WolfBot is based on the popular PircBot Java IRC framework. It is a collabrative project between me, Twigathy, and a number of other people. The code is avaliable on github (tpcarlson/Werewolf).

WolfBot is currently playable in #wolfbot on the boredicons irc network and. Use the command “!join” to start playing (please note if there is a game in progress you will have to wait for it to finish before you will get voice in the channel).

This post is a quick follow up to a talk I gave at BarCamp Canterbury, my original slides are available.

Posted in Programming | Leave a comment

BarCamp Canterbury recap.

Barcamp Canterbury Logo

BarCamp Canterbury 2012

Updates on the blog have been a bit thin and far between recently, but that’s because a lot of us have been busy organising BarCamp Canterbury. The event was run a couple of weekends ago (Saturday 28th and Sunday 29th of April 2012) and thankfully all our preparation was worth it as the event went without a (noticeable) hitch.

I thought it would be helpful to share what we have learned, for any one else thinking of organising a BarCamp.


  • Use EventBrite, their service is brilliant, and made keeping track of people/tickets sold a piece of cake.
  • Oversubscribe. We have a 30% no show. If your limit is 100 people you can probably issue 120+ tickets safely.

Food and Drink

  • Fifty people got through 140 pints of Ale and 40 pints of cider.
  • Sainsburys do Catering!
  • People get grumpy without coffee.


  • Follow up with sponsors. Some companies only replied to second email.
  • Make it clear what you expect from your sponsors, and what they should expect from you.
  • Ask for “stuff” many companies won’t give money but they will hand out freebies.

I hope this helps you if your thinking of running a BarCamp or similar event yourself. Please leave a comment if you think of anything else that would be helpful.

Posted in Events | Leave a comment

A brief history of my Zipit Z2

For a while now I have been playing with the idea of building my version of the perfect alarm clock. My original ideas involved the Arduino and the Arduino Ethernet Shield. This all changed when I was introduced to the Zipit Z2.

Unlike the Arduino, it comes with an integrated keyboard and chair screen. For further hardware specifications click here.

My investigations of the Z2 led me to Mozzwald’s site which contains most of what I wanted to know. There are Zipit guides on U-Booting, Ubuntu, etc.

While my Zipit was winging its way from the USA, I started work on my clock application. Using the Lazarus IDE and the Free Pascal Compiler I created the first draft. Setting up the cross compile environment was straight forward and I soon had a binary ready for the Zipit’s ARM v5 compatible processor.

After a week of anticipation, I was finally introduced to my Zipit at the Rochester Can’t Hack meet. I started by flashing the Z2 with a U-Boot image I downloaded. To get the image flashed I booted into the Z2′s stock OS and selected the reset to defaults option.

Using Mozzwald’s z2sidX image I booted into Debian Sid. Following this was a back and forth between the Can’t Hack group about keyboard layout. Needless to say I was a very happy to see X start and spent a few minutes playing Free Doom.

For the past few days I have been perfecting the sid image I am using, including changes that allow for better integration of my Clock application.

Some notes on my changes:

Installed avahi-daemon openssh-clients nfs-common

For the dbus install (avahi-deamon dependancy) I selected not to overwrite the dbus config file with the package maintainer’s version. This caused issues with dbus failing to load. To fix this I purged dbus and reinstalled avahi-daemon.

Something I noted was the MAC address used by Debian Sid was not the MAC address printed on a sticker found under the battery. To fix this I edited /etc/network/interfaces.

user@zipit:~$ cat /etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto wlan0
iface wlan0 inet dhcp
hwaddress ether 00:12:34:56:78:ab

To change the host name to “zipit” I used the hostname command and also edited /etc/hostname and the /etc/hosts file.

Note: I installed avahi-daemon to enable machines on the local network to find the Zipit on the network using the .local domain. i.e. ping zipit.local will resolve. This is why /etc/hosts contains the information below. localhost.localdomain localhost zipit

I then configured samba by editing  /etc/samba/smb.conf and used pdbedit to add a samba user login.
# pdbedit -a -u user

I have noted that the EWOC script provided on the z2sidX image has trouble configuring the wireless network when SSID’s contain spaces. I have fixed this issue and informed Mozzwald.

My work then shifted to my Clock application. I started adding features including a five day weather report, a week day alarm, timer and reminders. Another feature I wanted to add, was the ability to play music from a NFS share. I tested mpg123 and found that mp3′s played well when they were on the local flash drive but streaming off the NFS share was unworkable due to stuttering.

After adding the MP3 playback feature to Clock, I purchased a 32GB Sandisk Micro SDHC card to use for Zipit music storage. To my disappointment the card did not work with the Zipit Z2. The boot precess ended with I/O errors.

It seemed my dreams of adding music to the Zipit were in tatters, but then the word “buffers” popped into my head. When mpg123 plays back MP3′s on the Zipit it only uses about 15% of the processor’s capabilities. The stuttering had to be related to networking because local playback worked, the solution had to be buffering.

I changed the mpg123 command line for Clock to include a 2MB output buffer. Problem solved.

Clock's main window showing five day weather report.

The original idea was to open-source Clock under GPL, the problem is that the site I scrape weather information from prohibits scraping. Perhaps the solution is to get information from another source. I am willing to implement this alternative and release the source and binary for Clock. Suggestions are welcome.

My remaining issues include a long reboot time which I believe is related to the error – libertas failed to find firmware.

On boot up I get the error “boot wlan0 link not ready” from addrconf
and 200 second boot time.

Thanks go to Tristan and the Can’t Hack group, Mozzwald and all those that contributed to z2sid, Lazarus, FPC, Linux, GNU, etc …

Posted in Hardware, Programming, Software, Unix | 4 Comments