This is my make-through for the diploma's individual project trial.
Grab a cup of rice puding!
Understanding midi
MIDI stands for Musical Instrument Digital Interface. It consists of a set of digital signals that are used for controlling and playing electronic musical instruments. It's important to realise that MIDI doesn't contain any actual sound itself, it's simply instructions for how other instruments should create sound.
A MIDI message is made up of an eight-bit status byte which is generally followed by one or two data bytes. There are a number of different types of MIDI messages. At the highest level, MIDI messages are classified as being either Channel Messages or System Messages. Channel messages are those which apply to a specific Channel, and the Channel number is included in the status byte for these messages. System messages are not Channel specific, and no Channel number is indicated in their status bytes.
In this project I'm aiming to make a small portable midi controller with the following features
Minimum Features:
USB for power/USB communication/Mechanical control
Complete features:
Battery Powered/Bluetooth communication/Semi-full Touch control
Nice to Have:
All components and controls mounted on PCB to enhance assembly process(No wires)/Both Bluetooth and USB communication options/Full touch control
To achieve my first minimum feature, (USB controlled device) I had to use a micro controller that supports hardware usb communication, which are two ,(ATMEGA32U4) which is used on arduino leonardo, micro and pro micro or ATMEGA16U2 wich used as a UART to serial converter on original arduino UNOs.
I looked at it at litterally every electronics store In egypt but nobody evens know it!, I knew then that it's rarely used in projects, and clearley isn't used by egyptian makers at all.
Then My friend Mohamed el Sayed told me about a tiny development board available at FLE inevntory called Arduino Pico by MellBell
It's very small, comes in a tiny 0.6" x 0.6" inches package, making it perfect for projects where size and weight matter. But, that's not all, as it has 4 digital and 3 analog I/O pins, and Of course supports native USB in its tiny package, which is why we choosed it
Of course this number of I/O pins was less than what I needed, and here we know how week 5 of this diploma was useful :D.
I used a 16 channel Analog/Digital multiplexer (CD4067), it was also very hard to find, but luckilly I found it at this store, it's website is a little bit sick but it works :D.
For main keys I wanted to use 24mm arcade buttons like these as they have micro switches ( which means a softer, easier press) and they're transluscent. Which means it can pass light so I can use RGB leds with each one to assign different color functions
As usual, we don't always get what we want, The only available arcade buttons in this country were these 35mm and 45mm buttons with a cost of 35 or 45 LE each, and I needed 9 of them which meant a cost of 315-405 only for the switches only, which almost exceeded my desired price for the product
I decided to use these limit switches, as it was the only affordable available microswitch . and to use a flexible printed key pad above it.
These Idea was inspired from a project by GreatScott a popular maker x Youtuber, he used the same mechanism but with normal capped push buttons, which I refused to do for two reasons: I didn't want to replicate+ Push buttons press is too hard for a musical instrument.
In addition to buttons I used 1 slide potentiometer and 4 rotary pots
Schematic design was simple as usual, I used female pin headers for the pico, but I had some missing footprints, which were ( slide potentiometer, limit switch and multiplexer) I'll attatch their libraries below.
To make the PCB buttons alligned with enclosure holes, I took a sketch of the enclosure face and exported it as a dxf and imported it to eagle using the following ULP: import-dxf.ulp
Then I started placing the switches in the middle of the square holes and the same with potentiometers and slider
routing was a little bit harder the before, but it was only a matter of time, I used two bridged for this routing one ground bridge and one VCC bridge new huh?
After all PCBs we've done, PCB fabrication became easier, but I'm still doing some fatal mistakes due to lack of concentration, I milled the traces using the hole drilling bit! and I forgot flippig the image (as I was working on the botom layer.
I repeated the fabrication process next day and it went smoothly,
Soldering process was as smooth as possible, after previous SMD components soldering, through hole soldering became a peace of cake
Control and mechanisms:
I wanted to make a design similiar to that of the novation launch pad, and as mentioned above, I planned to use a flexible keypad with limit switches below it.
I designed a 100x100 square with 1 mm thickness and 9 square inside 20x20 mm each and with 5mm height in order to fit inside the enclosure. and t
First I printed one square with 5% infill to test the felxibility features of the leon flex filament I used.
Enclosure and PCB fitting
I designed a 150x150x30 mm box for the encloure with a white acrylic back.
It was easier for me to draw all features on the same sketch to be easier to edit. and to have accurate symmetrical and ergomical design.
After extruding all bodies, I changed them to components and started assmbly to make sure there's no interference and fittings are going well.
3d Printing
The PCB didn't fit well for a reason that I didn't have time to search for, so I sized it down using a small saw and some sanding paper and the result was acceptable. and the switches were alligned well with the square holes. but it was going to be better if the switches were 180 degrees rotated to make the limit switch lever better alligned.
there were minor scratches on the top caused by the 3d printer bed, but it has nothing to do with functionality
The keypad fitted will in it's required place but it was stiff, if you pushed it lightly it doesn't move, If you pushed it hard, it's removed from the enclosure.
I used an open source code by a Brazilian music technology engineer and maker called Gustavo Silveira, it's a thousand line code but he designed it in a great way to be easily customized to any number of keys and pots with multiplexer or directly to the I/O pins.
The code uses the following libraries:
Multiplexer4067.h to easily use our multiplexer
Thread.h it creates virtual threading that makes the potentiometer response faster
MIDIUSB.h it makes the device recognized as midi device and makes it send midi signal using bottons, pots, etc.
After including libraries, he defines the multiplexer selector and output pins.
Then he starts defining variables for total number of pins, uC pins and mux pins .
then he creates an array with the midi notes assigned to each button to bes assigned to butons selected previuosly
..................................................................................................................................
Then in the part using the virtual thread:
threadPotentiometers.setInterval(15); thread read rate (every 15 milli second)
threadPotentiometers.onRun(potentiometers) called function
.........................................................................................................................
for (int i = 0; i < N_BUTTONS_ARDUINO; i++) {
buttonCState[i] = digitalRead(BUTTON_ARDUINO_PIN[i]);
} In this for loop, the uC reads the number of buttons connnectef directly to the arduino defined above in n_buttons_Arduino and saves it in a variable called buttonCstate
Then the same way is used with pots and mux, and the rest of the code is made of conditions if other uC were used. And the direct funstions that send midi notes through usb communication
What I learned this project is...:
Be ready for doing several iterations when making a complex design (several fittings with several parts and joint types and sesntive parts (microswitch))
When designing a box-like enclosure start designing from the base to the top ( e.g in my design, buttons should have been place on the buttom of the case and the keypad placed over them) so trouble shooting could be easier.