Since the last update, I was able to:
- Continue implementing the state machine and integrate it with the MIDI file receiving and parsing code
- Implement the necessary interrupts for the state transitions
- Verify that the interrupts trigger the state transitions using an analog circuit
After talking with the teammates more about how the user experience will work, we decided the RPI will do light parsing of the MIDI file (to strip out unnecessary information that the Teensy doesn’t care about), so the Teesny only needs to parse the note and timing info.
Since the last update, I included a much more final version of the state machine, including support for the “file_transmission” and “pause” interrupts, which will eventually originate from the RPi. Implementing these 2 interrupts was challenging due to being rusty with the Arduino ecosystem, but those 2 alone account for half of all the state transitions. The next interrupts will be easier given that I already know how to do this now.
The above image shows the 2 interrupts I implemented and how they affect the state machine. The following image shows how code is executed in the main run loop based on the state stored in the FSM:
This picture also shows that I have integrated the MIDI file parsing code into the body of the state machine. This unifies 2 previously disparate bits of code.
Since I didn’t have easy access to the RPi (Ashwin is using it for his development), I had to figure out a way to mimic interrupts from the RPI. Since plugging a wire in and out of a breadboard rail will give multiple edges, it was not feasible to generate clean interrupts. Instead, I resorted to a purely analog way of generating the interrupt. By taking the signal that would otherwise contain multiple edges and feeding it through a simple RC low pass filter with a time constant on the order of 1 millisecond (10k resistor + 100nF capacitor), I can achieve “analog debouncing.”
The following picture shows a bank of such RC filters so I can mimic multiple interrupts. The “paper flags” indicate the name of the interrupt being simulated. The yellow wires that arch over are plugged into and out of the breadboard power rails to create rising and falling edges. Pull-down resistors (not pictured) pull the interrupt pins down to 0V so they are not floating when the yellow wires are not connected to either logic level.
This progress is on track as I finalize the structure and implementation of the code. The next big tasks are verifying fret detection (this has actually slipped) and creating the user experience modes (scale + song).
As you’ve now established a set of sub-systems necessary to implement your project, what new tools are you looking into learning so you are able to accomplish your planned tasks?
As I integrate more with Ashwin’s web-app, I might need to learn about his code. This may involve learning web-app frameworks in Python (something I have never done before) so I can understand what his code does and how it can easily input the data that will flow between it and the Teensy. Also, since we decided to offload some parsing onto the RPI, I may need to learn about low-lever byte manipulation libraries in Python, so I can communicate with Ashwin about how he can transition my existing C++ parsing code to Python. I don’t have much experience with such python libraries, so that will be new.