MIDI Control Surface (Part II)

At this point we are ready to implement MIDI thus making our Motorized Fader a complete Surface Controller.

We will be able to control volume of any channel of the virtual Mixer of a DAW.

Thanks to Cody Hazelwood for implementing the code of the first Bank of Mackie HUI Protocol for a motorized fader and two buttons.

To accomplish this we will need:

-Two Female 5-pin DIN standard MIDI connectors.

-An Optocoupler.

-One Diode.

-Two 220 Ohm Resistors.

-One 270 Ohm Resistor.

-Two 47 Ohm Resistors.

-Two Push-buttons.

So let’s see the Original MIDI Specifications: midihw.gif

We have there three MIDI circuits we can implement: MIDI IN, MIDI OUT, and MIDI THRU. This last is optional and we will not implement it because it has no sense in our project.

Let’s begin with the MIDI output circuit: this is the circuit featured in https://www.arduino.cc/en/Tutorial/Midi.

You may find this image useful:

image009_15645_640.jpg

Once done this we can connect a MIDI cable from the MIDI Output of our circuit to the MIDI Input of our Audio/MIDI interface.

Now it is useful to install a tool which allows us monitoring incoming MIDI messages such as MIDI-OX (http://www.midiox.com).

Next thing to do in MIDI-OX is enable MIDI Input and Output ports in Options->MIDI Devices.

Some interfaces have an internal loop between MIDI Input and Output ports by default, we can disconnect this loop in MIDI-OX -> View -> Port Routings.

Now we are ready to test our MIDI Output circuit: open the Arduino IDE and load this program extracted form the Arduino MIDI tutorial posted above:

MIDI note player

You should be able to see the MIDI messages corresponding to the notes being played in the Input Monitor of MIDI-OX.

If it is all good now let’s implement the MIDI Input circuit:

The reference design above specifies the long obsolete Sharp PC-900; modern designs frequently use the 6N138.

MidiIn.jpg

A common 1N4148 diode can also replace the 1N914.

Now we are ready to test the MIDI In part of our circuit:

Copy this program into the Arduino IDE (from http://www.hispasonic.com/tutoriales/bricolaje-midi-arduino/38463):

MIDIRX

This program reads incoming MIDI messages and if the message is a NoteOn corresponding to a C3 note in channel 1, the led integrated in pin 13 of Arduino lights for one second.

It is very important to disconnect pins 0 (RX) and 1 (TX) of Arduino while loading the program to the board because the programming is going through the serial port itself connected to the USB,  otherwise we will get errors and the program will not load.

Finally we can send MIDI messages from MIDI-OX itself: Actions->Keyboard and our computer keyboard will work as a MIDI Keyboard.

Let’s press letter Q, which corresponds to C3, and see if the Arduino led lights.

Now we only have to add the two push buttons like this:

PushButton.png

We use here the two 47 Ohm resistors (one for each button) as Pull Down Resistors.

We have to connect the push buttons to Digital pins 2 and 3, because the code uses interrupt function triggered by the push buttons to change channels, which is only available in those pins.

Finally we can load the code to make our circuit a full Surface Controller!

As explained above we used Cody Hazelwood code, but we had to adapt it because the library dependencies had updated their API since 2012, and the original code was broken.

One more thing, once in the DAW selecting Mackie HUI in Surface Controller section was not working but selecting Mackie Control did the trick, try between these two!

Download the code and final schematic here:

MidiMotorFader

Part2_bb

Motorized Fader (Part I)

Introduction

In this tutorial we will make a motorized fader work with the Arduino Uno platform.

This is the first part for making a surface controller capable of controlling volume of any channel of a virtual mixer of a DAW.

We are making this page for the closing of a final project in an engineering course.

Especially for this first part we follow the excellent Cody Hazelwood tutorial:

http://blog.codyhazelwood.me/motorized-faders-and-the-arduino/

So this will be quite similar, the next part will be more useful because there is no second tutorial on Cody’s page.

Fortunately there was code for the two parts, although it was broken, because the library dependencies had updated their API since 2012.

We only had to update the code to make it work in 2016 and we also changed the Arduino Pin Assigments for future compatibility with the MIDI tutorial (Part II).

So, here we go:

Parts Used

  • Arduino Uno
  • Motorized Fader
  • Breadboard
  • H-bridge
  • External 9V DC Power supply
  • 1MΩ Resistor
  • 10μF Capacitor
  • 10K Potentiometer

Fader

The fader used was an Alps RSA0N11M9A0J. You can find it on:

https://www.amazon.es/s/ref=nb_sb_noss?__mk_es_ES=%C3%85M%C3%85%C5%BD%C3%95%C3%91&url=search-alias%3Daps&field-keywords=alps+motor+fader&rh=i%3Aaps%2Ck%3Aalps+motor+fader

A fader is a slide potentiometer, so it works exactly like that:

tgfxhjtgfsaj.jpg

It is very easy to read the fader’s position using analogRead function: this function gets our fader’s position in the range 0-1023 (10 bit value).

To do so, we connect the fader positive pin to +5V from the Arduino, the negative to the ground and the wiper to an Analog In pin, in our case A0.

Motor Control

The fader contains a DC motor, which we will have to control.

The first thing we can try to test the motor is to supply it with 9V. Be careful because the motor can accept no more than 800 mA, you can limit current for example to 600 mA.

Connect the terminals of the motor to the positive and negative terminals of the power supply.

If we put the wiper in the midle, we can see that the wiper moves to one side of the fader when feeding the motor.

Using a digital out pin on the Arduino will give us control of the motor only in one direction, we need something for reverse the direction of the motor.

H-bridge

The device that we need is called an H-Bridge. From Wikipedia: “An H-bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are very useful to allow DC motors to run forwards and backwards”

3.jpg

When switches S1 and S4 are turned, a positive voltage is applied to the motor, and when switches S2 and S3 are turned, a negative voltage is applied to the motor.

If S1 and S3 or S2 and S4 are turned, the motor stops.

We have used a  L293B H-Bridge, because it allows until 1A, but you can also use the more common L293D, which accepts current until 600mA if you limit the current like we have said before.

We will use 2 control pins, 2 output pins, a chip power in, a motor power pin and ground, depending of control pins, the motor will either go forwards, backwards, or it will stop. We can see this here:

4.jpg

Touch Sensitivity

Our fader is touch-sensitive, and therefore, it is not necessary to move the fader for it recognize that is being touched, and you can see the value of the fader without alter it.

Also, when we use it with a DAW , this allows to write automations with “touch-and-latch” methods, those that knows when the fader is touched, this is an important reason to use touch sensitive, other important reason is to protect the motor, to avoid situations like moving the fader and the motor moves the fader in the opposite direction, you can tell the motor using Arduino to stop while the fader is touched.

2.jpg

To detect when the fader is touched, we will use this library:

http://playground.arduino.cc/Main/CapacitiveSensor

We will connect 2 Arduino pin (D7 and D8)  with a resistor with high value (1MΩ) between them, this converts this two pins into a capacitive sensor, which can sense the electrical capacitance of the human body, and detects when the fader is touched.

Circuit Testing

Up to this point, we will use a potentiometer for testing our circuit. Connect the wiper of the potentiometer into an Analog In pin (A3), the positive terminal to Arduino’s 5V, and the negative one to Arduino’s ground.

Using the code provided, we should see that when we move the potentiometer, the fader moves in one direction, and when we move the potentiometer in the other direction, the fader reverses its movement.

Conclusions

Until now we have focused in fader and motor performance.

In Part II, we will implement MIDI.

You can download the code and schematic below:

MotorFader

Part1_bb