DIY USB2DIN Sync

Wouldn’t it be nice if you could just plug one end of a cable into your Roland drum machine and the other end into a USB on your DAW and have them play in sync?

Now you can and you can build the cable your self.

The cable uses an ATtiny85 programmed with VUSB to act like a MIDI interface to your DAW, receiveing realtime messages and converting those into DIN Sync24 pulses.

The interface is plug&play and does not require any drivers for Windows, iOS or Android and shows up as a standard MIDI interface.

Roland Sync24

The Roland DIN sync interface is a TTL interface that sends 24PPQN Clock pulses on pin 3 and a high/low state signal on pin 1 for start/stop.

The microcontroller turns the MIDI realtime messages into these signal.

Clock (decimal 248, hex 0xF8)
Start (decimal 250, hex 0xFA)
Stop (decimal 252, hex 0xFC)

Physics

The interface is built on a custom PCB that fits inside the DIN plug.

One end of the PCB is soldered to the DIN plug and the USB cable is soldered to the other end.

BOM

IC1 ATtiny85 Sync24 MCU
R1 47ohm resistor
R2 1.5Kohm resistor
R3 66ohm resistor
R4/R5 Not used
R6 66ohm resistor
Z1 3.6v Zener diode
CLB1 1 meter USB cable
CN1 5-pin DIN plug
PCB1 Sync24 DIN PCB

The kit is $39 and is available at http://webshop.dspsynth.eu

Code

You need the DigiMIDI library found here:

https://github.com/heartscrytech/DigisparkMIDI

To be able to receive MIDI from the host, the file DigiMIDI.h requires some modification.

Add this to the function usbFunctionWriteOut:

void usbFunctionWriteOut(uchar * data, uchar len) {
  if (data[1] == 0xF8) { //If Clock
    CLKcnt=500; //Reset clock counter to 2mS
    digitalWrite(5,HIGH); //Set clock output
  }
  if (data[1] == 0xFA) { //If Start
    digitalWrite(2, HIGH); //Set Start/Stop HIGH
  }
  if (data[1] == 0xFC) { //If Stop
    digitalWrite(2, LOW); //Set Start/Stop LOW
  }
}

And this is the SYNC24.INO sketch:

#include <DigiMIDI.h>;
DigiMIDIDevice midi;

void setup() {
  pinMode(2,OUTPUT); // Run/Stop is output
  pinMode(5, OUTPUT); //Clock is output

  digitalWrite(5,LOW); //Set initial Clock to LOW;
  digitalWrite(2,LOW); //Set initial Run/Stop to LOW;
}
void loop() {
  midi.update(); //Check if any MIDI data is received
  if (CLKcnt) { //Ongoing clock pulse?
    CLKcnt--;
    if (!CLKcnt) digitalWrite(5,LOW); //Reset clock output
  }
}

If you want to build this all by your self the sketch runs fine on the Digispark board.

This is the setup with Reaper to send sync for a Roland drum machine:

The Sync24 is also available prebuilt here:
http://webshop.dspsynth.eu