Tag Archives: opendeck

Reactions and preorder status

It’s now been almost a month since I published the long-awaited post about OpenDeck v1.0. To say that I received overwhelming amount of responses would be an understatement. So far, OpenDeck has been featured on Synthtopia, AskAudio, GearNews, AudioZine and many other places I forgot to mention. A sincere thank you goes to every supporter out there!

The big news here is that I received enough pre-orders for OpenDeck boards. After all payments are done, I’ll order a new batch of boards and send them once they arrive. This process should take about a month, hopefully less. Note that boards can still be pre-ordered, but next batch of boards will be ordered a bit later.

I have also opened my own domain (finally!), so web configuration utility can now be found on shanteacontrols.com. This blog will also move to that domain soon, so that everything is in one place.

This is all for now, stay tuned for more!

OpenDeck platform v1.0

You’d be forgiven for thinking that OpenDeck project is dead, as well as this blog – after all, it’s been more than a year since the last update. While it’s true that in the past year I haven’t had much time to work on the platform, last couple of months have been full of development again, and this post is an announcement of OpenDeck v1.0 – stable version of firmware, hardware and Web configuration utility. This time, I’ll concentrate on user-facing changes only – low-level changes are going to be discussed in future posts.

In case this is your first visit here, I’ll copy OpenDeck info straight from GitHub:

OpenDeck is a platform suited both for prototyping and developing custom MIDI controllers compatible with any MIDI software on any OS. Main part of the platform is board on which various components used to build a MIDI controller can be connected. The board supports the following components:

  • Buttons
  • Encoders
  • LEDs (single color or RGB)
  • Potentiometers
  • FSRs (force-sensitive resistors)

Hardware

Since my last post, OpenDeck board went through two revisions. I’ve fixed some stuff, and added some as well, however, the basic layout is exactly the same, as well as dimensions. Final version of the board is black – it sure does look nicer compared to ugly green one.

2017-01-30-16-51-26

Now there are three indicator LEDs, compared to two on last revisions. One is for power, and other two are active when there’s MIDI traffic on board (one for input and one for output). Those two LEDs serve double-purpose, as they’re both on while in bootloader mode.

On MIDI side of things, I’ve replaced 6N138 optocoupler with way-faster 6N137.

Configuration utility

This is the big news. Really big. Ever since Google announced the support for Web MIDI in Google Chrome, I wanted OpenDeck configuration utility to run inside it. Building one app which runs on any platform is definitely better than coding three different apps for Mac, Linux and Windows. Since my knowledge of web is pretty miserable, I’ve hired two guys (programmer and designer) to design and build configuration utility based on my specs. I don’t know much about low-level details of utility, but I do know it involves some magic words such as “Angular” and “Javascript”. Concept of utility is actually pretty simple – it has sidebar containing configuration blocks available on OpenDeck – MIDI, buttons, LEDs, encoders and analog stuff. It also has activity log, displaying all incoming and outgoing messages, info window and backup and restore functionality. All configuration is done using custom SysEx protocol explained here. Below are the screenshots.

screenshot859
MIDI configuration block

On MIDI screen, user can configure couple of settings related to MIDI protocol itself, as well as channels for MIDI messages used on OpenDeck. Toggling DIN MIDI in to USD MIDI out will result in all MIDI traffic received via DIN MIDI in connector being forwarded to USB MIDI out, so any older MIDI gear can be used as USB MIDI controllers using OpenDeck  board. You can read more about running status and note off messages here.

screenshot860
Button configuration block

Button window lists all buttons which are possible to configure on board. Even though board has 64 inputs for buttons, 32 analog inputs can be converted to digital inputs (that is, buttons), resulting in total of 96 possible buttons. One of the cool features of utility is that pressing the button connected to board will automatically blink the correct button ID in utility, so that you don’t have to waste time finding it. You can read about how is that accomplished here. Another cool thing is that number of buttons (or anything else) isn’t hardcoded, but generated by the utility. Before the configuration section is rendered, a request is sent to board asking it how many buttons are possible to configure, so utility is future-proof if I’m ever going to increase or decrease number of buttons, encoders etc.

screenshot861
Single button configuration

Clicking on certain button brings up modal window which lists all possible parameters for single button. Here, user can configure button as momentary or latching. MIDI message sent by button can be chosen as well (note or program change) and also, any MIDI ID (0-127) can be assigned to specified button. MIDI ID is used as note or program, depending on which message type is selected.

screenshot862
LED configuration block

LED configuration lists some global parameters applied to all LEDs, as well as list of all LEDs which are possible to configure. OpenDeck supports 48 single-color LEDs, or 16 RGB LEDs, since RGB LED is actually three LEDs in single case.

screenshot863
Single LED configuration

Any LED can have assigned any activation note (0-127). When local control is disabled, LED is controlled with received MIDI note and velocity. You can read more about LED control here. When enabled, any button which sends note same as activation note will control the LED instead. LED can also be configured as RGB LED. Last two options are used for testing LED states (when RGB LED is enabled, different colors can be picked from state test field).

screenshot864
Encoder configuration block

Encoder section displays total of 32 encoders. 64 digital inputs available on OpenDeck can be used to connect those 32 encoders (one encoder takes 2 digital inputs). Note that analog inputs cannot be used to connect encoders.

screenshot868
Single encoder configuration

Encoders need to be specifically enabled in order to function. Encoders send CC messages, and any CC number can be assigned to specific encoder (0-127). Two encoding modes are available: 7Fh01h and 3Fh41h, which can also be inverted.

screenshot865
Analog configuration block

Analog configuration section displays total of 32 components.

screenshot866
Single analog component configuration

Analog components need to be enabled in order to function. This is to avoid junk coming out of floating analog input when nothing is connected to it. All analog inputs can be configured as potentiometers, FSRs and buttons. Default is potentiometer. Any MIDI ID can be assigned (0-127). Potentiometer type will send CC messages with CC number specified as MIDI ID, FSR type will send MIDI note event with note being MIDI ID, and button type will send note event specified in button configuration section. Invert option applies only when potentiometer is active type. Lower and upper CC limits can be used to scale CC values coming from potentiometer and FSR.

screenshot867
Info window

Info window contains some basic info about the board (firmware and hardware version). Checking for updates is done by comparing last tag on OpenDeck GitHub to firmware version currently present on board, which is a very cool feature. Other options include rebooting the board, factory reset and bootloader mode, which is used for firmware update process.

I can say I’m very proud of configuration utility, as it’s one of the first WebMIDI apps used for configuration using SysEx messages! Building a MIDI controller sure does seem easy now. I haven’t had the chance of testing it on Linux distros yet, but it works (mostly) flawlessly on Windows and Mac OS X – mostly because of WebMIDI still being finicky. For instance, MIDI connection sometimes won’t be detected, and leaving the utility idle for some time can sometimes lead to issues. On top of that, Google also requires SSL connection when using SysEx messages via WebMIDI which is a real PITA. Really Google? I hope those issues will be resolved one day, but for now, I can live with it. I also hope other Web browsers will include support for WebMIDI soon – not everyone likes Chrome. There is some activity with WebMIDI implementation in Firefox, though.

Documentation

Undocumented code is worthless. I’ve written extensive wiki on OpenDeck GitHub, so you can check entire documentation here – everything from schematics, connection diagrams, SysEx protocol, firmware update process etc.

Open Source

Most of OpenDeck really is open. I’ve done my best to write clean and efficient code and document entire project. Exceptions to this are board design (gerber files) and Web utility. Those two things are truly custom solutions, and OpenDeck is a platform open enough to be used without them, since my GitHub contains complete schematics and full documentation on SysEx protocol. Maybe someone will build a better board and better configuration app – who knows? In the meantime, my board and utility really are the only incentives for someone to actually spend any money on OpenDeck. At the end of the day, whenever someone buys it, it will make me invest more time into platform, which translates to less bugs, more features and possibly new products. So far, development of platform has been pretty slow. Supporting it will definitely change that.

Availability

Now that board, firmware and configuration utility are ready, you can contact me for pre-order. Pre-order here means that I’ll send the boards to manufacturing once I receive at least 10 pre-orders. I’m selling the board for 111€. Package contains:

  1. Board
  2. USB cable
  3. MIDI cable
  4. Access to online web utility
  5. One year guarantee

Bugs and feature requests can always be reported here.

Thanks for reading!

Marching forward with OpenDeck: The hardware

This post will shed some light on the development of OpenDeck platform, since it’s been quite some time I’ve done any updates on this project. Don’t let the silence fool you – project is very active.

For those who don’t know what OpenDeck is (there are couple of posts about it on this site) – it’s a MIDI platform designed to relieve you of doing tedious stuff in the build-process of a MIDI controller. Those who want to build their own controllers quickly find out that it’s not really a small thing to accomplish, even if there are some great platforms out there which can make the job much easier, such as Teensy or Arduino. You need to know how to write code, choose the right hardware, install software development tools on your computer, deal with all kinds of errors (both hardware and software) etc. OpenDeck allows you to forget about all of that. It’s a system which allows you to pick basic components of your MIDI controller – such as potentiometers, buttons, encoders, LEDs etc. – plug them into the OpenDeck board, and actually use them in your MIDI controller in a matter of minutes. Neat, right? So, how does it work? I’m going to talk about it in a couple of posts, since the project has several layers. In this one, I’ll try to do a hardware architecture breakdown of the project.

The board

The board is 10x10cm in size. It’s 1.6mm thick and the current color is green. It has four M2 mounting holes, one in each corner. I don’t have pictures of the board since I’m currently waiting for it to arrive from ITead studio, but here’s render of front and back (the holes in the corners are not displayed):

eagleUp_OpenDeck-r1_board_top

eagleUp_OpenDeck-r1_board_bottom

Specifications

You can connect various components which are the building blocks of your MIDI controller into OpenDeck board. It allows you to connect:

  1. 64 buttons or 32 encoders max (one encoder is kinda like having two buttons)
  2. 32 potentiometers or FSRs (force-sensitive resistors)  – support for other analog sensors is planned as well
  3. 48 single color or 16 RGB LEDs

The board also contains DIN MIDI in and out ports. MIDI in port can be used in two ways:

  1. MIDI to USB converter, allowing you to receive data from MIDI gear and translate it to USB MIDI to control your MIDI software on a computer
  2. LED control, allowing you to receive data from MIDI gear and control LEDs connected to OpenDeck board.

Schematic

Complete schematic and PCB files can be found on this link.

Power

The board has only one power connector – USB (B type). Board can be used either using computer or standalone, in which case USB wall charger is required – any one will do, as long as it meets USB power spec (5V/500mA).

ESD protection

USB data and voltage lines have ESD protection diodes. There’s a nice article on electro-static discharge on Wikipedia.

Indicator LEDs

There are two LEDs on board – power and bootloader LEDs. Power LED is constantly on when board is powered on, while bootloader LED is only active when firmware update is in progress.

Microcontroller

The brain of OpenDeck board is same microcontroller used in Arduino Leonardo and Teensy 2.0 – Atmel ATmega 32u4. That little microcontroller has USB hardware built right into the chip which allows your computer to recognize it as generic MIDI device, so that there are no drivers required on any major platform (Linux, Mac OS X, Windows).

Button/encoder hardware

In order to read buttons and encoders, a matrix setup is used. There are 8 input rows controlled by 74HC165 shift register and 8 columns controlled by 74HC238 decoder. Matrix uses column-switching to read data and there is only one active column at time during which all 8 rows are being read. There is more info on how button (and LED) matrix works on this link.

LED hardware

LED setup also uses matrix. It has 6 rows and 8 columns. Driving LED matrix directly from microcontroller is generally un-advisable, since the microcontroller isn’t really meant to be current source (or sink) so its capabilities are quite limited in that regard. Matrix can draw a lot of current, so if not careful, you can easily damage the microcontroller. In order to solve this, several components are used:

  1. LED hardware uses dedicated voltage regulator, LP2985-N. Regulator outputs stable 4V.
  2. Each LED row has a MOSFET transistor which turns the row on or off, triggered by a state of digital pin on microcontroller. This way, very little current is required to turn the MOSFET on, and when it is on, transistor draws the current from 4V voltage regulator instead of microcontroller, and feeds it into LED.
  3. Each column is connected to ULN2803 current sink, since 6 rows of LEDs can generate about 200mA of current and absolute maximum microcontroller can handle is 40mA.
  4. Current sink inputs are connected to another 74HC238 decoder so that only 3 pins are required to handle column switching instead of 8.

The big question here was which resistors to choose for LED rows. In order to achieve full brightness, most LEDs require 20mA of current. In matrix, LEDs get switched on and off very fast without you noticing it. Current flawing through LEDs in matrix is called “pulse” current, since it flaws for a very short period of time. If you would pick a resistor for 20mA of current in LED matrix, you would notice that LED isn’t really set to maximum brightness, since the current is actually lower. Because of this, we will calculate the value of resistor to achieve 30mA of current. Another problem rises here: each color of LED has different voltage drop. For instance, red LED usually has voltage drop around 1.7V. Green has around 2.2V. In order to select resistor value, I took the average voltage drop for most popular colors, based on this table. The average drop is 2.3V. For 30mA current, 4V voltage source and 2.3V of voltage drop, a resistor value of 56 ohms is chosen. Since this calculation is based on average voltage drop, the current will vary depending on chosen color.

Analog hardware

For analog components to work reliably, stable voltage is absolutely required. Like LED hardware, analog part of the board also has dedicated 3.3V voltage regulator, MCP1825. To read values from 32 analog components, two 4067 analog multiplexers are used.

MIDI hardware

MIDI in hardware requires the use of opto-coupler – I’ve selected 6N138 as recommended on MIDIbox forums and official MIDI documentation. MIDI out circuit is the same as recommended on Teensy web site.

That would be all in this post – in the next one I’ll talk about the software running on the board.

Building Ceylon

This is a long overdue post about Ceylon, another Shantea Controls controller, only this time, one that I’ve built for myself. Of course, it’s based on OpenDeck platform.

Ceylon was actually built about three months ago. Reason why I haven’t written about it is a combination of things really. First, it was in a beta period for more than a month, and after that I just didn’t have much time to write posts, as I was really busy (and still am) with other projects that I’ll hopefully write about soon.

Name and design

Let’s start with a name. After Anandamidi and Sensimidia, it was time to bring back tea in Shantea Controls again. So, Ceylon is actually well-known high-quality tea originating from Sri Lanka, former British colony known as Ceylon (hence the name). There are couple of variations of it, black one being my favorite (with some spices of course, that is, loads of ginger).

10678704_306345016225412_2880265286737813749_n

Picture above is a rendered drawing of Ceylon design. Numbers around the circle are coordinates of Kandy District, heartland of tea production in Sri Lanka. So there you have it, a Ceylon story!

Layout

Since Tannin was my only controller so far, I’ve mapped nearly every function I need, so when I started designing my second controller, I wanted something really simple that would complement Tannin well. There was no need for a complicated layout or redundant functions, that’s why its design is really minimal. There are 3 faders, 12 orange LEDs for some eye-candy, err, I mean VU-meter, shift button, two potentiometers above faders for gain control, six anti-vandal switches with blue LEDs, and disk. Most significant change here from Tannin is the use of encoder. Well, not your usual encoder though. It’s a salvaged HDD motor acting to be encoder actually.

Plate

Ceylon is first controller I’ve built which doesn’t use standard black/white Gravoply plate, as I grew tired of it. Instead, I’ve picked blue plate this time, and it looks really gorgeous.

WP_20150224_028

I also redesigned USB plate.

WP_20150224_017

Case is white again, just like Tannin.

The disk

As I’ve already stated, only thing new in Ceylon is the disk. So, how does it work? The motor in mechanical hard disk generates phase-shifted sinusoidal waveforms when spinned. The faster you spin it, larger the amplitude and frequency of waveforms. By examing waveforms, you can determine disk direction, which is what I needed. There are couple of issues with this:

1) Signal amplitude is way too low to be sampled directly by a microcontroller, unless you spin the disk real fast, which is kind of missing the point of whole setup as you want fine grained control. My measurements showed that disk generates +-500mV when spinned at maximum speed (maximum being somewhat subjective term, I spinned it by hand).

2) For encoders, you don’t actually need analog signals, but digital ones. By examining output data from two encoder pins, you can easily determine its direction. Those two outputs are called quadrature outputs, as they are 90 degrees out of phase.

600px-Quadrature_Diagram.svg

ScreenShot209

Making the signals digital

Basically, what this setup needed was ADC (analog-to-digital converter). For this use, I’ve chosen LM339, a very cheap, available and popular comparator. LM339 contains four comparators in a package, making it suitable for this setup, as I needed only two. Comparator takes two inputs, and simply determines which one is bigger. If voltage on non-inverting input (+) is larger than voltage on inverting input (-), output is digital 1, or Vcc, and if non-inverting input is smaller than inverting input, output is digital 0, or -Vcc (in this case GND). Very simple. But as usual, there are couple of caveats.

Issues

Connecting motor inputs directly to LM339 isn’t such a good idea, for two reasons:

1) What happens if two signals are very close to each other? Comparator would output bunch of ones and zeros very fast, which is actually junk, so you get unreliable results.

2) According to LM339 datasheet, you cannot apply more than -0.3V at either of its inputs. This is a problem, as disk actually outputs about -0.5V when spinned real fast.

Hysteresis

It took me really long to figure out what hysteresis actually is, but it’s actually really simple. Using hysteresis on comparator, you are creating two thresholds for generating two output states, that is, you are setting one threshold for output to be Vcc, and second one to be -Vcc, that is GND. This is achived by applying positive feedback from output back to input, using two resistors. Since signal from motor is really low, I’ve designed hysteresis for low values, just to keep signal from circling around switch point. Hysteresis is calculated using this formula:

Vth+ = -VN ∙ (R1 / R2)
Vth-  = -VP ∙ (R1 / R2)

Vth is threshold voltage, Vn is negative output (in this case 0V), and Vp is positive output (+5V in this case).  I wanted to set positive threshold above 0V, and negative below -5mV, so resistor values are 1k for R1, and 1M for R2:

Vth+ = -0 * (1000/1000000)
Vth+ = 0V
Vth- = -5 * (1000/1000000)
Vth- = -5mV

So, when positive input voltage is above 0V, output is 1, and only when negative input drops below -5mV, output is 0. This way I created “dead zone”, or area where my signal can be of any value (between 0 and -5mV), without affecting the output of comparator.

250px-Smitt_hysteresis_graph.svg

Graph is showing the input signal (U), usage of comparator on that signal without hysteresis (A), and output signal from comparator with applied hysteresis (B).

2000px-Op-Amp_Schmitt_Trigger.svg

Picture above shows hysteresis setup. This is how you debounce your inputs using hysteresis, so that your output never becomes gibberish.

Voltage clipping

Now, there is one more concern. As I stated already, inputs on LM339 cannot be smaller than -0.3V. To accommodate this, I used BAT46 Schottky diode on inputs, having anode connected to ground. When the input is positive, diode doesn’t do anything as current cannot pass through. When the input is negative, diode still won’t do anything, as long as input voltage doesn’t become smaller than -0.3V. Those diodes have a voltage drop of about 0.3V (how convenient), so, when input voltage exceeds -0.3V, current will pass through diode, and voltage on comparator input will actually be voltage drop on that diode, and it will not exceed those -0.3V. Two problems solved, yay!

encoder

Software side of things

Now that I’ve taken care of hardware, it was time to actually read and process signals from motor. For this, I’ve used modified encoder library for Teensy/Arduino. Library is great as it has two really clever parts:

1) Since it’s written with Teensy/Arduino in mind, it automatically detects whether the pins on your microcontroller on which you’ve connected encoder have interrupt capability. If they do, library reads encoder using interrupts. Since HDD motor can be spinned real fast, I’ve connected both motor pins to interrupts (pins 2/3 on Arduino) in order not to miss any pulse. Pins 2 and 3 are two out of four unused pins on my OpenDeck board, so this was very convenient.

2) It has “predicting” algorithm, giving your encoder 4x more resolution. This is achieved by remembering previous state of pins, and comparing it to current state of pins with a lookup table. Lookup table contains valid encoder transitions:

ScreenShot210

This works really, really well, but since HDD motor jumped a bit when changing direction, I’ve implemented additional debouncing:

void OpenDeck::readEncoders(int32_t encoderPosition) {
if (_board == SYS_EX_BOARD_TYPE_OPEN_DECK_1) {
if (encoderPosition != oldPosition) {
if (millis() - lastSpinTime > ENCODER_DEBOUNCE_TIME) initialDebounceCounter = 0;
if (encoderPosition > oldPosition) {
if (!direction) { initialDebounceCounter = 0; direction = true; }
if (initialDebounceCounter >= ENC_STABLE_AFTER) {
sendPotCCDataCallback(127, 127, 5);
} else initialDebounceCounter++;
}
else if (encoderPosition < oldPosition) {
if (direction) { initialDebounceCounter = 0; direction = false; }
 initialDebounceCounter++;
if (initialDebounceCounter >= ENC_STABLE_AFTER) {
sendPotCCDataCallback(127, 1, 5);
} else initialDebounceCounter++;
}
oldPosition = encoderPosition;
 lastSpinTime = millis();
}
}
}

If there is a movement detected, code first checks for whether the disk hasn’t been moved for more than ENCODER_DEBOUNCE_TIME (70mS). If it hasn’t, it resets the debounce counter. This is to avoid extra pulses when disk is slowing down. After that, initialDebounceCounter variable is incremented until it reaches 1. This is to prevent disk jumping when changing direction.

So there you have it, a pretty good resolution from HDD motor for use in MIDI controller! In all honesty, its resolution is far from optical encoders, but as this is more of a proof-of-concept, I’m really satisfied with results.

LEDs on anti-vandal switches

This was another issue that I had while building Ceylon. Anti vandal switches (the ones around the disk) I had around have blue LED on them. Their pins are separated from button pins. Those button pins can be connected in NC and NO configuration, so there’s 5 pins in total. Since I’m using shared column button/LED matrix in my OpenDeck platform, I’ve connected – pin of LED and one of button pins together, going into same column, and then + pin of LED into LED row, and second button pin to button row. Nothing out of ordinary, right? Well, something weird was happening with this setup. Whenever I pressed the button, LED on it lighted up. This is not the behavior that I expected nor wanted, so for a while I had no idea what was happening. Only few days later, I’ve discovered that it doesn’t really matter where you connect + and – of the integrated LED on button, since there are 2 LEDs inside, one of which has anode on + pin, and second one on – pin.

anti vandal configuration

Okay, but why does the LED turn on when button is pressed? For this, answer is in matrix setup. LED/button matrix works by switching columns very rapidly. Only one column is active at the  time, and during that time, it is connected to GND, while others are connected to Vcc. When button is pressed, connection from microcontroller input on which button is connected goes to GND, and button press is registered, but only during the time the column is active. When column isn’t active anymore, it’s connected to Vcc. Since those switches have two LEDs inside, one of which has anode on – pin, when button is pressed, and column isn’t active, that anode is actually connected to Vcc, and LED row on microcontroller starts acting like current sink, so LED is lighted up.

switch

In order to solve this, I’ve placed Schottky diode (to minimize voltage drop) between LED anodes and microcontroller LED row pin, so that the current is blocked for second LED inside switches.

switch2

Demo

So, to conclude this post, here’s a short video of Ceylon in action, together with Tannin.

And also some higher quality pictures of Ceylon.

IMG_8551 IMG_8553 IMG_8565

Thanks for reading!

Sensimidia MIDI controller

Sensimidia is third Shantea Controls controller, and also my second commercial project. I’ve been working on it for the last two months, but most of that time I did nothing, because of some delivery issues with faders and box. Now that it’s finally over, I’d like to present it here.

SensimidiaIn many ways, Sensimidia is similiar to Anandamidi controller. Same buttons, same pots, same faders, same mounting techniques – except for the faders, which I’ve done right this time. It features 24 buttons, 12 LEDs, 6 rotary potentiometers and 2 faders. I’ve also added two additional mounting screws to the plate to avoid its bending, although I should’ve added two more – one in the middle left, and one in the middle right. Design features logo from the guy who ordered the controller. It turned very cool, but then again, that board has magical capability of turning everything into something super-nice.

This controller is first controller I’ve built using my recently-announced OpenDeck platform, therefore, if you’re interested what hardware does this run, scroll few posts below. Worth of note is that even though it’s based on OpenDeck design, it doesn’t mean Sensimidia runs full version of OpenDeck software. Yes, buttons, pots, MIDI input – all of that works, but full controller configuration via MIDI System Exclusive messages doesn’t work yet. Luckily, that is nothing to worry about in this case, since the guy really wanted something simple that works out-of-the-box. I can always update the firmware on controller later – once the OpenDeck platform is finished, and also assuming the guy would actually want the extra features.

Anyways, here’s how Sensimidia looks all wired-up:

OLYMPUS DIGITAL CAMERAAs I said, it’s all very similiar to Anandamidi construction. This OpenDeck board connects to my MIDI USB PCB via pin header right above that electrolytic cap.

OLYMPUS DIGITAL CAMERAThis is how it looks in case. Very nice, but a bit too dark for my taste.

P1010005_crAnd standard USB plate for the cable.

All in all, very fun project again, even though it’s not been really that much different from Anandamidi. Here’s a quick video I’ve taken demonstrating some of controller functionality (really sorry for the lack of good camera and tripod):

Building OpenDeck platform, part 1

I’ve been real quiet about this project for more than a month, but not because I haven’t done anything. Quite the opposite, I literally got consumed by work invested in this project. I realized there’s much more stuff to do than I thought. As I mentioned last time, the project consists of three distinct parts:

  1. PCB
  2. MCU software
  3. GUI application

Apart from some mockups, there’s nothing else I’ve done with GUI for the time being, so I’ll just talk about first two points.

1) PCB

I’ll repeat what I said about PCB last time: it has 32 digital inputs, 32 digital outputs and 16 analogue inputs. As far as digital stuff is concerned, it’s a simple 8×4 matrix with shared columns for both buttons and LEDs. The column switching is done via 74HC238 decoder. Its outputs are connected to ULN2803 transistor array, since Arduino alone can’t handle that much current sink when all 4 LEDs are turned on in a column. Button and LED rows are connected directly to Arduino (with 220Ohm resistor for each LED row). 16 analogue inputs are handled with two 4051 multiplexeres. All in all, fairly simple circuit. Bonus features I’ve came up with are 4 additional configurable I/O pins, which you can configure in GUI app (but not right now, since GUI isn’t finished yet, and there’s not even support for those pins in MCU code). So in essence, you could use those four pins to add two additional rows in button matrix and two rows in LED matrix, resulting in total of 48 buttons/LEDs. Or you can use all four to add 32 additional buttons. Or LEDs. There is some flexibility involved in any case. Here’s how the PCB looks:

OLYMPUS DIGITAL CAMERA

Since I’m already using it in a project I’ll talk about soon, I can tell you that everything works perfectly. No wrong connections or any electrical problem. I did manage to reverse poteniometer labeling though: pots 0-7 are actually 8-15, and vice versa. Annoying? Kinda. Deal breaker? Most certainly not. I’ve also added ground shortcuts to multiplexer inputs, so if you’re not using one of multiplexers (or both), you can quickly shortcut them to GND to avoid floating pins.

OLYMPUS DIGITAL CAMERA

That’s how the board looks like with most of the stuff soldered. There is one (hardly) visible issue: Right above of the ‘A’, ‘B’, ‘C’ and ‘D’ pins (which are those configurable pins I’ve talked about) are GND pins. I intended it to be quick way to shorcut those four pins to GND if they’re left unused, since I don’t like having any pins floating. Now, there is nothing inherently wrong with that idea, except that you can’t simply ground some pins on ATmega chips. I’ve learned it the hard way. After I’ve done all the soldering, naturally I’ve connected all four of those pins to GND since the project I’m using this board for at the moment doesn’t require them. I’ve connected the board to USB via CP2102 serial-to-usb converter, but the LED connected to pin 13 on Arduino didn’t blink at all. After you connect the board to USB, that LED blinks for 6 seconds, after which your code starts running. In this case, only the power LED got turned on, so there was apparently something fishy going on. First I simply tried to upload code to the board using serial converter, but that didn’t work. I think the message in avrdude said something along the lines of “board is not responding”, or similiar. Weird. After that, I assumed that maybe I accidentally removed the bootloader while I was playing with the Arduino couple of days earlier. I connected my USBASP programmer to the board (or more precisely, soldered the cables to pins sticking out since I had no other way of doing it) and decided to simply burn the bootloader onto the board, but that also didn’t work. I got similiar message like when I tried to upload new code via serial converter. Damn. After that, I started to wonder that maybe 10nF electrolytic cap and 0.1uF cap are too much capacitance, causing the board not to work properly, because I had the same scenario with my USB MIDI PCB (you can read about it couple of posts below). So I simply cut the 0.1uF cap at first to see what happens (that’s why the cap right next to the electrolytic cap may seem a bit weird, because later I’ve re-soldered it). Nothing. Then I almost cut the electrolytic cap as well, when it hit me. When you upload new code to your board via external programmer, you connect MOSI, MISO, SCK, reset, VCC and GND pins from programmer to ATmega. MOSI, SCK and MISO are pins 11, 12 and 13 on Arduino board. The unused ‘A’ and ‘B’ pins are actually pins 12 and 13 on Arduino. See the problem here? How the hell am I supposed to upload new code to board via pins which are connected to GND? Then I simply removed the solder shortcuted to GND pins, and magically, board worked. Another lesson learned. Apart from that, there were no other issues.

2) MCU code

There’s been many changes and optimizations in code since the last time I posted. I removed HardwareReadSpecific library since hardware control is being handled via callbacks now, so all the configuration is being done within main program now. There is added benefit of being able to compile the whole OpenDeck library as a single file and simply including it as precompiled binary in other projects, but since it’s still under heavy development, I wouldn’t have any use from it. I’ve also made a “database” of parameters in EEPROM, like MIDI channels, blink time, button notes, CC numbers etc. There’s also array of default parameters in code, so that there’s an option of performing “factory reset” of MIDI controller. I’ve saved those default parameters in PROGMEM part of ATmega memory, since I would’ve wasted limited amount of available SRAM otherwise. 1kB of EEPROM may sound like tiny amount of space, but in reality it really isn’t. You are free to check the code on my GitHub page. I still have to design my own SysEx protocol to program the controller. I hope I’ll manage to finish that in the next few days, after which I can move on to GUI app.

That would be all for now.

Announcing OpenDeck platform

In the last few days, I’ve finally put all of my ideas into one, coherent project called OpenDeck. For those of you who don’t already know, OpenDeck started as my vision of open source MIDI controller. I didn’t mean open source as just the code – it was a complete open hardware project, with vector design, electronic circuit, PCB schematic and last, but not least, the code itself freely available on my GitHub account. Eventually, OpenDeck source code got transformed into a helper library, which I happily use (it’s the base of Anandamidi and Tannin, two controllers I’ve built). I’ve spent few years tweaking it until I finally got super-stable code, so that when I build controllers, and something doesn’t really work, I am sure it’s not the code, but something hardware-related. Therefore, OpenDeck as a platform is really the only logical next step. What the hell am I talking about? Let’s see.

OpenDeck backend

The backend is actually the software which I already have. It’s split into few distinct parts:

1) OpenDeck library

This library (for now) can handle:

  • LED and button matrices
  • blink and constant mode on each LED
  • LED control via MIDI in
  • start-up animation generation
  • reading potentiometers directly connected to ATmega chip or multiplexed via external multiplexer
  • inverting the potentiometer data
  • turning potentiometers into 6-way switches (expandable)
  • both digital and analogue debouncing
  • MIDI channels selection
  • long-press button mode (buttons can be configured to send a MIDI event after they’re pressed for defined time)

For now, that’s it. As you can see, it already has lots of options, however, the features I’m planning to add are:

  • rotary encoder support
  • RGB LED support
  • anything else?

2) HardwareReadSpecific library

This library talks directly with OpenDeck library. The only thing it contains is hardware-specific code. As an example, let’s see how OpenDeck library gets reading from whole column in button matrix:

void OpenDeck::readButtons() {

uint8_t buttonState = 0;
uint8_t rowState = HardwareReadSpecific::readButtons();

...

}
 
And readButtons() in HardwareReadSpecific looks like this (example taken from Tannin controller):
uint8_t HardwareReadSpecific::readButtons() {
     
    //get the readings from all the rows
    return (PINB &amp; 0x0F);
     
    }
So, OpenDeck library contains only generic stuff, while HardwareReadSpecific deals directly with the hardware. This kind of implementation allows for extremly simple change of microcontroller used in the project.
 
Apart from dealing with hardware directly, HardwareReadSpecific library also contains lots of switches. Using them, you can easily enable or disable LED or button matrix altogether, define debouncing time, blink duration and much more. Code is up on my GitHub account, so can check it yourself.
 

3) MIDI library

 
This is the only part of the code which isn’t written by myself, although I’ve trimmed out the parts from it which I don’t need. This library is responsible for actually sending and receiving MIDI data. The most powerful part of it is exactly the incoming data parser. Library is written by Francois Best, and you can find the latest version of it on his GitHub account. It’s worth of mention that latest version is 4.2, while I’m using older-but-proven modification of 3.2 version (also available on my GitHub, redistibuted under GPLv3 conditions).
 

4) main file

 
If you’re ever done any programming in your life, you already know what main file is. If you haven’t, then you’ve also probably skipped this entire section. But, simply put, main is where your code starts. In microcontroller programming, it usually has two distinctive parts: setup, in which you call constructors, initialise everything you need, and run some code which only runs on start-up, such as LED animation, and loop, which runs until you disconnect power from your microcontroller. This file calls OpenDeck functions. After OpenDeck library gets stable data from inputs, it uses callbacks to MIDI library to actually send the data, or store the incoming stuff.
 
I’m really happy about the modularity of my code, since this way, I can develop each of the four parts independently, without breaking whole code.
 

OpenDeck frontend

Okay, how about we make it interesting? Even though I’ve went through pretty-much all of the code which powers my MIDI controllers, I consider it only to be backend. So, what would be frontend? GUI application, of course! If all of this sounds familiar, well then, it should, because Livid Instruments makes everything I’m talking about in this entire post. Go check it yourself. What they’ve done is pretty amazing. They’ve got a PCB board on which you can connect anything you like, pots, encoders, LEDs etc. It all comes pre-programmed, it’s MIDI compliant, and it also has GUI configuration. There’s only two problems really:

1) Only two PCB sizes (one costs 49 and other is 189$, which makes for quite a gap for projects of mid-size)

2) It’s not open-sourced

Therefore, I’m basically building clean-room implementation based on what I already have. As I’ve already explained, my backend is very modular, so adapting it for other hardware only requires small changes in HardwareReadSpecific library. As far as PCB is concerned, I’ve created design for reference board, which I’ll send to manufacturing after I’m done checking for any errors. The board contains total of 16 analogue inputs, 32 digital inputs (32 buttons or 16 enoders, once I’m done implementing it in software), and 32 digital outputs for LEDs. What powers that board is Arduino Pro Mini, great little tool (also very, very cheap). Board also has headers for my USB MIDI PCB board, which I’ve talked about in my last post. Notice, however, that this is only reference board. Final version will have both ATmega and AU-123 chip integrated into one board, so that there’s no messing with drivers or converters, straight plug-and-play. I’m also planning to have ICSP header, for those feeling adventurous, so that even the ATmega chip is reprogrammable. Of course, board design, as with circuit schematic is going to be freely available, just like software itself.

GUI

I’m only laying ideas here, I don’t even have design mockups yet, however, these are the features which I’m initially planning to have in my configuration software:

  • Testing of whole controller, that is, checking for whether all buttons, encoders, LEDs and pots actually work
  • Controller configuration, which would involve everything from MIDI channel selection, flipping of potentiometer data (or anything else), start-up animation generation etc.
  • Controller programming via custom SysEx messages (that could be a challenge)

I am planning to have GUI running across all platforms, but since I only use Windows, that’s going to be a priority. Also, because of cross-platform availability, source is probably going to be written in Java, unless someone has better ideas. While we’re at it, this whole thing is a pretty big project, so I am looking for contributors. If you’re feeling you can help me developing modular, open hardware MIDI building platform, please let me know!