Midipedal for Amp Simulation Programs

by erikgilberg in Circuits > Arduino

1554 Views, 17 Favorites, 0 Comments

Midipedal for Amp Simulation Programs

IMG_20221209_151038.jpg

Introduction:

I am impressed with how good amp simulation has become, so now I use plugins for home practising. When playing directly into plugins, I miss the ability to trigger different channels and effects. This is a feature that is available on most guitar amps. I know there are many daws (Digital audio workstation) and standalone amp simulation programs that support midi commands. So there is an ability to use midi communication through a pedal setup. The idea I have in mind is a setup with switches to control channels, and potentiometers to control analogue values like volume and reverb. This pedal connected via Bluetooth can also be practical when considering all extra cables. I am talking from a guitarist's perspective, but these functionalities could also be handy for other instruments and equipment. When these connections between the pedal and computer are up and running, we can add the necessary switches and pots.

Why make this, couldn’t you just buy it?

The pedal is a summer project I have between my studies in electronic engineering. I wanted to experience more coding and 3dmodeling and needed some new challenges. The best way of learning is by making something you need. Using keyboard commands while playing annoyed me for a while, so I was looking for a midi pedal as a replacement. Midi pedals I have seen on the market are often complex and suited for handling more than just a computer program. Unfortunately, for my goal, these pedals are too expensive. So my best solution is to build my very own midi pedal.

Supplies

What you will need:

I should inform you early that this pedal is Bluetooth communication only. You could connect a midi plug and make it work with a wire connection, but that will need 5v. So I have set aside this functionality for later. I think Bluetooth will do for now.

 

I will not put any links in here because I don't like to recommend a supplier over another. You are free to buy from wherever you want. I have included some descriptions to make it easier to source the right components:

 

Parts:

  • Esp32 T18
  • You can use other esp32 with battery connections. I just preferred this for its 18650 battery holder and built-in charging circuit.
  • Ssh1106
  • If you use another screen, you might need to change things in the code.
  • 18650 cell
  • Recommend good quality batteries, like Panasonic, Samsung, LG and other known manufacturers. 
  • USB port
  • I bought a USB port meant for SMD soldering, but I would use a USB module here instead. Then you get a more accessible and better soldering connection, which feels less flimsy.
  • USB cable
  • Soldered to the USB port and connected to the USB port on esp32.
  • Potentiometers 
  • Be sure to get a linear taper, not an Audio taper. As the analogue scale for midi is linear, there is also essential that the potentiometers deliver a linear analogue input signal. Ensure that the shaft height is correct. Treads need to stick out from the top plate to be attached. So measure how thick you want your top plate to be. Thick enough that It will not flex. For resistance, any value of resistance will work.
  • Capacitors (one for each potentiometer)
  • It doesn't matter what size. Anything from 10nF to 1000 uF. I used 100nF just because I had them lying around.
  • Switches (power and footswitches)
  • For power, you need a simple spdt-type switch or anything you have that functions as a position switch. The footswitches need to be momentary push switches. They can’t be latch-type. Search for "momentary footswitch" with two or more pins.
  • Wire 
  • It doesn't need thick wires as the current is small. Anything will do, but single-core wires are more manageable to solder in place.
  • Treaded inserts
  • They are helpful in the 3dprinted case for better hold on screws.
  • 3mm screws
  • They are used everywhere except the switch cause the holes were too small for them.
  • Plastic standoffs
  • Esp32 has to be mounted. Standoffs are great for this purpose.
  • Futuristic midi port
  • Not connected, but nice to have it available if I want wired midi in/out sometime in the future.

 

Tools:

  • Soldering iron
  • Recommend temperature-controlled soldering iron, but everything will work.
  • Screwdriver kit
  • Allen key/Hex key. Torx is also acceptable.
  • 3d printer
  • You don't need to own one, but you have access to one or know someone that has.
  • Hot air gun
  • For heat shrink tubing. You could also use a candle or a lighter but try not to have the tubes too close.
  • Multimeter
  • To ensure that there are no short circuits. It might also be handy to check if battery voltage monitoring is correct.

 

Extra you might not need:

  • Epoxy
  • For glueing the switch in place and placing the midi port.
  • Silicon
  • For glueing acrylic glass in place. 
  • Plastic lacquer
  • If you need to sandpaper down some parts of the 3dprint and the colour changes.

Soldering

Midi pedal schematic.png
IMG_20220704_232806.jpg
IMG_20220704_232821.jpg

Follow the schematic and make sure there is enough isolation between each pad. Make sure you solder the potentiometers right. You may get a short circuit from Voltagesupply to ground if these wires are connected incorrectly.


Every switch uses built-in pull-up resistance. That means you can solder signal ground into a star connection. Potentiometers connect to 3.3 volt, ground and input pin on esp32. Because of unwanted EMC noise picked up by the analogue input, I soldered a capacitor between the input pin and ground. The screen connects to "SCL" and "SDA" inputs on esp32. These connections were gpio numbers "21" and "22" on this development board, but this can be different for other development boards. Check the datasheet to be sure.

 

Battery voltage monitoring is using gpio pin 35. I can't guarantee that this pin is battery voltage for every development board. If you don't have a defined pin for voltage reading, you can make your own with a voltage divider. When making a voltage divider, ensure the voltage divider's output voltage doesn't exceed 3.3 volts. The charging voltage is probably the highest voltage reading, so you can measure between the battery holder's positive- and negative terminal while the USB is connected. It's probably around 4.3 or 4.4 volts on lithium-ion. Calculate resistor values with this voltage divider calculator.

 

For safety, you should remove the battery when you are soldering the power switch. You need to know the switch's position when the battery is connected so you can solder two wires over to an external switch. On two-way switches, this is typically the middle position pin and the "on" position. Measure with a multimeter to be sure.

Coding

Skjermbilde 2022-12-09 kl. 14.27.07.png
Skjermbilde 2022-12-09 kl. 14.57.27.png
Skjermbilde 2022-12-09 kl. 14.44.44.png

To program this microcontroller, you will need to download Arduino IDE or Vscode with Arduino extension. For anyone new to programming, I suggest you use Arduino IDE because this software is less complex and a little more beginner friendly. 

 


To run this code, you will need these libraries:


Arduino:

-      Spi.h

-      Wire.h

BLEMidi: https://github.com/max22-/ESP32-BLE-MIDI

Debounce: https://github.com/wkoch/Debounce

Adafruit:

-      Adafruit_GFX.h https://github.com/adafruit/Adafruit-GFX-Library

-      Adafruit_SH1106.h https://github.com/wonho-maker/Adafruit_SH1106

  

Download them if you don't have them. With the zip file downloaded, go to Arduino software. Click on "Sketch", "include library", and "add zip library". You may have "spi" and "wire" from before, so check the list if it's there, or use google to find them. You will also need support for esp32 boards. You can find this by clicking "tools", "board", and then "board manager". Search for it, and if it's not there, follow this guide from randomnerdtutorials.com. T18 is an "Esp32 Wrover" board. Depending on what esp32 board type you are using, make sure you select the correct board type before flashing. After you have installed all the libraries and chosen the correct board type, everything should be ready for flashing. You can now flash the ino-file I have published on GitHub.

 


Midi in code:

You can customize device name by uncommenting: "BLEMIDI_CREATE_INSTANCE("EnterdeviceName", MIDI)".

 

Midi-channels are 1, 2 and 3. In my code, I call them "programs" because each program can suit different functionalities. 

 

Footswitches use PC from 1 to 4. In my code, I call them "channels". These commands I use for switching inside plugins.

 

Potentiometers use CC 101 and 102. Potentiometer 1 is CC= 101, and potentiometer 2 is CC=102.


Bluetooth software:

You will need software from Korg inc to get the Midicommands over from Bluetooth to music programs. This software is called "Bluetooth Midi Connect". For mac, you can find it in the mac Appstore. For windows, I think you have to download it from their website. Follow this guide from Korg.

 

Opening the software "Bluetooth Midi Connect" and power connected to esp32, you should see a midi in/out device appear. When the computer has established a connection with the pedal, you should be able to pick up midi commands in your daw or other standalone software. If it doesn't show up in your daw, you will have to google midi-functionality for this daw and be sure you have set up the connections correctly. I can't include guides for all of them. If "Bluetooth Midi Connect" has a connection, and the sh1106 screen says "BT" instead of "BT not connected", the pedal and computer should have a connection.

3d-modelling/laser Cutting

IMG_20220801_113840.jpg
IMG_20220801_113845.jpg
IMG_20220801_185606.jpg
IMG_20220801_160236.jpg
IMG_20220823_190647.jpg

3d-modelling:

The enclosure was the most time-consuming element of this project. I have some experience with Fusion360, so that wasn't the trickiest part, but the amount of planning was time-consuming. Every component needs to be mounted where it is suitable.

I started by testing some angels for the top plate and preferred an angel at around 10 degrees. Sidewalls had to be thick but not wider than the length of the USB port. The screen had to be mounted on the back wall and pushed up under the acrylic glass for a minimum problem with light refraction. USB terminals often fail due to forces pushing a little in all directions, so I built extra support around the connector. I added additional walls around the USB port and a 3mm screw support from behind. The wiring of each component needed holes through the mid-structure, but at the same time, holes had to be as small as possible not to weaken the structure. I prepared all screw holes for threaded inserts and measured spacing between each screw hole.

I shared my 3dmodel files on Github, but I am not sure your components will fit into my measurement. For example, as I said in the supply description, I wouldn't recommend buying an SMD-type USB connector. Also, pots and switches come in different sizes, and the midi port might be slightly different. I might update the 3d model for more common sizes later, but these adjustments take time and will not be perfect.


Laser cutting:

The top plate is made of 5mm thick acrylic glass. The top plate has to be stiff enough and made in one piece. Every button will cause a force on a small area. After prolonged use, I think the 3d printed plastic will have problems with fatigue resistance. A metal plate is also possible, but then I will have to cut out a window for the screen. In my opinion, acrylic glass is a more effortless alternative.

If you choose to go for an acrylic glass, I recommend cutting it with a laser cutter. Every measurement will be precise, and the cut will be clean. As a bonus, the laser will melt corners and make every surface transparent. There is also possible to engrave text in acrylic glass and sign each button. You might not have a laser cutter at home, but you can hire someone to do this for you. Model it in Fusion360, and mail the file to someone with experience. 

I have included the top plate as a dxf-file in the folder "3d print" on Github.


Problem-solving after mounting:

After mounting components, you find every small details you haven't thought of beforehand. For example, power Butten needed smaller screws than my threaded inserts supported. Therefore I made threads in the 3dprint to insert smaller screws. But these threads were not strong enough to support the force of my hand. So instead of fixing the design and printing it over again. The solution was to glue it with epoxy. I can tolerate a few easy-fix solutions, as this is a prototype build. For later improvements, I might look for a switch with 3mm screw holes or threaded inserts with a smaller diameter.

Another thing is the print quality around the midi connector. The layers seem to have expanded on the corners. So I filled out every cleft with epoxy. After the epoxy was dry, I sandpapered the sharp edges. At last, I could paint them black with plastic lacquer while listening to "Paint it black" by The Rolling Stones. A simple solution for everything.