Midi Bass Pedals - Part 2: Simplify

The Rocky Start
My embedded systems journey started When I was in High School. I was coding up an animatronic project for an Arduino, and my CS PhD dad tried to teach me about event loops and event driven design. The project didn’t go great (what would you expect from a high schooler who only knew Java and web languages before this), but got me interested in embedded systems. Fast forward several years, and I’m a CS student at BYU taking a computer systems class where we used the MSP430 MCU (TI). We wrote small projects like a LED Morse code generator, a game of Snake, and other small projects. This taught me valuable lessons about embedded systems like how to debounce switches, how to use interrupts, clocking systems, CPU structure, etc. I left that class much smarter and more prepared to work on some iOT projects, this time ESP32 based, taking sensor data and uploading it to the cloud for further processing and reporting.
These were all very simple projects which involved significant mentoring or resources. The community around Arduino, RP2040, and ESP32 is huge in the maker space. If you’re trying to write a project for one of those platforms, it is easy to find libraries, tutorials, examples, and sometimes wholesale solutions to do what you want. I thought myself competent at very rudimentary embedded systems programming. Admittedly, I am better than a lot of devs out there sipping their soy lattes from their JS mugs (you know who you are), so I picked up an STM32H750 development board thinking, “this’ll be a big learning opportunity, but should be in my wheelhouse.” Boy, was I in for some surprises.
I wasn’t ignorant to how complex embedded systems are, or the miracle that is modern computing architecture and abstractions through amazing GNU libraries, or hardware drivers. It really is amazing that anyone understands enough to make something as simple as a mouse work. If you break it down, it’s an incredible amount of work that went in to making something so ubiquitous possible. Now because of abstraction, almost any competent programmer with a bit of soldering experience, a 3d printer, and youtube could make a passable mouse in a couple days time.
That being said, I decided on my platform based on having enough GPIO pins to have enough buttons to press, and a system that had been shown to work with audio playback or some DSP. I came across the Teensy boards, but they didn’t quite have enough GPIO pins for this project (I also didn’t want to worry about designing around a multiplexor before someone points that obvious bit out). The STM32H750VB had a development board that I could get super cheap, and I found videos and github projects where people had used this board and similar boards for synthesizers and guitar effect pedals. It seemed like a good fit. I didn’t know that the community around the STM32 MCUs would be significantly smaller than the Atmega chips, but I did see arduino support so I figured it would be easy enough to combine the two.
I’m not a project manager. I’m not a project manager. I’m… oh crap
Working on large projects can often be overwhelming due to their complexity and the sheer number of tasks involved. It’s easy to get lost in the details and lose sight of the overall goal. I hit this very quickly with my MIDI bass pedal project, mainly due to how many components I was trying to combine. The requirements for my project, while nebulous, are pretty ambitious. I want a MIDI controllable synthesizer with built-in pedals that control the tones, built-in buttons to switch presets/banks of presets for the voices, shift octaves, knobs to adjust settings, MIDI output, balanced and unbalanced outputs, and more.
That’s a lot to tackle at once, especially when you start to consider the implicit requirements, like persistent state, persistent presets, interacting with a DAC, possibly external DACs, oh, and did I mention that this is without having a provided file system to write to? Without having abstracted libraries where I can just throw an MP3 file at it and it’ll play to the proper output? Also, when did embedded systems start using a HAL?
As Henry Ford once said, “Nothing is particularly hard if you divide it into small jobs.” I was spinning my wheels moving nowhere in my model A for too long on this project, and decided I had to do something. This is when I put on my project manager diaper and started making the tough cuts. First was breaking out the keys and midi controller from everything else. I knew I could write simple code to handle button presses from my previous experience, so integrating that with the Arduino MIDI library seemed doable. And it was. I coded up a decent MIDI controller for an arduino Uno in about an hour and had it tested and working. Hooray!
Gaining momentum and jumping over fences
In high school, I ran cross country and my friends liked to jump the baseball fence at our school since it had a hard plastic cover over the top of the chain links. I remember my first time running up to it, then, slowing to jump, I wasn’t even close to clearing it. So I got a running start, ran straight at the fence, and still didn’t have the height. I smashed straight into the chain link fence. But something incredible happened- I grabbed onto the fence, and my body bouncing back gave me momentum to slide over the plastic covering at the top of the fence. Sometimes its better to approach work smarter, not harder, but sometimes, you just need to work as hard as you can, and take advantage of mechanics and systems in place which will help you.
So I broke down my project and started running at the fence. MIDI controller, check. MIDI Input skeleton, check. State Manager to centralize common state, check. Now what the heck is QSPI, SPI, I2C, SDMMC, and when will I get the time to learn about them deeply enough to actually use them? I quickly discovered that arduino as a hardware abstraction was lacking, which led me to the manufacturer and their tools for development. Since everyone seems to be moving to vscode nowadays, they have built out support for building, debugging, and coding in vs code. While intellisense is a bit lacking for C and custom CMake binaries in vscode, it’s helpful to have some auto-complete in place and a copilot to keep suggesting via includes that I should’ve used a different chip (the STM libraries have headers for multiple chips not just the STM32h7xx.h header).
Feeling enthused by the project was great, but as easy as it was to jump that fence, a brick wall isn’t very elastic, and won’t be as bouncy to run into. It’ll stop your momentum faster than you can gain it. So you have to find a way around it. This is when I realized I was a project manager. I wasn’t just the programmer on this project, I was technical lead, project manager, customer, technical support, and angel investor all wrapped into one. And if I didn’t want to work on my project anymore, how could I work around that? I had already started scoping things back too far to want it, but I knew it had the potential to be what I needed.
Moving forward
Sometimes the best thing about these passion projects is not the product, but the process. Even though a passion project’s focus is on the product (that’s what drives the passion), there is more to be had by learning as you go. There are unexpected products you can create that will benefit you as much as or more than the project you do or don’t complete (and usually you won’t complete it). With that, my goal is to learn what I don’t know so that I can finish this project.
I think that if you can’t teach something, you either don’t know it, or you can’t code it. Coding is nothing but codifying instructions and thoughts into a hardware specific language. It’s stating something so exactly and perscriptively that even a machine that can’t think will make it work. A machine will do exactly what you tell it, even if that’s not what you want. Even if it’ll cause it to self destruct and let out the magic smoke that was the only thing making it work to begin with. With that said, I’m going to start working on tutorials and examples around the STM32H7 platform which will help me iteratively build my knowledge and understanding, while providing a service to others.