Accordion Mega story

JasonBugeja edited this page Dec 25, 2014 · 33 revisions

I like to play accordion & have a dog. People say dogs are singing with squeezeboxes and some people find it funny. Not for me. I know that my pet hears note harmonics much better then me & suffers from high pitches very much. I could not really practice at home just because of humaneness. That sucks. I like to play accordion. Programmers see cycle here. Let's get out.

THIS IS IT.
It plays to headphones, produces MIDI output, etc. etc. It costs $6,699.00 on e-bay (buy now offer) on November 17, 2010. In the US I can buy Peugeot Partner for the same price. In Ukraine where i live both are 1/2 times more expensive. For that money i'll get beautiful device to practice at home and no service centers available within 400Km radius. Weird.

Another cycle, getting out of it just below.
Let's build MIDI accordion. What do we require:

  1. Old accordion to be reborn
  • scan 41 keys of right hand
  • scan 120 buttons of left hand
  • measure pressure inside box
  • send all of that via MIDI message to much smarter device i'm writing this text on.

Googling a bit, microcontrollers, robots, hurray 2,3,5 are done by MIDI Chromatic Button Accordion (CBA) and costs 75 euro. Nice try, Tom, however for a pre-programmed device, price is too high. Soldering 120 reed switches for the left hand & 41 for the right will give me much soldering experience and quite dumb device. It will produce notes without feel, being closed for further development. No, thanks. But thanks for informative site, really!

Another article of Mike Szczys with impressive youtube video. Instrument developed by Lee. It works, huh? No source code. You will not have a chance even to make a copy of that toy. Thanks anyway, Mike & Lee, you proved we can do it.

So, arduino. As of 2010 this project looks slightly outdated, but, who cares. It has descent hardware (comparing with Sinclair 48K i had long time ago), some IDE, lots of libraries and ready-made projects.

Lets try to solve our requirements one by one.

  1. you have one if read this article up to here. Solved.
  2. keyboard

it have to be

  • fast
  • cheap
  • chorded (allow pressing of any button combination)
  • fit inside an old accordion.

candidates are:

  • matrix keyboard: possible (with diodes)
  • 1-wire keyboard: no, no chording
  • PC keyboard chip: cheap, no chording
  • hall sensors: cheap? no way
  • optointerruptors: yes, read below

Since optointerruptor is a pair of diode and phototransitor we have to light up every diode one by one & get the value from pulled-up input arduino pin. For me it's logical to combine diodes not to octaves (by 12) but to bytes (by 8) to read the result faster. No debouncing required. Looks like a dream, huh?

Schematics

Output transistor may be pulled up to +5v by external resistor, but we know how to turn on internal pull-up resistors in Atmega chip, so, keeping things simple.

As you see in schematics I don't want to scan every button of left hand. Accordion does not, it has patented hardware encoder, it is already producing the feeling of button pressed, already opens up necessary vents, and, there are 24 vents only, not 120. This gives us a chance to scan keys fast enough and reduce number of wires & power requirements.

Some constructing, some sawing, some etching, some soldering. Both hands are equiped with optointerruptors now:

Left hand photo Right hand photo

3.keyboard Solved

4.air pressure.

BMP085 – digital barometric pressure sensor just does it. This page describes everything you need.

4.Solved

5.send MIDI message.

3 bytes MIDI message is easy to send:

 Serial.print(midi_cmd, BYTE);
 Serial.print(notes_number, BYTE);
 Serial.print(midi_vel, BYTE);

but not so easy to recieve. Something has to tell computer these 3 bytes are MIDI and route it to synthesizer or sampler you use. Of course we can turn off debug, leave MIDI the only bytes on serial connection and route that to sampler somehow. I want to keep the debug connection clean and use different port for MIDI data. MIDI tutorial is easy & helpful, but I don't have MIDI-USB dongle and don't want to buy one. At least now. So, i propose to connect something like BTM-112 to spare serial port of arduino to transfer MIDI data and make instrument wireless.
For me it worked out of the box, spent some time to find its AT command set and figure out how to speed it up. 115Kb/sec is more then needed in this case.
Now the most tricky part. We have to tell computer that this exact serial line transmits MIDI data to play. Windows users luckily do have Roland Serial Midi driver which may work. I'm MacOS user and have not found anything suitable to just feed ready-made bytes from serial line to IAC driver of CoreMIDI sybsystem. Serial_MIDI_Converter works, but it is a bad joke to start Java for such an easy task.
Finally i had to write my own 4Kb utility to do that, you will find it here, it is based on rtmidi package and will work in any OS.

5.Solved

After programming arduino with firmware we have 41/120 wireless MIDI accordion.
Roland, you lost one more customer ;)

bill of materials:

  • old accordion free
  • ArduinoMega from e-bay. 30$
  • BMP085 13$
  • optointerruptors BPI-470-T51 65x0.2$ = 13$
  • WH0802A-NGG-CT 3.75$
  • 5x1.2v NI-MH cells 22.50$
  • phone 6pin connectors, wires, usb connectors, etc. ~15$

sum: 97.25$

Looks like we can buy any MacOS computer with Logic and any sample package for the change. Have fun!

Youtube video included

Useful readings

With some mods in code & schematics this project can be made with arduino Nano or Fio. Firmware (at least in 2010) is not larger then 16Kb so any >Atmel168 can be used. Some day i'll make MIDI concertina with it.

PS. send me a link to list here if you found this project useful.

[N9YTY note - One small change to be more compatible with most MIDI accordion implementations. The left side is not really 24 notes, but two sets of 12 notes, each set should be sent on a different MIDI channel. Typically MIDI channel 1 (and sometimes 4 as well) is the right hand, MIDI channel 2 is the 12-note range of the chords and MIDI channel 3 is the 12-note range of the Bass notes. Hopefully this would be fairly easy to fix in the firmware by paying attention to which set of covers were for chords and bass and setting channel appropriately.]

[JasonBugeja note - @N9YTY my version https://github.com/JasonBugeja/AccordionMega_USB_Keyb fixes the issue of separate midi channels for bass notes and chord notes on the Stradella bass buttons. To do this I have transferred the code used for the right hand to the bass side to have different midi channels (channels 2 and 3). The right hand side is then taken care of by the code taken from Yuuichi Akagawa's https://github.com/YuuichiAkagawa/USBH_MIDI/blob/master/examples/USB_MIDI_converter/USB_MIDI_converter.ino since I'm using a ready-made USB keyboard going through USB host shield.