Saturday, September 16, 2017

Korg Nanokontrol Schematic + New Firmware

Ages ago I drew a schematic for Korg's original Nanokontrol. I finally decided to dust it off and do something with it.

From the outside the Nanokontrol is just a USB control surface, but inside it hides an AVR microcontroller. It even has the ISP (programming) header broken out, though the pinout differs. With this it seems pretty natural to write a new firmware for it.

I wanted a simple project that demonstrates interfacing the potentiometers, LEDs and buttons. The idea of a CV step sequencer sprang to mind. In order to get nice clean voltage output I decided to add a DAC. The problem with adding to this setup is the general lack of IO pins. The serial pins TX and RX are conspicuously unused, but I chose to leave them free for possible MIDI communication. I don't plan on using USB MIDI, so I freed up IO by removing the USB chip.

PDIUSBD12 USB chip
The USB chip actually serves as the clock source for the AVR, so a replacement clock must be supplied. Step one is to flash the AVR fuses such that it can accept a crystal clock source. This has to be done while we still have an external clock. After that the USB chip can be removed and a crystal can be attached to the XTAL pins of the AVR. Conveniently the USB chip has an external crystal footprint that we can repurpose.

Now most of IO PORTD is free to use. I used one external interrupt pin for the trigger input. This makes it fast and easy to step the sequencer in response to an external clock/trigger. This leave plenty of pins for the DAC (MAX528). It gets its own clock and chip select lines, but it shares the data line with the LED shift register since it's clocked separately.

This is what the schematic looks like after the modifications:

Modified Nanokontrol
This setup works, but the CV output only spans about 0-4V. To broaden this, the DAC can operate on +12V while still responding to TTL level control. It just needs the supply rail and reference voltages changed to 12V. For convenience sake, I also added a 5V regulator. This makes it easy to run the entire setup off of 12V.

MAX528 12V configuration
Now all of the hardware modifications are done. It's time to write some code. The only trickiness comes from interfacing the multiplexed IO. Here is an overview of how to read/write them:

Read Buttons:
  1. Pull PC0-3 low one at a time to enable one column
  2. Pull PC4 low to enable buffer
  3. Read PINB for button statuses (low = pressed)
  4. Repeat steps 1-3 pulling each column low

Read Pots:
  1. Set PA0-2 to select pot from Mux
  2. Read Mux on PA4 and PA6
  3. Read single pots on PA5 and PA7
  4. Repeat steps 1-3 selecting each set of pots

Write LEDs:
  1. Set PC7 high to disable LED output
  2. Write first bit to PD7 (low to turn on)
  3. Set PA3 high, then low to clock in bit
  4. Repeat steps 1&2 for all 8 bits
  5. Set PC5-7 to select column and enable LED output
  6. Delay to allow LEDs to shine
  7. Repeat steps 1-6 selecting each column

The code and schematics can be found on my github here. The code is pretty barebones and simple. It just serves to demonstrate interfacing the Nanokontrol hardware. There are some obvious upgrade and features that can be added, so this is just a starting point.

No comments:

Post a Comment