Thursday, July 03, 2008

How to Build a MIDI Clock to Game Boy Sync Thing for Around AU$15

Introduction
Here is a simple, step-by-step guide to make your very own MIDI Clock to LSDJ and/or Nanoloop Sync Device.

This device will respond to 'STOP', 'START' and 'CONTINUE' MIDI real time messages, making it compatible with devices that are able to output MIDI clock messages. (eg. a drum machine or a sequencer). You can synchronise up to 6 copies of LSDJ and/or 6 copies of Nanoloop simultaneously to MIDI clock.

If you would like to build one of these yourself, you can contact me and I can send you a pre-flashed Freeduino chip etc for a very low cost. This device cost me around AU$15 in parts to make and it is not very hard at all.




Schematic
There is no need to worry about this schematic is you follow the steps below.
• The above schematic shows what the circuit is.
• In addition, you will need to apply 5V to the Arduino / Freeduino pins 7 and 20, ground to pin 8 and add a 16MHz crystal in between pins 9 and 10 which go to ground via 2 20pF capacitors. Additionally, pin 1 will need to be connected to 5V via a 10k ohm resistor.
• PORTD refers to the IC pins 2 - 6, 11 - 13
• PORTB refers to the IC pins 14 - 19
• PORTC refers to the IC pins 23 - 28




Arduino Code
There is no need to worry about this code if you would like me to send you a pre-flashed chip.

You can view and download the Arduino code here:
http://milkcrate.com.au/_other/downloads/projects/MIDIGBSYNC/




What You Will Need

Let's have a look at the required electronic components:

Resistors
1. 3.3k ohm resistor
2. 110k ohm resistor
3. 220 ohm resistor
4. 10k ohm resistor

Capacitors
5. 20pF ceramic capacitor (x 2)
6. 0.1uF ceramic capacitor
7. 47uF electrolytic capacitor

Diodes
8. 1n4148 small signal diode

Crystals
9. 16.00 MHz crystal

Integrated Circuit
10. 4n25 Optocoupler
11. Pre-flashed Arduino / Freeduino ATMega168

Sockets
12. 14 pin DIP socket (x 2)


You will also need:
• A circuit board of some sort
• A USB A to B cable that you can splice up (or some other 5V power source)
• A Game Boy link cable that you can splice up
• A 5 pin DIN socket with solderable lugs on the back
• Wiring




How to Build It, Step By Step
1. This is the circuit board I will be using in this tutorial. The brand is Datak and the model is 21-113.

2. Solder the integrated circuits and some basic components into place. Solder the 4n25 directly onto the board, being careful not to overheat the IC. If you prefer, use a 6 pin socket instead of soldering the IC directly to the board. Solder the 14 pin sockets to the board, so that they will allow the 28 pin Freeduino IC to fit comfortably in the two. This is where the Freeduino IC will sit, so I will refer to these two sockets as being the Freeduino IC.

Solder the crystal between pins 9 and 10 of the Fredduino IC. Solder the two 20pF capacitors between pins 9 and 10 respectively, and two free positions on the board. When soldering the two legs of the capacitors that are not connected to the Freeduino, use a little bit more solder and join the two together.


3. Solder the resistors and the diode into place. The diode goes in between pins 1 and 2 of the 4n25. The black band on the diode should point towards pin 1 of the 4n25. The 220 ohm resistor goes from pin 1 of the 4n25 to an empty point on the board. The 3.3k ohm resistor goes from pin 5 of the 4n25 to an empty point on the board. The 110k ohm resistor goes from pin 6 of the 4n25 to an empty point on the board.


4. Solder some caps to the power supply busses. The two long strips along the middle of the board are going to be the power supply busses. When looking at the component side, with the 4n25 facing up, the left bus is 5V and the right one is ground. Solder the 0.1uF capacitor in between 5V and ground. Solder the 47uF capacitor in between 5V and ground, so that the side with the white minus signs is connected to ground.


5. Connect power to the appropriate places for the ICs. Ground connections are shown in blue; 5V connections are shown in orange. The unconnected side of the 110k ohm resistor should go to ground. Pin 8 of the Freeduino should go to ground. The unconnected side of the two 20pF capacitors should go to ground. Pin 4 of the 4n25 should go to ground (this can be done quite easily by simply applying a little more solder to the pin and the bridging it across to the ground bus).

Pin 7 and 20 of the Freeduino should go to 5V. The unconnected side of the 3.3k ohm resistor should go to 5V.


6. Looking at the 5 pin din MIDI female connection from the back, point the five soldering lugs downwards. The second-most left pin should be soldered to the unconnected side of the 220 ohm resistor. The second-most right pin should be soldered to pin 2 of the 4n25.


7. Splice a Game Boy link cable. The green wire (clock) goes to Freeduino pin 23 (in fact, you can sync up to 6 Game Boys running LSDJ with this device... simply connect clock signals to Freeduino pins 23 - 28). Connect the blue (ground), orange (serin or serout) and red (serout or serin) to ground. You may need to make more ground connections by bridging the ground bus with another row.


8. Splice up a USB cable and connect the 5V and ground lines to the 5V and ground busses respectively. When looking at the USB connector with the four contacts facing downwards, ground is on the very left and 5V is on the very right. These two lines are usually designated with a red and a black wire.


9. And you're finished!




How To Use It with LSDJ
• Connect the USB connector to a power source, such as a computer USB port or a mains to USB power supply.

• Connect the MIDI connector to the output of a MIDI device that is capable of sending MIDI clock messages (such as a sequencer or a drum machine or an environment such as Max/MSP etc).

• Connect the Game Boy end of the link cable to the Game Boy.

• Start up LSDJ and load the song file of your choice.

• Set LSDJ to slave sync mode in the project screen.

• Select the correct position to in the song that you want to start on and press start. LSDJ will say 'WAIT'.

• Ensure that the output of your MIDI clock-generating device is set up properly to output the MIDI clock signal (for example, in Ableton Live, set the correct MIDI output to Sync On).

• Press start on your MIDI clock-generating device, LSDJ will follow.

• As you change tempo on your MIDI clock-generating device, LSDJ will follow.

• If you press stop on your MIDI clock-generating device, LSDJ will stop. However, to start again from the same position in the LSDJ song, you will need to manually select it and press start before pressing play on the MIDI clock-generating device.




Construction for Use with Nanoloop
This is identical to the steps above, except that the Game Boy link cable must be connected in a different way:
• Connect ground on the Game Boy link cable to ground on the board

• Connect SERIN on the Game Boy link cable to Freeduino pins 14, 15, 16, 17, 18 or 19

31 comments:

nak said...

Hi, very cool tutorial! I was just wondering if you've heard of instructables.com. They have a very neat system for making tutorials pretty easily.

I'll have to try this out :)

ideasweforgot said...

Hey, this is awesome. Exactly what I've been looking for. I've never built circuits though, and the idea kind of scares me. Would you be willing to build one for me? And if so, for how much?

Sebastian Tomczak said...

@ Nak: Oh hi! Thanks for the comment. Yes, I've heard of instructables, but I've never added my own stuff there.

@ideasweforget: please email me and we can work something out, i am sure.

adam said...

Hi there,
just wanted to know how to get a pre-flashed chip?
Could you please email me

adamjohnrex at gmail dot com

cheers

adam

Robert Pook said...

hi there.
is it possible that someone could make and post me one of these. I eill pay ya £50-100. Depending on how good it is. Please get back to me if u interested.

Sebastian Tomczak said...

Hi Robert,
Lets chat over email.

seb dot tomczak at gmail dot com

I am sure we can work something out

"Depending on how good it is"
^^ Although you will need to clarify this statement :) Have a think about how many game boys, what types of game boys, and so on. Maybe there are other features you would like to see as well?

Kind regards,

seb

robert pook said...

hi there
i e mailed you
thanks very much

Charles said...

Thanks for posting this tutorial. I am just curious if providing 1mA to RX is enough to get you a signal?

5v/3300Ohm = .0015 ~ 1.5mA

I am playing around with a 4N25 and having trouble with it.

Is attaching pin 6 to ground via the 110K resistor in order to increase switching speed?

Thank you.

Robin Sutcliffe said...

Hi, I wondered if you got my mail (I mailed you last week sometime)

I would lke to buy a pre-flashed chip from you, is that possible?

ultimatesoundclash (at) gmail.com

Thanks very much,

Robin Sutcliffe

Robin said...

Does this work with GBA and nanoloop 2.3? Trying it out but it doesn't seem to want to. Any tips on the cable colour code/what I could try? Thanks

Sebastian Tomczak said...

Hi Robin,
This should work with Nano 2x in a GBA, however if you are having problems try powering the circuit from the GBA instead of from USB.

If you check out this post: http://little-scale.blogspot.com/2009/08/pin-swapping-gba-cable-for-vcc.htmlyou will find a way to easily get a power line from the GBA cable to power the circuit from the advance itself.

Robin said...

Hi Seb, thanks very much for your reply.

I'm going to try this out tomorrow now, it's past my DIY time... : )

I'll let you know how I get on

Sebastian Tomczak said...

Also Robin, if you're making it just for NanoLoop 2.3, please check out this post: http://little-scale.blogspot.com/2009/08/dual-nanoloop-2-mdi-sync-with-tuplet.html

Robin said...

Ok so it turns out all pins were connected on my link cable, so pin 1 had vcc already.

I still can't get the circuit to operate though.

When I was poking around originally the gameboy crashed a few times and sometimes made some odd noises (this was when I was poking around with the pin one VCC cable, which is white in my case)

Do you think I have fried the 4n25 or the atmega by applying the 3.3v whilst it already had 5v (from USB) ?

Thanks,

Robin

Sebastian Tomczak said...

Hi Robin,
1) Don't use both the USB power and the GBA power - use only the GBA power.

2) Try using a 4n28 instead.

Robin said...

Hi Seb, I had inadvertently used both Vcc's before you suggested to use the GBA Vcc (I must have the only GBA link cable to have Vcc already connected!)

I then tried it with only GBA power and no result, that's why I thought I could have previously fried the chips with over-voltage.

I will try a 4n28 instead, Thank you for your tips!

Robin Sutcliffe said...

Hi, I tried a 4N28, and a 4N27 with no success. Is there any more help you could offer? Do you think if I sent you the circuit you could complete it for me (for a fee of course)I really want to be able to sync my GBA and nanoloop but I am unable to get this circuit working by myself.

Thanks,

Robin

Josh said...

Hi Seb, If you are still up to doing so, I can pay you whatever you like to set one of these up for me. I could probably do it myself but things are picking up for me as an artist and I truly don't have the time and patience to come up with the components and make this happen. I'll send you an email or you can email me if you get to the reply first. thanks.

-josh

shagnetics @ gmail dot com

Benny Ray said...

Hi Seb
I was wondering if this would work with an underclocked gameboy or would this cause sync issues?

ultrastatic said...

Hey there. Great tutorial! I'm wondering if I could get one of the pre-programmed chips. You can email me here dmgking@gmail.com Thanks a lot!

Sebastian Tomczak said...

Hi Ultrastatic, this project is no longer active. However, can I recommend this one, which is basically an updates version with USB support. http://little-scale.blogspot.com/2011/08/usb-midi-game-boy-sync-for-16.html

Anonymous said...

hi,
i'm just wanted to know how to get a pre-flashed chip ? is it available ?
Can you please e-mail me.
andre
andy1210@hotmail.fr

thanks

andr said...

Hi there,
just wanted to know how to get a pre-flashed chip?
Could you please email me.
thanks
andré
andy1210@hotmail.fr

Jaclyn said...

Thanks so much for this article, pretty useful material.

Søren Andreasen said...

Hi,

Great tutorial here!

I just got all the parts (including the freeduino atMega chip), and now all I'm unsure about is how to flash the atMega chip. I have an arduino-board - could I use this to flash it, and do you know how?

you can mail me at: mail AT sorenandreasen DOT com

the best
Søren

Søren Andreasen said...

Hi,

Great tutorial here!

I just got all the parts (including the freeduino atMega chip), and now all I'm unsure about is how to flash the atMega chip. I have an arduino-board - could I use this to flash it, and do you know how?

you can mail me at: mail AT sorenandreasen DOT com

the best
Søren

Søren Andreasen said...

Hi,

Great tutorial here!

I just got all the parts (including the freeduino atMega chip), and now all I'm unsure about is how to flash the atMega chip. I have an arduino-board - could I use this to flash it, and do you know how?

you can mail me at: mail AT sorenandreasen DOT com

the best
Søren

Søren Andreasen said...

Hi,

Great tutorial here!

I just got all the parts (including the freeduino atMega chip), and now all I'm unsure about is how to flash the atMega chip. I have an arduino-board - could I use this to flash it, and do you know how?

you can mail me at: mail AT sorenandreasen DOT com

the best
Søren

Søren Andreasen said...

Hi,

Great tutorial here!

I just got all the parts (including the freeduino atMega chip), and now all I'm unsure about is how to flash the atMega chip. I have an arduino-board - could I use this to flash it, and do you know how?

you can mail me at: mail AT sorenandreasen DOT com

the best
Søren

Søren Andreasen said...

Hi,

Great tutorial here!

I just got all the parts (including the freeduino atMega chip), and now all I'm unsure about is how to flash the atMega chip. I have an arduino-board - could I use this to flash it, and do you know how?

you can mail me at: mail AT sorenandreasen DOT com

the best
Søren

Tyler Barnes said...

Nice device. I would very much like a pre-flashed chip please. a socket would be appreciated too, but is optional. please email me at bassmonster138@hotmail.com