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

8 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.