Saturday 12 March 2011

MIDI Organ Drawbars

Here's a pretty story about PIC interfacing. OK - so the context is music technology - but I think Hams and "Knack Victims" will find something of interest. Read on...

Regular readers will remember I was given a Digital Effects Processor as a Christmas present. I was amused to hear that one of my fellow members of WARC uses these processors in his shack! I think he uses something called a "microphone" as an input to his radios - 'nuff sed. Of course, I'm pretty fussy about audio quality, too - having gone to elaborate lengths to generate a nice sound!

The Processor has some old-school 5-pin DIN sockets on the back (reminiscent of those on my beloved old Quad 33 pre-amp), supporting something called MIDI; the "Musical Instrument Digital Interface".


Well, I've managed to get through half a century without MIDI (despite a lifelong interest and activity in music and electronics). However, prompted by those sockets on the back of my Christmas present, I decided it was high time I learned something about it.

A sniff around the web showed me it is easy to generate MIDI signals using a PIC. I cut my teeth with a program for the PIC 16F873, generating control signals for the Behringer processor - all pretty easy stuff.

MIDI's physical layer involves the 5-pin DIN connectors mentioned previously - so I added to my stable of PlugIn modules with a MIDI connector...


The socket was part of the bargain haul from g4vap's stand at the Red Rose Rally a few months back.

Having seen how easy MIDI is to generate, I started to think about a project that has been fermenting in the back of my mind for several years - an organ. Not the "Hauptwerk" PC-based emulations of pipe organs (though, no doubt, I'll end up running that too). Rather, a virtual "tonewheel" organ, emulating a Hammond - such as that played by several of my "heros"...


PC software emulating a Hammond was led by Native Instruments' "B4" software, a demo of which I downloaded a few years back. The "B4" software was impressive, but limited by the price tag for the code itself (far too rich for a cheapskate like me) and by the requirement for an expensive hardware interface for the player, including...
  • Keyboard(s)
  • Pedals
  • Controls
MIDI keyboards are cheap, but both pedals and controllers (especially organ-specific controllers) are VERY expensive. However, now I had cracked MIDI, I could consider homebrew controls and pedals...

The key to the control interface for a Hammond organ is the array of "Drawbars" (some of which are seen in the image above, sandwiched between Joey and Thijs).

For the non-musos, drawbars are gain controls for individual harmonic components of the sound produced by the organ. The Hammond Organ (at least, any one of the bigger models) provides 9 drawbars for each of the two manuals and a further 5 drawbars for the pedal department. That's 23 potentiometers - easy enough to handle in the original analog "mixing" context but a non-trivial interfacing problem in a digital emulation.

The PIC16F873, as used in the controller for my multi-mode beacon, has 5 channels of 10-bit Analog to Digital Conversion on-chip - but interface to 23 pots was going to need some kind of multiplexing scheme...

Obviously, trying to switch 23 individual analog voltages to one (or more) analog inputs would be a chore - so I decided that it would be simpler to switch the voltage applied to the "top" of each of the potentiometers sequentially, such that only one pot is "energized" at any instant. Diodes would block the inactive potentiometers, allowing a SINGLE ADC channel to read the selected drawbar. I could scan along all the controls and send a MIDI signal whenever a control setting is changed.

Here's a schematic of the idea, for the 9 drawbars of the upper manual ...

A four-bit "address bus" gives access to 15 individual controls (the last of the 16 states is used to generate an "off" condition) - enough for the upper manual drawbars plus some extra analog controls (swell pedal, etc) OR for the drawbars for the lower manual and the pedals. The "address bus" will be shared by these two units - selection between them is arranged by individual (active low) "latch enables".

Here's the code for reading the setting of a single Drawbar...

MIDI control values are 7-bit numbers (0:127) and I ignore changes in the bottom two bits when checking if a drawbar setting has changed.

The subroutine calls in the code segment above are all pretty trivial; "Latch_Upper" simply puts an (active low) pulse to the 74HC137s in the Upper Manual Drawbar unit, "Delay" "does what it says on the tin", "sendmidi" is Ross Bencina's routine and "ad_conv" drives the A->D conversion on the PIC's RA0 pin...

I've breadboarded the system with the only two slider potentiometers I had in the "junk box"...


It operates though a dirt-cheap MIDI - USB adapter, available for peanuts from many sellers on eBay...


(OK: the MIDI -> USB interface is difficult to get running until you find the right links on the 'net and pluck up the courage to make the necessary Registry Changes - but the price is right!).

The prototype works perfectly with the excellent Organized Trio VST plug-in (which is a free-ware version of VB3)...


All that remains is to buy 23 sliders - another "trip" to eBay is indicated!

...-.- de m0xpd


Update

I happened to swing by Maplins yesterday and couldn't resist buying up all their stock of sliders - which now adds up to the spectacular total of five! Here they are in a test lash-up with a couple of keyboards [they are mapped to the lowest five Upper (swell) manual drawbars]...


Even this level of controllability makes the organ emulator infinitely more usable and musical - great fun!

1 comment:

  1. Hi! Awesome project.
    If you dont mind, can I have a source code? or Any links where's to downloaded it?
    Cheers

    ReplyDelete