Saturday, May 10, 2008

NanoSync


This is a device that will synchronise Nanoloop 1.x to a MIDI clock signal. A custom job for 8BC member Paranym from Melbourne.


You can see a video of this particular interface in action here:
http://youtube.com/watch?v=OQpSCPxz-E8


Arduino Code:
The Arduino code for this project can be downloaded here.


Schematic:


19 comments:

booyaa said...

heya i'm pretty new to all this crazy audio gear, what does that do?

Sebastian Tomczak said...

Oh, hi there. This will sync a Game Boy running Nanoloop to a computer or other device that can output MIDI clock data. It responds to Start, Stop and Tick bytes.

nitro2k01 said...

Wait, GB link in one end (of course) but RCA in the other end...?
I reckon that could be confusing if someone finds the box and doesn't know what the it'is doing?

Sebastian Tomczak said...

For sure, but I think it is okay for two reasons...

a.1) this device is just a one of, really (hopefully)

a.2) ... so, i will tell him. and then he knows. ie. no confusion between the two of us.

b) the idea is that one can hack up, say, a GBC link cable and attach the RCA end so that one can choose between syncing a colour or a dmg-01 or whatever.

c) maybe its an easy way of adding strain relief for the cable and the circuit inside (?), (i assume you are suggesting to hardwire a link cable onto the board??)

Sebastian Tomczak said...

that's more than two reasons! aggghhh. don't mind me. :-)

Intosia said...

Hi,

Im gonne build this sweet thing, gor NL few days back and syncing with Korg EMX is a must have...

I was wondering, IC2 is that Optocoplar? (got a number?)

Intosia said...

Hi,

I tried all afternoon building this, and it doesnt work... What type of optocoupler/diode (i use 4N27 with a 1N4148 diode) are you using? I the schematic 100% correct?

Thanks

Intosia said...

Nevermind, it works :) Although i i dont know what i done diff know...

Works like a sharm, thx man :)

Rich said...

Hi,
I breadboarded the circuit, hoping to use it for MIDI sync between a computer or drum machine and an analog synthesizer I am building.

I am using an Atmega 328 programmed via Arduino Duemilanove, a 16MHz crystal (with two 22p capacitors) plus a CNY-17 optocoupler, but sadly cannot get it to work.

Perhaps I am missing something regarding the Atmega 328?

Any comments would be greatly appreciated!

Rich said...

As a postscript to my last post, here's what I have found works so far:

FL Studio is sending MIDI Clock to the opto-isolator via a USB/MIDI cable.

The opto-isolator is passing MIDI clock signal to the Atmega 328 (pin 2).

The MIDI sync code has been successfully uploaded to the 328.

The crytal osc must be working, because the 328 will run the LED Blink sketch OK when uploaded via Arduino board, and sited on breadboard.

This is my first Arduino project, so it would be great to get it working so I can do other things with this great platform!

Can anybody see what I might have done wrong? Thanks again!

Sebastian Tomczak said...

Hi Rich, are you 100% sure that the mcu is receiving the MIDI data? If it is, I don't see a reason why this should not work.

Rich said...

Hi, I checked the MIDI signal at pin 2 of the chip, and it seems to be in order.

I also tried inverting the waveform with a transistor circuit, just in case the opto was not supplying the correct waveform polarity, but still nothing from pin 4 of the Atmega.

Sebastian Tomczak said...

Ah! I see the problem (maybe). This code is for an older version of the IDE, where the baud rate can be a variable.

Use the following instead:



/* NanoSync

MIDI Clock --> Nanoloop 1.x sync

by Sebastian Tomczak
May 2008

*/

// MIDI Real Time Bytes
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;


// Working Variables and Pins
int nano_flip = 0;
int nano_pin = 2;
int play_flag = 0;
byte data;


// Setup
void setup() {
Serial.begin(31250);
pinMode(nano_pin, OUTPUT);
}


// Program
void loop() {
if(Serial.available() > 0) {
data = Serial.read();

if(data == midi_start) {
play_flag = 1;
}

else if(data == midi_stop) {
play_flag = 0;
nano_flip = 0;
}

else if((data == midi_clock) && (play_flag == 1)) {
nanoSync();
}
}
}


// Functions
void nanoSync() {
if(nano_flip == 0) {
digitalWrite(nano_pin, LOW);
nano_flip = 1;
}

else if(nano_flip == 1) {
digitalWrite(nano_pin, HIGH);
nano_flip = 0;
}
}

Rich said...

Hi Sebastian,
Thank you for posting the revised code - sadly it didn't do the trick (pin 4 stubbornly refuses to give us any output!).

I don't think the chip is damaged, because it has been handled very carefully, and no pins have been shorted. Perhaps there is something else about the code that has to change to make it work with the IDE?

Thanks again,

Rich.

Sebastian Tomczak said...

Hi Rich,
I really don't know as I have never used the 328 before - perhaps there are subtle differences somewhere, but I would not know.

Unfortunately I don't have access to a 328 setup at all, so I can't really do anything at the moment - perhaps try and post on the Arduino forums?

Rich said...

Good idea - if all else fails, perhaps I could use an older chip with your code.

Thanks a lot for all your help! I will spread the word about your great blog....

Sebastian Tomczak said...

Sorry I couldn't help you, Rich. It seems like it will be something quite simple.

Rich said...

Hi again - no luck on the forum, so could I just ask which chip you used for the NanoSync, so I can check if there are differences between mine and yours?

Thanks again.

elephantapede said...

Hi I'm very impressed with all of your projects, I was wondering if you could help me with a project of my own, or at least point me in the right direction. I want to sync a Gameboy Micro running nanoloop 2.5 and a DMG running nanoloop 1.5 to a MacBook running Ableton Live. I don't know much about circuitry, soldering, and arduino but I'm reading about schematics now. I was thinking I'd like to undertake this myself as I haven't found anyone I could commission for this. Could you tell me what I would need and help me design a schematic? If you had the time of course. Also, how is the code imbedded into the board? Forgive my ignorance, I'm not sure if these questions are even valid.