Brain
From Livid Wiki
Contents
|
About the Builder Brain
The Livid Builder Brain is class-compliant and OEM (original equipment manufacturing) device for creating your own MIDI control device. This board can be used for a wide range of applications including audio, video, lighting control, device control, software control, and other miscellaneous operations. The Brain can be used with buttons, analog controls (faders, knobs, sensors, etc..), and can receive MIDI to control LEDs. USB class-compliance means no drivers are needed for any operating system, and it is powered by USB. Standard 5-pin DIN MIDI in and out jacks are also available to control other MIDI devices such as synths, sequencers, and lighting.
As an OEM device, the Brain gives you the ability to create a totally unique control surface and leaves much room for creativity and expandability. The Builder Brain is based on the PIC18F4550 chip from Microchip Technologies. We provide examples for connecting analog and digital controller to the board, as well as schematics to expand the basic functionality of the Brain. Please visit our user forums for support and ideas on ways to use your Brain.
Connecting the Brain
The Brain uses USB for both power and communication. The provided MIDI in- and outputs can also be used, but the Brain must be plugged into a USB host with MIDI software running (even if it's something basic like MIDI Monitor (http://www.snoize.com) or MIDI OX (http://www.midiox.com) running. This is a byproduct of a USB-powered class-compliant devices with no external power source, not an intentional limitation. However, once you have the Brain connected to a computer and some simple MIDI application running, you can send and receive MIDI messages from the MIDI output and input jacks.
- Using a USB cable, connect the Brain board to your computer.
- The device will show up as “Livid Builder Brain” in Mac OSX, and Windows 7, and as “USB Audio Device” in Windows XP. (There are no drivers needed)
- Before the Brain any connections can send MIDI, you will need to configure the inputs and outputs using the Brain Editor software.
Quick Start Guide
If you have no experience with soldering, circuits, or electronics, we have made the Brain Quick Start Guide to cover the basics of using the Brain. If you want an easy-to-follow lesson to get started using the board, you'll want to start here. Advanced users may wish to skip this section, however it may prove to be useful in understanding the Brain.
A video guide of our Quick Start can be found here http://www.youtube.com/watch?v=Yyv1BnH_-vA
There is also a video with a more advanced example, "Livid Builder Tutorial - My First Controller": http://www.youtube.com/watch?v=8sgTDp4509c
Diagrams
Board Diagram
- A. Button Pin Headers (JP1) - Connect buttons, switches, and contacts to the board to enable digital note on/off and CC messages.
- B. LED Pin Headers (JP2) - Illuminate LEDs connected to the board.
- C. External Pin Header (JP3) - Used for power and grounding buttons.
- D. Analog Pin Header (JP8-JP13) - Connect faders, potentiometers, sensors, or other analog controls for continuous control messages, such as CC and Pitch Bend.
- E. Program (JP5) - Used to connect a programmer to alter the firmware on the PIC nicrocontroller.
- F. MIDI IN - 5 Pin Din MIDI Jack.
- G. MIDI OUT - 5 Pin Din MIDI Jack.
- H. USB - Required for USB communication and power.
Pin Header Numbering
There are three different pin header configurations used on the Brain: 10 pin, 14 pin, and 16 pin. Pin headers are numbered as follows. Pin 1 always has an arrow pointing to it. If you are using ribbon cables the red line should always line up with the arrow and will ensure correct connections.
Using MIDI
As described in the first part of this manual, the Brain is designed as a MIDI device to create physical interfaces. We will discuss here how it is used as a MIDI controller and how MIDI is implemented on the board. Since this board is a class-compliant MIDI device, no software drivers are needed.
Configuring The Board
Before you use the Brain board, you must provide the microcontroller with a description of your connections, using the Brain Editor application. In the Editor, you set the number of digital, analog, and LED connections used for your project so the pin headers can be activated and deactivated accordingly. The Editor also provides access to advanced features of the board such as setting the desired MIDI messages, channel, and other useful utilities. It is important that you first configure your board properly, as incorrect configurations may result in unintended MIDI data and noise.
For detailed instructions see Brain Editor.
Connecting to The Board
All connections to the Brain use double-row pin headers and flat ribbon cables with socket connectors. There are three sizes of pin headers on the board; 10, 14, and 16 pin. All analog inputs use a 10 pin header, LEDs and External use a 14 pin header, and buttons use a 16 pin header. It is important that you use cables to connect to the board, rather than directly soldering to the pins. Not only is this difficult and makes reuse nearly impossibly, it could also damage the Brain and will void your warranty.
Using Digital Inputs - The Button Feature
The Brain supports up to 179 button switches (normally open, momentary contacts). Up to 16 switches can be wired directly to the Button header JP1, and grounded on the other side to the external header JP3 pin 1. A simple matrix of buttons and diodes can be used for up to 64 buttons. For the maximum button connections, decoder chips in a matrix with up to 179 buttons can be used.
Direct Wiring Examples
Support: 0 to 16 button switches, normally open, momentary contact (NO-MC)
There are two methods of doing this.
Method1
This method requires no additional circuitry.
Wiring
Wire one side of each Button to the External Header's Ground (JP3: Pin1).
Wire the other side of one Button to one of the Brain's Button Matrix Pins (only one button per Button Matrix Pin).
The "Pull-Ups" for these pins need to be enabled for this Configuration in the Brain Configuration Program.
Function
Buttons wired in this fashion will operate as follows:
"OFF": Midi Note of Velocity 64
"ON ": Midi Note of Velocity 0
Method2
The second method requires that "pull-down" resistors be added to each Button Matrix pin.
Wiring
Wire one side of each Button to the External Header's Vdd Pin (JP3: Pin13).
Wire the other side of one Button to one of the Brain's Button Matrix Pins (only one button per Button Matrix Pin).
Wire one side of a resistor (30k - 39k) to the Button Matrix Pin you used.
Wire the other side of the resistor to the External Header's Ground (JP3 Pin1).
This is called a pull-down resistor not because it is any special kind of resistor, but because it pulls an input down to ground to allow current to escape when a switch is turned off.
One pull-down resistor needs to be wired in the same fashion to connect each used Button Matrix Pin to Ground.
Function
Buttons wired in this fashion will operate as follows:
"OFF": Midi Note of Velocity 0
"ON ": Midi Note of Velocity 64
Direct Wiring Suggestions
For maximum stability using Direct Connect Button Mode, every Button Matrix Pin that does not have Pull-Ups enabled in the Brain Configure program should have a pull-down resistor.
[Image example]
Matrix Mode Examples
Diode Matrix
Support: 0 to 64 button switches (NO-MC) in a simple diode matrix
To connect more than 16 buttons, use a simple matrix is possible by adding nothing more than diodes and pull-down resistors. With this matrix configuration, the Button header is divided in half, with a maximum of 8 Column pins (JP1: Pins 1-8) and 8 Row pins (JP1: Pins 9-16), resulting in a maximum of 64 buttons.
Wiring
Button Wiring
Connect one side of your button to one Button Matrix "Column" Pin (JP1: Pins 1-8).
Connect the other side of your button to the '+' side of a switching diode (1N4148, for example).
Connect the '-' side of the diode to one Button Matrix Row Pin (JP1: Pins 9-16).
Repeat for all other buttons. No two buttons should be connected to both the same row and same column pins, unless you want them to act as if they are the same button.
Pull-Down Resistors
Because this mode "samples" the buttons, a resistor connecting each row pin to ground is required to quickly drain current off of the Button
Row Pins when the Brain changes which Column it is scanning. A pull-down resistor is just an ordinary resistor connected in the following fashion.
Connect one side of one resistor to one Button Matrix Row Pin (JP1: Pins 9-16)
Connect the other side of the resistor to the External Headers Ground Pin (JP3: Pin 1)
- Repeat this process for all Rows used (one resistor per row.
Diode Matrix Mode Notes
-Any of the first 8 pins on the Button Matrix header can be used for columns, but must be on consecutive-numbered pins.
-For maximum stability in Matrix Mode a pull-down resistor should be connected to each of the 8-Rows (even the ones that aren't used)
-The Brain scans all 8 rows, whether or not they are actually used. The most efficient setups will use all 8 Rows with a minimum number of columns.
-Unused column pins can be used for directly-connected buttons.
-Note number indices are Column-major, meaning that all 8 potential Rows in Column 1 are numbered "0" through "7" and continue with "8" for Column 2, etc. Any unused Row pin results in a missing Note number index. Since Column pins must be consecutive, there are no missing indices in the Column order.
Here is an example of using a 4x4 grid matrix using arcade buttons. This is the same method you would use with any normally open switch.
Button Matrix Example
This is an example of a 29 button matrix, arranged in a 4 column, 8 row format. We have intentionally left column 4 with only 5 buttons to show that an even number of buttons is not necessary. For speed and efficiency, this matrix uses all 8 rows.
All rows are connected to pins 9-16 of the Brain Button Matrix header JP1.
All columns are connected to pins 1-4 of the Brain Button Matrix header JP1. Column pins 5-8 of the Brain Button Matrix header JP1 are not used for this matrix but could be used for more columns of a larger matrix.
One side of all the buttons in a column needs to be continuously connected to that column's pin.
The other side of each button connects to a diode. The opposite end of each diode connects to a continuous row pin.
All diodes should face towards the row pins.
Somewhere on a row should be connected to one leg of a pulldown resistor. We commonly use 33k resistors for pulldown resistors. The other end of each resistor should connect to the ground pin1 of the External header JP3 on the Brain board.
Address Decoder Matrix
Support: 0 to 179 button switches (NO-MC) with an active-low decoder chip
This section is for advanced users only. You will need a good understanding on how address decoder chips work. Using Address decoder chips, the Brain can support 179 Buttons. Only the first 124 will allow MIDI mapping - the last 55 will have hard-coded as MIDI continuous controller messages, and only the first 124 can be mapped. You will have to be careful in your map, since those last 55 codes won't be usable in the lower 124.
Wiring
Button Wiring
Connect your Button Matrix "Address" Pins (Pins selected by Brain Configure Program (JP1: Pins 1-8)) to each "Select" Bit on your Decoder Chip (these are usually labeled A,B,C,D on the datasheet). A 3.3V "high-speed" active-high decoder is preferred for this application.
Connect one output pin from your decoder chip to one side of your button.
Connect the other side of your button to the '+' side of a switching diode (1N4148, for example).
Connect the '-' side of the diode to one Button Matrix Row Pin (JP1: Pins 9-16).
Repeat for all other buttons. No two buttons should be connected to both the same row-pin and same decoder-pin, unless you want them to act as if they are the same button.
Pull-Down Resistors
Because this mode "samples" the buttons, a resistor connecting each row pin to ground is required to quickly drain current off of the Button Row Pins when the Brain changes which Column it is scanning. A pull-down resistor is just an ordinary resistor connected in the following fashion.
Connect one side of one resistor to one Button Matrix Row Pin (JP1: Pins 9-16)
Connect the other side of the resistor to the External Headers Ground Pin (JP3: Pin 1)
- Repeat this process for all Rows used (one resistor per row.
Address Decoder Matrix Mode Notes
-Any of the first 8 pins on the Button Matrix header can be used for addressing, but must be on consecutive-numbered pins.
-For maximum stability in Matrix Mode a pull-down resistor should be connected to each of the 8-Rows (JP1: Pins 9-16) (even the ones that aren't used/enabled)
-The Brain scans all 8 rows, whether or not they are actually used. The most efficient setups will use all 8 Rows with a minimum number of columns.
-Unused Address Pins (JP1: Pins 1-8) can be used for directly-connected buttons.
-Note number indices are Column-major, meaning that all 8 potential Rows in Column 1 are numbered "0" through "7" and continue with "8" for Column 2, etc. Any unused Row pin results in a missing Note number index. Since Column Address pins must be consecutive, there are no missing indices in the Column order.
-Up to 8 address bits and up to 8 rows can be used, however achieving the full, theoretical capacity for 2048 buttons would require all 8 address bits and a 256-output decoder chip (which probably doesn't exist). Instead, multiple cascaded decoders would be needed. There are also the limitations of MIDI at 128 notes and 128 controls for each of the 16 channels, so it is highly unlikely that anyone could actually build a 2048-button design without running into some limitations. However, the general design can certainly be used to break the 64-button limit of the level 1 wiring configurations described above. The provided firmware only supports 179 buttons.
Using Analog Inputs
The Brain supports 64 analog controllers such as a rotary potentiometer, slide potentiometer, or other analog controls. Potentiometer with values between 10k-100k work best with the Brain.
Direct Wire Analog Controls
Support: 0 to 64 potentiometers (rotary knobs or linear faders / sliders)
Each 10-pin analog pin header (JP7-JP14) has Ground (Pin1) and Power (Pin2),
and 8 more pins for individual inputs (Pins 3-10)
Each pot should have its outer pins connected to Ground and Power, with the wiper pin connected to one individual input pin (Pins 3-10). Ground and Power should be maintained separately for each header, and certainly should not be connected to the digital supplies on the External header.
Details: The Brain can be configured to start scanning with any of the 64 inputs, but all inputs that are active must be consecutive. It will be allowed to wrap around from the highest-numbered input to the lowest and still be considered consecutive.
The Brain can be configured to start scanning with Analog input number 48, continue to 64, wrap around to 1, and end on number 9.
If you need non-consecutive inputs in a range, then the missing inputs must be grounded.
In fact, each group of 16 inputs which has at least one active input should have all remaining inputs grounded unless they are actively used as well. This latter requirement pairs 10-pin headers into 16-input groups which must be grounded for optimal performance. The above describes the minimum amount of grounded pins, but if in doubt, simply ground all unused inputs.
A low-pass filter will improve the response, so a bypass capacitor will provide something like a first-order RC network with the potentiometer.
The scan rate of the firmware is 6.4 kHz, but that is shared among all active channels. Therefore you must keep in mind that when you configure for fewer than 64 channels the scan rate effectively goes up. The slowest scan rate would be 100 Hz for 64 channels and the fastest would be 6,400 Hz for 1 channel. Depending upon the resistance that you use for the potentiometers, and the number of active channels, you would want a difference capacitance to set a reasonable RC time constant.
0.1 µF and .01 µF are common, but look at the standard RC time constant formula for hints about what to use in your circuit. Larger potentiometer resistance requires smaller capacitance, and higher scan rates (for fewer channels) also requires smaller capacitance.
Potentiometer Example
Here is a single slide potentiometer wired to JP7 using a 10 pin ribbon cable. The first pin (red wire) is ground out and the second is voltage. If you had more then one potentiometer connected to this header (it can take up to 8) you would use the same voltage and ground pins for all 8 potentiometers.
Using LED’s
The Brain can support 14 direct wire LEDs and 48 LEDs in a matrix. We suggest using a red, orange, or yellow LEDs for optimal brightness. LEDs can be used for backlighting, indicators, to show status, or create animations.
The Brain receives MIDI messages (and sysex) that will signal the Brain to turn the LEDs on and off. All LEDs must be used in conjunction with a resistor. The resistor value will depend on the color and spec of the LED. To find the value resistor needed you can use this resistor calculator http://led.linear1.org/1led.wiz.
It is worth noting that the BYOB circuit boards support both thru hold and surface mount LEDs.
Note: The supplied green LED that comes with the Brain requires a 47ohm resistor. Using the above calculator you can see how we calculated this. Since we use 3.3 volts for the LEDs, and the green LED included forward voltage is 2.2v (common green) and 25mA, it tells us that we need a 47ohm resistor. When using through-hole resistors, you will need to locate the positive (anode) and negative (cathode) connections coming from the LED. The long leg of the LED is positive and should be connected to the External Header's JP3 with a resistor in between the LED and the pin (if using Direct Connect Mode. The short leg is the negative and should be connected to the LED Matrix header JP2.
Direct Wire LEDs
Support: 0 to 14 two-wire single-color LEDs. 12 of these can probably be any color, so long as the LED voltage is less than 5.0V, but there are two pins which only support 3.3V or less for the LED voltage.
For most LED connections, use the 3.3V power pin on the External header (JP3: Pin 13), connected through a resistor to the LED. This resistor is an ordinary resistor, but is generally called a "current limiting" resistor because of its job in the circuit. The other pin of the LED should connect to one pin of the LED Matrix header (JP2) so that current can flow from power through the resistor and LED to the JP2 header. If any LED needs more than 3.3V, then use the 5.0V power pin instead (JP3: Pin 14), but remember that two pins (JP2: Pins 9 & 10 ) cannot handle this.
Wiring LEDs
Connect the anode (+) side of the LED to a current limiting resistor (To find the value resistor needed you can use this resistor calculator http://led.linear1.org/1led.wiz )
Connect the other side of the resistor to the External Header (JP3: Pin13 for 3.3V LEDs or Pin 14 for 5.0V LEDs)
Connect the cathode (-) side of the LED to the controlling pin on the LED Matrix header (JP2)
- Repeat for up to 13 more LEDs (one per pin on JP2)
LED Matrix
Support: 0 to 48 two-wire LEDs. All LEDs must have an LED voltage under 3.3V maximum for this mode, which probably rules out blue and some of the more exotic LED colors.
Wiring LEDs
Connect the anode (+) side of the LED to one side of a current limiting resistor (To find the value resistor needed you can use this resistor calculator http://led.linear1.org/1led.wiz )
Connect the other side of the resistor to the desired LED Column Pin (JP2: Pins 9-14)
Connect the cathode (-) side of the LED Row Pin (JP2: Pins 1-8)
- Repeat for up to 47 more LEDs (one per pin on JP2). Make sure that no two LED's are connected to both the same row and column Pins or else they will light together at less brightness.
Matrixed Mode Notes
The External header is not needed in this configuration, all power is provided by the column pins on the LED Matrix header.
Each LED is limited to 25 mA maximum, and the total for all cannot exceed 200 mA.
For a full 6-column, 8-row matrix, each LED should not run with more than 22 mA. Select appropriate resistors to meet these restrictions.
LED Matrix Example
This is an example of a 17 LED matrix arranged in 7 row 3 column format. It has intentionally been setup with an uneven amount of LEDs to demonstrate that you do not need full rows and columns. It is advisable to have full 7 rows for speed and efficiency. All rows should be connected to pins 8-14 of the Brain LED Matrix JP2 pin header.
All of the LEDs in a column should have one side connected to a continuous column. Each column is connected to pin 1-3 of the Brain External header JP3. The circuit should be designed with a resistor at the beginning of each column to control voltage for the matrix.
Enhanced Color and Brightness
Support: Same as the level above, but with additional external circuitry to boost current and/or voltage.
-Zener diodes can be used to protect pins 9 and 10 from exceeding 3.3V, such as needed for exotic LED colors.
- Using the LED Matrix to Control Transistors, it is also possible to increase brightness! You just need one transistor per row, and one transistor per column. Here's how to wire it up.
P-channel Mosfets (Columns) -Gate Pin: LED Column Pin (one of LED Matrix Header Pins[9-14]) -Source Pin: +3.3V from External Header (JP3: Pin 13) -Drain Pin: Anode of every LED in the Column (maximum 8 (one for each row)
Then connect the cathode of the LED to your current limiting resistor.
N-channel Mosfets (Rows) -Gate Pin: LED Row (one of LED Matrix Header Pins[1-8]) -Source Pin: To the other unconnected sides of the current limiting resistors of all the LEDs in the Row. -Drain Pin: To Ground
External Header
The external header has various function for all of the controls. Pins 1, 13, 14, and 2 carry 0V, 3.3V, 5V, and unregulated voltage, respectively. The 5V supply is automatically disabled until the USB host enables it, and is also disabled when the USB device is suspended or sleeping.
JP3 External Pins
pin / port
- VSS (0V ground)
- Vin (unregulated input voltage)
- RA5
- RA2/S1 (reserved)
- RA3/S2 (reserved)
- RF2/INH (reserved)
- RF5/S4 (reserved)
- RF6/S5 (reserved)
- RG3/!SHDN (output)
- RG2 (reserved)
- RG1(reserved)
- RG0 (reserved)
- VDD (3.3V power)
- VCC (5V power)
One pin which might need a little explanation is pin 9, which carries "!SHDN." This is a 3.3V logic signal that is 0V until the USB host enables the USB device. Thus, any circuit based on the unregulated voltage or the 3.3V power line should possibly be disabled when !SHDN goes below 3.3V. If your total current usage is below 100 mA, including the Brain itself, then you can safely ignore this enable signal. But if your circuit needs more than 100 mA then it should either use the 5V power (which has limitations on interfacing with the PIC) or be disabled by !SHDN. The pins marked as "reserved" above are for future expansion and have no function on the Brain.
Warranty
Damage
Your hardware should be inspected immediately upon receiving it. If there are any damages they should be reported immediately. All of our hardware is fully tested just prior to leaving our shop.
Return Policy
All sales of Livid Instruments Hardware are given a fifteen (15) day return policy. A circuit board may be returned within fifteen (15) days of purchase. We will refund the purchase price of the product, less shipping, immediately upon receipt of the returned item in as good of shape as it was shipped in. Any damage will be the responsibility of the customer. We will do our best to determine if damage happened during shipping and will help the customer by allowing carrier inspection of any damaged items. Software cannot be returned. Any open software packaging is not returnable or available for any refund.
Warranty
Livid Instruments warrants that this product is free of defects in materials and workmanship under normal conditions for one year, so long as the product is: owned by the original purchaser; the original purchaser has proof of purchase from Livid Instruments or an authorized dealer. Warranty does not include repairs needed due to misuse or abuse. In the event that Livid Instruments receives written notice of defects in materials or workmanship from such an original purchaser, Livid Instruments will either replace the product, repair the product, or refund the purchase price at its option. In the event any repair is required, shipment to and from Livid Instruments and a nominal handling charge shall be born by the purchaser. In the event that repair is required, a Return Authorization (RMA) number must be obtained from Livid Instruments. After the RMA number is obtained, the unit should be shipped back to Livid Instruments in a protective package with a description of the problem and the Return Authorization (RMA) clearly written on the package. In the event that Livid Instruments determines that the product requires repair because of user misuse or regular wear, it will assess a fair repair or replacement fee. The customer will have the option to pay this fee and have the unit repaired and returned, or not pay this fee and have the unit returned un-repaired.
THE REMEDY FOR BREACH OF THIS LIMITED WARRANTY SHALL NOT INCLUDE ANY OTHER DAMAGES. LIVID INSTRUMENTS WILL NOT BE LIABLE FOR CONSEQUENTIAL, SPECIAL, INDIRECT, OR SIMILAR DAMAGES OR CLAIMS INCLUDING LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGE, EVEN IF ITS AGENTS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, AND IN NO EVENT WILL LIVID INSTRUMENTS' LIABILITY FOR ANY DAMAGES TO THE PURCHASER OR ANY OTHER PERSON EXCEED THE PRICE PAID FOR THE PRODUCT, REGARDLESS OF ANY FORM OF THE CLAIM. LIVID INSTRUMENTS SPECIFICALLY DISCLAIMS ALL OTHER WARRANTIES, EXPRESSED OR IMPLIED. SPECIFICALLY, LIVID INSTRUMENTS MAKES NO WARRANTY THAT THE PRODUCT IS FIT FOR ANY PARTICULAR PURPOSE.
This warranty shall be construed, interpreted, and governed by the laws of the state of New Jersey. If any provision of this warranty is found void, invalid or unenforceable, it will not affect the validity of the balance of the warranty, which shall remain valid and enforceable according to its terms. In the event any remedy hereunder is determined to have failed of its essential purpose, all limitations of liability and exclusion of damages set forth herein shall remain in full force and effect.
Appendix
Documentation for PIC Programmers
Sysex
SYSTEM EXCLUSIVE COMMAND BYTES
The System Exclusive message includes the official MIDI Manufacturer ID for Livid, a Product number, and the Command number. A "wild card" Product number allows the same commands to be shared across multiple Livid products. These messages can be almost any number of bytes from 7 to (255) bytes. Note: In this specification, all numbers are hexadecimal unless parenthesized or otherwise noted, in which case they are decimal.
F0 00 01 61 01 NN ... F7
The Product number is 01 for the Brain, and the Command numbers, NN, are described below.
The Brain can be configured for a wide range of control surface wirings, and therefore these commands will sometimes refer to circuits that are not attached, or even to a superset of potential hardware that may only be partially connected. Keep in mind the total capabilities when interpreting the commands, not merely the current configuration.
COMMAND SUMMARY
02 : Save User Settings
04 : Set all LED indicators
05 : Recall User Settings
06 : Factory Reset
07 : Request, multiple subtypes:
07.04 : Request all LED indicators
07.06 : Request Control Surface Snapshot
07.08 : Request MIDI Settings (Local Control, etc.)
07.09 : Request Single MIDI Input mapping
07.0A : Request Analog mapping
07.0B : Request Button mapping
07.0C : Request MIDI Basic Channel
07.0D : Request MIDI Output Merge setting
07.10 : Request Hardware Configuration
08 : MIDI Settings Response
09 : Map Single LED Indicator
0A : Map Analog Inputs
0B : Map Buttons
0C : Set MIDI Basic Channel
0D : Set MIDI Output Merge
0E : Erase entire MIDI Input Map
10 : Hardware Configuration
7E : NAK Negative Acknowledge
7F : ACK Positive Acknowledge
COMMAND DETAILS
02 : Save User Settings
F0 00 01 61 01 02 F7
All User Settings which can be remembered will be stored in Flash and automatically restored whenever the Brain is powered up.
The Brain responds with ACK when finished processing this command.
04 : Set all LED indicators
F0 00 01 61 01 04 XX YY LL HH LL HH LL HH LL HH LL HH LL HH F7
All (62) possible LED indicators can be set on or off with this command. There are (14) bytes, or 7 pairs. Values must be 7F or less. The XX YY pair correspond to the 14 Direct-connect LEDs, with pins 1-7 in XX and pins 8-14 in YY, with lower-numbered pins in the lower bits. The first LL HH pair represents column 1, with each subsequent LL HH pair representing the next column. Within each pair, LL represents the first 7 rows, and HH represents the remaining 1 row. There are 8 bits total for rows. A 0 bit turns the LED on, a 1 bit turns it off.
The Brain responds with ACK when finished processing this command.
05 : Recall User Settings
F0 00 01 61 01 05 F7
Recall User Settings from storage, just like what happens on power up.
The Brain responds with ACK if the User Settings are valid, or NAK when no setting have been saved or the memory is unreadable. The NAK request contains an error code for diagnostic use.
06 : Factory Reset
F0 00 01 61 01 06 F7
This will erase the User Settings so that the Brain is factory fresh.
The Brain responds with ACK when finished processing this command.
07 : Request
F0 00 01 61 01 07 RR .. F7
This command allows several types of information to be requested. Each request type, RR, will be detailed below. Some request messages require additional information bytes to specific which particular item is being requested.
The Brain responds with the specified data.
07.04 : Request all LED indicators
F0 00 01 61 01 07 04 F7
Request state of all LED indicators. The Brain will respond with Command 04, and the bits are interpreted identically.
07.06 : Request Control Surface Snapshot
F0 00 01 61 01 07 06 F7
Request values for all Analog inputs. The Brain will re-scan every analog input and report the value with the usual MIDI Channel Message, even if the physical control has not been changed recently.
07.08 : Request MIDI state (Channel Mode, etc)
F0 00 01 61 01 07 08 F7
Request state of settings that are controlled by MIDI messages, such as Omni, Mono/Poly Mode. The Brain will respond with Response Command 08.
07.09 : Request Single MIDI Input mapping
F0 00 01 61 01 07 09 LL HH F7
Request the current mapping of incoming MIDI messages. LL HH is the 8-bit map code defined under Command 09 below. Both values must not exceed 7F. LL holds the lower 7 bits, HH holds the most significant bit. Values of HH greater than 1 are reserved. The Brain will respond with Command 09, which repeats LL and HH followed by the LED code as CR.
07.0A : Request Analog mapping
F0 00 01 61 01 07 0A F7
Request MIDI map for all Analog inputs. The Brain will respond with Command 0A, and the bits are arranged identically.
07.0B : Request Button mapping
F0 00 01 61 01 07 0B F7
Request MIDI map for all Buttons. The Brain will respond with Command 0B, and the bits are formatted identically.
07.0C : Request MIDI Basic Channel
F0 00 01 61 01 07 0C F7
Request MIDI Basic Channel. The Brain will respond with Command 0C.
07.0D : Request MIDI Output Merge setting
F0 00 01 61 01 07 0D F7
Request MIDI Output Merge setting. The Brain will respond with Command 0D.
07.10 : Request Hardware Configuration
F0 00 01 61 01 07 10 F7
Request the Hardware Configuration. The Brain will respond with Command 10.
08 : MIDI Settings Response
F0 00 01 61 01 08 XX F7
Individual MIDI settings, such as the Channel Mode flags, are combined into the data of this message, XX. Bit 1 is Omni Mode Off/On. All other bits are Reserved. They may reflect other settings, but they may change in future releases. Note that this is a response command only, and it will be ignored if received by the Brain. Use the official MIDI messages to change these settings.
09 : Map Single LED Indicator
F0 00 01 61 01 09 LL HH XX F7
This command updates the MIDI Input map for a single entry. If HH is 00, then LL specifies the Note number. If HH is 01, then LL specifies the Control number, but only valid control numbers are accepted from 00 to 78. Values of HH above 1 are reserved. XX is the LED indicator code, or 7F to clear the mapping for the specified entry.
LED indicator Codes:
00-0D Direct-wired, pins 1 through 14
0E-0F Reserved
10-3F Matrix-wired, Row in 3 LSBs, Column in next 3 higher bits
The Brain responds with a Single MIDI Input mapping for the specified message.
0A : Map Analog Inputs
F0 00 01 61 01 0A (64)*[LL HH] F7
This command updates the MIDI map for all (64) Analog inputs. If HH is 00, then LL specifies the 7-bit Control number, but only valid control numbers 00 to 78 are accepted. If HH is 01, then LL selects between 14-bit Control numbers and Pitch Bend. In the latter case, LL between 60 and 6F specifies a Pitch Bend message on Channel (1) through (16), respectively. Otherwise, LL selects a 14-bit Control number, of which the only valid control numbers are 00 to 1F. All other values for LL, 20 through 5F and 70 through 7F are reserved for future use. Values of HH above 1 are similarly reserved.
There are (64) sets of LL HH value pairs in this message, each corresponding to the index of an Analog input.
The Brain responds with ACK when finished processing this command.
0B : Map Buttons
F0 00 01 61 01 0B (124)*[LL HH] F7
This command updates the MIDI map for the first (124) Buttons. If HH is 00, then LL specifies the Note number. If HH is 01, then LL specifies the Control number, but only valid control numbers are accepted from 00 to 78. Larger values of LL and HH are reserved, with 7A (start), 7B (continue), and 7C (stop) used for MMC.
There are (124) sets of LL HH value pairs in this message, each corresponding to the index of a Button. Subsequent Buttons beyond index 124 are always unmapped.
Button code indices:
00-07 Direct-wired, pins 9 through 16
08-0F Direct-wired, pins 1 through 8
10-4F Matrix-wired, Row in 3 LSBs, Column in next 3 higher bits
10-AF Address-decoded, Row in 3 LSBs, column Address in 5 MSBs
Note the overlap in codes for the two kinds of matrices.
The Brain responds with ACK when finished processing this command.
0C : Set MIDI Basic Channel
F0 00 01 61 01 0C NN F7
This command sets the MIDI Basic Channel to NN, where 00 through 0F are valid and the rest are reserved. During operation, incoming Channel messages are ignored if Omni Mode is Off and the Channel does not match. If Omni Mode in On, then the incoming Channel is not checked, and all messages are interpreted. For outgoing MIDI messages, the Basic Channel is always used unless an Analog input is mapped to Pitch Bend, in which case the Channel number is specified by the mapping entry.
The Brain responds with ACK when finished processing this command.
0D : Set MIDI Output Merge
F0 00 01 61 01 0D NN F7
This command allows the Control Surface to merge its messages onto the MIDI output jack, in addition to USB. NN can be 00 (off) or 01 (on). Other values are reserved.
The Brain responds with ACK when finished processing this command.
0E : Erase entire MIDI Input Map
F0 00 01 61 01 0E F7
This command erases all MIDI Input message mappings. These affect the remote control of LED indicators, so no remote control will be available immediately after the map is erased. Because there are as many as (249) possible MIDI Input messages that can be mapped to an LED, and because multiple assignments to the same LED can cause conflicts, it is best to start the LED indicator mapping process by first erasing all entries before filling in the desired mappings, no more than (48), preferably.
The Brain responds with ACK when finished processing this command.
10 : Configure Hardware
F0 00 01 61 01 10 GG HH PP QQ RR SS TT UU VV WW XX YY JJ KK LL MM NN F7
This commands configures the Brain firmware for a particular hardware wiring. All values must not exceed 7F. GG and HH configure the Analog inputs, JJ KK LL MM NN configure the LED indicators, and PP QQ RR SS TT UU VV WW XX YY configure the Buttons. The exact wiring options are documented elsewhere.
Analog controls:
GG number of contiguous inputs in use
HH index of first input to scan
Direct-connect Buttons:
PP enable bits for pins 9 through (15)
QQ enable bit for pin (16) plus enable for pullups on pins 9 through (16)
RR enable bits for pins 1 through 7
SS enable bit for pin 8 plus enable for pullups on pins 1 through 8
Matrix-connected Buttons (simple Columns and Row):
TT Column code for pins 1 through 8
T- upper 3 bits: starting Column bit [0 means pin 1, 6 means pin 7]
-T lower 4 bits: number of Column bits [minimum of 2, 0 means off]
UU Row enable bits for pins 9 through (15)
VV Row enable bit for pin (16)
Addressed-matrix Buttons (requires external decoder chip):
WW Address code for pins 1 through 8
W- upper 3 bits: starting bit [0 means pin 1, 6 means pin 7]
-W lower 4 bits: number of Address bits [0 means off]
XX Bit enables for pins 9 through (15)
YY Bit enable for pin (16)
Direct-connect LED indicators:
JJ enable bits for pins 1 through 7
KK enable bits for pins 8 through (14)
LL Column code for pins 9 through (14)
L- upper 3 bits: starting Column bit [0 means pin 9, 5 means pin (14)]
-L lower 4 bits: number of Column bits [0 means off]
MM Row enable bits for pins 1 through 7
NN Row enable bit for pin 8
The Brain responds with ACK if the configuration is value, or with NAK and an error code specifying why the settings were rejected.
7E : NAK Negative Acknowledge
F0 00 01 61 01 7E XX F7
This is intended as a way for the Brain to indicate a problem with the previous message. Unfortunately, when messages are sent too fast, it becomes impossible for the Brain to reply with anything reliably, even NAK. The best approach is to wait for ACK (see below) after sending each message, rather than depend on NAK to indicate an error. The exceptions are Recall User Settings and Configure Hardware, where the Brain will reply with NAK if there is a problem. An error code, XX, is sent to indicate the problem.
7F : ACK Positive Acknowledge
F0 00 01 61 01 7F F7
ACK means the previous message was handled correctly. Some messages (e.g. Map Single LED Indicator) simply reply with a specific command, instead of ACK, when more context is needed than a simple acknowledgment.
MAPPING SUMMARY
Analog to CC; 121 control numbers; 7-bit value
Analog to CC; 32 control numbers; 14-bit value
Analog to Pitch Bend; 16 channels; 14-bit value
Button to Note; 128 note numbers; 1-bit value
Button to CC; 121 control numbers; 1-bit value
Button to MMC; 3 types; no value
LED from Note; 128 note numbers; 1-bit value
LED from CC; 121 control numbers; 1-bit value
MIDI IMPLEMENTATION
The following standard MIDI messages are implemented.
System Real Time:
MIDI System Reset
Channel Mode Messages:
Reset All Controllers
Poly On / Mono On (both set Omni Off)
Omni On/Off
All Notes Off (turns off all LED indicators)
Headers
JP1 Button Matrix
pin port
1 RE0
2 RE1
3 RE2
4 RE3
5 RE4
6 RE5
7 RE6
8 RE7
9 RD0
10 RD1
11 RD2
12 RD3
13 RD4
14 RD5
15 RD6
16 RD7
JP2 LED Matrix
pin port
1 RB0
2 RB1
3 RB2
4 RB3
5 RB4
6 RB5
7 RB6/PGC
8 RB7/PGD
9 RC0
10 RC1
11 RC2
12 RC3
13 RC4
14 RC5
JP3 External
pin port
1 VSS (0V ground)
2 Vin (unregulated input voltage)
3 RA5
4 RA2/S1 (reserved)
5 RA3/S2 (reserved)
6 RF2/INH (reserved)
7 RF5/S4 (reserved)
8 RF6/S5 (reserved)
9 RG3/!SHDN (output)
10 RG2
11 RG1
12 RG0
13 VDD (3.3V power)
14 VCC (5V power)
JP4 USB
pin function
1 (unsupported)
2 common output
3 USB V+
JP5 Program
pin ICSP
1 !MCLR
2 VDD
3 GND
4 PGD
5 PGC
6 n/c
JP6 MIDI
pin name
1 GND (MIDI out pin 2)
2 O+ (MIDI out pin 4)
3 O- (MIDI out pin 5)
4 I+ (MIDI in pin 4)
5 I- (MIDI in pin 5)
JP7 AD1-8
pin signal
1 GND
2 VDD
3 AD1
4 AD2
5 AD3
6 AD4
7 AD5
8 AD6
9 AD7
10 AD8
JP8 AD9-16
pin signal
1 GND
2 VDD
3 AD9
4 AD10
5 AD11
6 AD12
7 AD13
8 AD14
9 AD15
10 AD16
JP9 AD17-24
pin signal
1 GND
2 VDD
3 AD17
4 AD18
5 AD19
6 AD20
7 AD21
8 AD22
9 AD23
10 AD24
JP10 AD25-32
pin signal
1 GND
2 VDD
3 AD25
4 AD26
5 AD27
6 AD28
7 AD29
8 AD30
9 AD31
10 AD32
JP11 AD33-40
pin signal
1 GND
2 VDD
3 AD33
4 AD34
5 AD35
6 AD36
7 AD37
8 AD38
9 AD39
10 AD40
JP12 AD41-48
pin signal
1 GND
2 VDD
3 AD41
4 AD42
5 AD43
6 AD44
7 AD45
8 AD46
9 AD47
10 AD48
JP13 AD49-56
pin signal
1 GND
2 VDD
3 AD49
4 AD50
5 AD51
6 AD52
7 AD53
8 AD54
9 AD55
10 AD56
JP14 AD57-64
pin signal
1 GND
2 VDD
3 AD57
4 AD58
5 AD59
6 AD60
7 AD61
8 AD62
9 AD63
10 AD64
Circuit
Please refer to the Microchip PIC18F87J50 Family Data Sheet for all firmware development. Pay particular attention to the Electrical Characteristics (Chapter 28), because there is no protection on the board. Any warranty will be voided if the parameters documented by Microchip for their part are violated.
The following text describes the circuits outside the PIC which provide DIY features.
EUSART1 (Chapter 20) as MIDI ports
The PIC has two Enhanced Universal Synchronous Asynchronous Receiver Transmitter modules. EUSART1 is connected to circuits which translate to the standard MIDI connection. In order to operate the MIDI port features of the DIY, reference the MIDI specifications for baud rate and data word length, then reference the PIC specifications to effect those settings. The MIDI circuit will handle the electrical translations.
Note that EUSART2 is available on the External header. For a second set of MIDI I/O ports, or any other serial interface, the electrical conditioning can be handled by external circuitry and custom firmware.
10-bit A/D Module (Chapter 21) with 64 external inputs.
AN0 is connected to an analog multiplexer circuit that funnels one input at a time from the 64 Analog inputs (AD1-AD64). There are four 16-channel multiplexer chips, and their 4-bit address bus is controlled by RA1-RA4. There is a 2-to-4 decoder controlled by RF5-RF6 that selects one of the four multiplexers. RF2 is the Enable for the decoder, and the decoder outputs drive the individual INHIBIT signal of each mux.
In order to control this subcircuit, RA1-4, RF5-6 and RF2 must be programmed as outputs in TRISA and TRISF. The process starts by setting INHIBIT true on RF2. Then select 1 of 64 analog inputs by setting the 6-bit address into RF6-5 and RA4-1. An easy way to do this is to shift the address left by 1 bit, then mask 4 lower bits into LATA and 2 upper bits into LATF. Set INHIBIT false before engaging the PIC A/D Module.
Finally, note that many of the PIC18F66J50 I/O pins have multiple functions. For each of the pins that are available on a header, these alternate functions can be enabled in custom firmware, provided that compatible circuits are attached.
Resources
http://forums.lividinstruments.com - This is our online forums and the best place to get answers from us, other users, and the community.
http://www.sparkfun.com/commerce/categories.php - A great place for parts, boards, and hard to find components for creating physical devices.
http://www.mouser.com/ - A comprehensive source for almost all electronic components. Potentiometers, buttons, project boards, enclosures, LED’s and much more. The website search is ok, but usually pulls up too many parts to look at. Do yourself a favor and order a catalog. It is the size of a major city phone book and has product from virtually every major electronics manufacturer.
http://www.digikey.com/ - Much of the same as Mouser with a few hard to find parts. Their free catalog is almost as large as the Mouser catalog.
http://www.alpha-products.com/ - A good source for potentiometers and buttons. They are more for bulk quantities.
http://www.harmony-central.com/MIDI/ - Several good links to getting started in MIDI projects.
http://createdigitalmusic.com/ - Online magazine geared towards the do-it-yourself musician. Active forum and regular articles about cool ideas for control surfaces.


