background image

THE ARDUINO SKETCH EXPLAINED

The Atmel Atmega32U4 processor used on the Arduino Leonardo (or Pro Micro)
board has 9 built-in ADC inputs (Analog-to-digital converters), just what
we   need   to   read   9   linear   10K   potentiometers,   that   in   our   case   are   the
drawbars. All this sketch has to do is to read the drawbars and generate
MIDI   CC   messages.   Optionally,   it   can   read   a   push-button   and   lit   2   LEDs
that are used to swtich between two banks of pre-defined CC numbers, that
we can use to control either the Upper or the Lower manual of a Clonewheel
organ.

The   MIDI   stream   is   output   both   from   the   USB-MIDI   port,   using   the   32u4
built-in USB controller, and from the UART port clocked at 31250 Baud as
the MIDI specs require.

So   this   sketch   uses   the   following   libraries   (that   should   be   installed
separately   using   the   IDE   library   functions,   in   case   they   aren't   pre-
installed):

MIDI

 

Library

 

by

 

Fourty

 

Seven

 

Effects

 

-

https://github.com/FortySevenEffects/arduino_midi_library

 

Used   to

generate MIDI messages to be sent to the UART PORT

MIDIUSB by Gary Grewal -  

https://www.arduino.cc/en/Reference/MIDIUSB

Used to generate MIDI messages to be sent via USB

EEPROM (built-in) Used to store and recall the selected CC bank into
the internal EEPROM

The   loop()   function   cycles   through   the   9   ADCs   by   reading   their   current
values and storing them into an array; the same function also "listens"
whether the push button has been depressed (contact to ground, value LOW).
The pin to which the button is connected has an internal pull-up resistor.

The DoDrawbar() function compares the value of a given ADC read by loop()
with the previous value of the same ADC, if the difference is greater than
the   value   set   by   DEADBAND,   it   is   considered   as   a   potentiometer   value
change and generates the MIDI event to be sent. The DEADBAND value is set
to 8, because the ADCs have a 10 bit resolution (2^10 = 1024 values), but
we need to scale it down to 7 bits (2^7 = 128 value), so we can discard 7
values each 8. In other words, if previous value was 1000 and current is
1004,   nothing   changes,   but   if   the   new   value   is   1009,   then   this   is
interpreted as a value change. This mainly prevents unwanted messages to
be sent when drawbars aren't actually moved by the user.

The   SendMidiCC()   function   generates   the   actual   MIDI   CC   message,   while
set_mode() is called each time the button is depressed, switches the LED,
sets   the   value   of   the   "mode"   variable   and   stores   it   into   the   internal
EEPROM.

The   CC   numbers   to   be   used   are   stored   into   the   two-dimensional   array
CCMap[2][9],   which,   as   the   numbers   in   the   brackets   suggest,   contains   2
banks of 9 values each.

Содержание D9U

Страница 1: ...DRAWBAR CONTROLLER D9U An open source Do it yourself project based on Arduino MOUNTING INSTRUCTIONS...

Страница 2: ...led PREPARATION Prepare a clean and tidy surface with just the required tools handy and make sure you have discharged your body from electrostatic charge by touching some metal object that makes conta...

Страница 3: ...Electronic parts Mechanical parts...

Страница 4: ...sistors bend the terminals 90 degrees and add them to the Main PCB as shown in the pictures below Also add the LEDs pay attention to the polarity and the posisions The shorter lead towards the edge of...

Страница 5: ...and the mini TRS Jack STEP 3 turn the PCB upside down and add the 2x8 DIL strip as shown in the following picture Pay attention to have it set straight on the board or you ll have troubles when coupli...

Страница 6: ...t exceed 350 C 660 F and don t keep the soldering pin on the terminals for too long The SIL strip must face the bottom of the board thus the pins will be soldered on the top side as shown in the pict...

Страница 7: ...PU board the final assembly should look like the picture below Now take your cutters and cut the exceeding terminal strip leads on the JACK side as shown below Optionally you can also cut the exceedin...

Страница 8: ...6 black screws must be set to the right side of the drawbar board as shown here below Then insert the spacers on the other side add the main board and fix the bolts using your fingers to hold the bolt...

Страница 9: ...STEP 8 Use 18 out of the 22 M3X4 black screws to fix the drawbars to the metal bottom piece as shown in the picture sequence below...

Страница 10: ...assembly to the drawbars and solder the DIL terminals Slide the boards slighly angled so the MicroUSB connector can easily pass through the hole in the metal panel STEP 10 Solder all drawbar terminals...

Страница 11: ...astic drawbar caps First set them in position using the following color sequence BROWN BROWN WHITE WHITE BLACK WHITE BLACK BLACK WHITE Once done turn the whole assembly upside down and fix them using...

Страница 12: ...2 Put the metal top cover In order to have the jack connector easily pass through the hole in the metal panel start from an angle from the connector s side Use the remaining 4 M3X4 screws to close the...

Страница 13: ...DCs Sends MIDI CC numbers 12 20 or 21 29 according to selected mode Last update July 2018 This is where you can define your CC numbers for the Bank 0 or 1 int CCMap 2 9 12 13 14 15 16 17 18 19 20 Uppe...

Страница 14: ...DoDrawbar int d int value Get difference from current and previous value int diff abs value prev_val d Exit this function if the new value is not within the deadband if diff DEADBAND return Store new...

Страница 15: ...e the selected PORT points to Leonardo 3 Click the icon with the arrow pointing right this will compile the sketch and upload it to the board PLEASE NOTE once the sketch is properly uploaded to the bo...

Страница 16: ...CC bank into the internal EEPROM The loop function cycles through the 9 ADCs by reading their current values and storing them into an array the same function also listens whether the push button has b...

Страница 17: ...URL https www midi org articles old updated how to make your own 3 5mm mini stereo trs to midi 5 pin din cables The D9U uses TYPE B Use a 5V cellphone USB Charger PSU to power the D9U and use your ada...

Отзывы: