I was cooking pancakes for dinner on a peaceful evening. It was going well, half of the pancakes were done. Then I tried to flip the next pancake... And suddenly I found the handle of the pan in my hand. Without the pan! Revenge had to be served...
![The Pan from below](https://private-user-images.githubusercontent.com/48630952/237762267-aaa561df-8837-4fc7-982e-e7d50344a3ec.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzNzY1MjMsIm5iZiI6MTcyNDM3NjIyMywicGF0aCI6Ii80ODYzMDk1Mi8yMzc3NjIyNjctYWFhNTYxZGYtODgzNy00ZmM3LTk4MmUtZTdkNTAzNDRhM2VjLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIzVDAxMjM0M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMzMjNkMGY3YWQ1OGFlNzZiZjg4NGI5YmYzMTc1MWE3NmFjYjA3OTMwMDUxMDJhNjc4ZDAyODY3OGE3MWQ4NjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.u5dRbiWGa07wSuT7kS6W5FR7t6CMC6FsnP3gajMGAVw)
![The Pan from above](https://private-user-images.githubusercontent.com/48630952/237762212-a0822521-735f-47f2-84dc-502bb2e25141.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzNzY1MjMsIm5iZiI6MTcyNDM3NjIyMywicGF0aCI6Ii80ODYzMDk1Mi8yMzc3NjIyMTItYTA4MjI1MjEtNzM1Zi00N2YyLTg0ZGMtNTAyYmIyZTI1MTQxLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIzVDAxMjM0M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY3NWMyYmI2OTZiMWY0YjA1OTc1N2Y3MjEyMTVhZTVlMDI1OWNlNjJmNzYyMTBlYzE5NzUzY2NhZjA4MWI5MGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BQ6vTZWQPK5CKGwlQl-FiQlMqQyAdkiuiByHDksqGfo)
The Pan has 5 potentiometers and 5 rotary encoders (with push buttons) below them, also it has 1 button (alt). The microcontroller is a Wemos D1 R2 board. The rotary encoders and the button are connected to a CD74HC4067 16 channel multiplexer. The multiplexer is read with a digital pin on the microcontroller. The potentiometers are connected to another multiplexer of the same type. It is read by the analog pin on the microcontroller. It still has 11 channels remaining for future upgrades (e.g. some piezo sensors as drum pads). The select pins of the multiplexers are connected to the same digital pins on the microcontroller. The powering and communication of the device is through the micro-USB port of the board.
The code on the microcontroller reads the state of the components on The Pan and sends a message through the Serial Port when a change is detected. A Node.js script reads these messages, gets the necessary data from the microcontroller to determine what is being done on the pan. (e.g. holding down a button, or pressing it shortly). Then it translates these messages to MIDI messages. These messages are then sent through a virtual MIDI port (the port is created using Tobias Erichsens loopMIDI application)
The MIDI messages then find their way to my beloved DAW, FL Studio, where a script controls the changing of parameter values. Sadly there is no standardized way of handling infinite rotary encoders, so I had to come up with my own way. A more robust version of the Node.js script has been rewritten in Rust, it is no longer used, but is left here in memorial.
The microcontroller connects to the driver by exchanging two very sophisticated messages:
- Who are you?
- I am The Pan.
Then it starts sending the changes of components over the serial port. These message make it possible for the driver to identify The Pan on one of the serial ports. The driver translates the messages from the Pan into MIDI messages. These messages are sent through a virtual MIDI port. It is not possible (or way too hard) to create a virtual MIDI port on Windows (as far as I know), so I use Tobias Erichsen's loopMIDI application as a workaround. This program is automatically started by the driver, or detected if it's already running. The MIDI messsages are then further processed by a Python script to control FL Studio.