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 | 3 Comments

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.

Sharing

Sharing

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

[embedplusvideo height="507" width="640" standard="http://www.youtube.com/v/_OiOyxsI5n8?fs=1" vars="ytid=_OiOyxsI5n8&width=640&height=507&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=&notes=" id="ep1626" /]

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 | 5 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

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.

Nanode

Nanode

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.

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.

Light Painting photos:

As a bonus, if you use Google Docs and need to draw circuits I have a bunch of symbols avaliable for use under a Creative commons CC BY-SA 3.0 licence here!

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