Atmel, emulate-the-f1, Hacking, Performance & DJing, Traktor

Emulating The Traktor Kontrol F1 – Part 2

Development Setup

In Part 1 of this post, I explained the background of this project. Now I’m going to detail the hardware and software development setup I am using.

N.B. Since starting this series, Traktor 2.6.2 has been released, which allows MIDI mapping of the Remix Decks. I’ve decided to finish this series anyway, however, as it has a lot of information that is helpful for Arduino development in general, as well as for building custom controllers for the Remix Decks (and other HID and MIDI applications also).


First let’s look at the MIDI Shield. It comes unassembled, so a bit of soldering is required. I also opted for a set of header pins so that it could be used on a breadboard or stacked on an Arduino board as a shield.

Some careful soldering, and the MIDI Shield is assembled. The Uno came with female headers already installed, so no work was required there. A few other parts make the development process easier as well: a breadboard, jumper wires, LEDs, resistors and a momentary contact button.

On the breadboard, I’ve wired all the bus strips together, so that I can get +5 VDC and GND easily anywhere on the board, and reduce the clutter a bit. I’ve also connected these to the banana jacks to make it easier to use an external supply- otherwise these will be powered from the USB connection to the Uno board.

Arduino Leonardo
Arduino Leonardo

One other component that I haven’t mentioned is an ISP (In-System Programmer). Once the ATmega16u2 on the Uno has been flashed with custom firmware, we can no longer load sketches onto the ATmega328 using the Uno’s USB connection. The ISP connects to the ICSP (In-Circuit Serial Programming) header on the Uno, and lets us program the ATmega328 directly. Without an ISP, it would be necessary to flash the ATmega16u2 back to the original Arduino firmware, load the sketch, then flash it again to the custom firmware- doable, but a longer process. Most (all?) Arduino boards can double as ISPs, so I chose to use an Arduino Leonardo that I already had on hand.

Here is the final schematic for the development setup, along with a picture of what it looks like assembled on the breadboard:

Serial To F1 Schematic
Serial To F1 Schematic

Some notes on the schematic:

  • A momentary SPST button is connected to the Uno (see “DFU” in the legend). The ATmega16u2 is put into DFU mode by momentarily connecting RESET and GND on the ICSP header of the ATmega16u2 (note this is not the same ICSP header as the main ATmega328). The switch just gives us an easy method to go into DFU mode.
  • The MISO, SCK and MOSI pins on the ICSP headers on the Uno and Leonardo are directly connected, and Pin 10 on the Leonardo is connected to RESET on the Uno.
  • The three LEDs connected to the Leonardo (note the resistors to limit the current flowing through the LEDs and prevent damage to both the LEDs and the Leonardo- read more here) indicate the status of the ISP software- from the ArduinoISP sketch:
    // Put an LED (with resistor) on the following pins:
    // 9: Heartbeat - shows the programmer is running
    // 8: Error - Lights up if something goes wrong (use red if that makes sense)
    // 7: Programming - In communication with the slave
  • RX and TX on the MIDI Shield are connected to pins 4 and 5 respectively on the Uno- we’ll use these pins with the SoftwareSerial Library.
  • I didn’t have an ICSP header cable, so instead I used shorting jumpers like these (commonly found on IDE hard drives and optical drives and PC motherboards- you have to use the ones that are open on both sides). You can slide these onto a pin and then use the other side of the jumper for a jumper wire.


The software side of the development setup involves setting the Leonardo up as an ISP and installing an environment to build the firmware code for the ATmega16u2 and load it using DFU mode. Luckily, the Arduino IDE includes an ArduinoISP sketch that will satisfy the first requirement, which does (almost) exactly what we need it to do.

To get rid of the “almost” we need to make two simple changes. Open /Applications/ with your favourite text editor (I’m a Mac guy, so PC folks will have to figure out the file path themselves). Add the following lines to the end and save: as ISP

Next, open the Arduino IDE and load the ArduinoISP sketch from the “Example” section of the File menu. Change the following line (recall that we’re using pin 10 on the Leonardo for RESET) and save the updated sketch as “LeonardoISP”:

#define RESET     SS


#define RESET     10

Now connect the Leonardo to the computer via USB. In the Arduino IDE choose “Arduino Leonardo” from the “Board” submenu in the “Tools” menu. Under “Tools” -> “Serial Port” choose the appropriate serial port (on my MacBook Pro it is <code>/dev/</code> but this may vary depending on your setup). Choose “File” -> “Upload” and the sketch will compile and upload onto the Leonardo. If all goes well, you should be rewarded with a slowly pulsing LED on pin 9.

WIth the ISP sketch successfully loaded onto the Leonardo, change “Tools” -> “Board” to “Arduino Uno” and select “Leonardo as ISP” in the “Tools” -> “Programmer” menu and now we can use the Leonardo as an ISP to load sketches onto the UNO via the ICSP headers by choosing “File” -> “Upload Using Programmer” instead of just “Upload”.

To load the firmware onto the Uno’s ATmega16u2, we need to install two additional components. The first is the Atmel build environment- on the Mac an easy way to do this is using CrossPack for AVR® Development from Objective Development. The second component required is dfu-programmer. I use fink and dfu-programmer wouldn’t compile properly from source, so rather than fighting with it, I downloaded a binary for Mac from here and installed it in my path. See my post about how to compile dfu-programmer on Mac OS X here. CrossPack includes libusb, so you can ignore the part about installing libusb.

To load firmware onto the Uno we then do the following:

  • Connect the Uno to the computer via USB
  • Momentarily press the DFU button to put the UNO into DFU mode
  • Run “make dfu” from your code directory (in our case, there is a dfu target in the makefile, as you’ll see in the next part of this series)
  • Power cycle the Uno (unplug both the Uno and Leonardo USB cables from the computer, then replug both of them)
  • That’s it!

Finally, you might consider installing a few additional pieces of software to help in the development and debugging process:

  • The latest IOUSBFamily Log Release package from the Apple Developer Tools (you have to register as a developer to get access to this, but it is free to do so).
  • Hardware IO Tools for Xcode – February 2012 – this is also from the Apple Developer Tools, but the newer releases seem to have omitted the tool we’re interested in, “USB Prober”, so download this version.
  • A MIDI snifer such as as Snoize’s MIDI Monitor.
  • An HID sniffer such as iHID.
  • A good text editor such – I use BBEditTextMate and good old-fashioned vim.

In the next post, we’ll detail the firmware for the ATmega16u2.


Leave a Reply

Your email address will not be published.