Using this software - the journey #4
Replies: 6 comments 1 reply
-
|
Wow, that's quite impressive!
Ohh, I have looked at those with envy several times already :-)
That seems to be a good quality board, I have read good comments about them in the MicroPython forum.
Thonny seems to be simple and useful. I use VSCode to edit/lint the code and mpremote and old fashioned make files to update the microprocessor. Another nice development environment seems to be Viper IDE https://viper-ide.org
Oh yes, during that time the software is uploaded via the USB connector. Rest of the topics: I'll comment that later. Believe it or not: I have to go leave now to play the crank organ at at a Christmas concert :-) |
Beta Was this translation helpful? Give feedback.
-
|
Re: Questions to ponder
What type of battery pack is that, and what type of monitoring are you thinking to do? Batteries are quite difficult to monitor externally. For example, measuring the battery voltage does not lead to good results, since the voltage depends on the current load and discharge curves do not help much there. A power monitor such as the INA220 may be the best option, since you can measure the consumed power directly and then add that over time and compare with nominal battery capacity. But that is somewhat equivalent with what the software currently does indirectly: the software adds up the operating time and the time solenoids are on and correlates that (with a linear multivariable regression) with the user input when the battery is empty to estimate a discharge curve.
That sounds great! I made some tests with the BMP280 sensor and it seems very adequate for the job. It connects to I2C, so if you put the MCP23017 inside the windchest, you can put this on the same bus (https://www.tapatalk.com/groups/buskerorgan/viewtopic.php?p=7391#p7391). Rotation speed: do you mean crank rotation speed? There is a capability in the software to measure crank rotation speed both with a simple encoder or with a quadrature encoder. The crank can either only start the tune, or can be set to influence playback speed. To sense rotation, it uses the PCNT hardware on the ESP32-S3 chip, so this has very little overhead. I have had many, many headaches with the crank sensor (mostly problems I introduced myself) and have a writeup pending with the conclusions... At this point I have pending to test a quadrature encoder as crank rotation sensor, which I like a lot, but I managed to connect 12V to the microcontroller input and fry it, and haven't had the courage and time to try again so far (and I needed to order a replacement ESP32-S3 board). As for tune information display, that's quite interesting!
I never thought about separating the code in two, so this will need some coding and design. I can certainly assist there. On the other hand, the "optimization" while playing back music allows to do tasks while the music plays, but you have to be a bit careful. The main issue is responsiveness, i.e. no task should "hog" the CPU for a long time, since that will mean a delay in the notes that are playing. A small delay, such as 10 to 30 milliseconds, is barely noticeable, since the MIDI player catches up with the tempo if that happens. So if a task needs little CPU time once in a while, it can perfectly run while the music is playing. For example, what I'm currently doing while music is playing:
Internally, this multitasking is not done with threads but with a mechanism called If a longer computation is needed, exceeding, say, 30 milliseconds, then this software provides a What this will do is to put the enclosed statements to wait until there is a 200 millisecond (or whatever time you specify) pause or long notes in the music. Music has lots and lots of pauses or long notes! That way, long tasks go absolutely unnoticed because they are scheduled when the music allows it. For example, MicroPython's garbage collection, which used to need up to 150 milliseconds, is handled this way and never interfered with the music. The only drawback of And, for me, the other drawback was that I had to learn about So as a first go, I would take the easier way and launch a task using Of the enhancements you mention, the display is probably the most CPU consuming one. It would be interesting to measure the display update time. I would guess update time is quite fast, probably much less than 200 milliseconds. I think this route is less work than splitting the software in two. The music player is currently not stressed at all, the response can be monitored installing a But I think this could be the best option: when using a second microcontroller for example for a display and buttons, there are already many JSON webservices coded such as To communicate two ESP32-S3, ESPNOW seems to be the way to go, although to use the available web services you would need TCP/IP over WiFi (i.e. the builtin Please let me know if this is useful. |
Beta Was this translation helpful? Give feedback.
-
It's a nice board! Fortunately there are several good quality providers for ESP32-S3 boards, that's good for us!
I agree. All functions are exposed as web services, so adding a second user interface should be quite feasible. (edit) For example, to implement a crank rotation sensor in a second microcontroller, there is a /set_velocity_relative web service. I did not document these web services, I never thought somebody might use those :-) but please post your questions here and I'll be happy to find some way to implement that.
I did all the support for calculating the battery usage, but then found out that at less than 300 grams per battery it's easier to carry a second battery pack around :-) and changing it when required. But it's nice to have a better indicator than just four leds.
Yes, I want to do that sometime also! There are some excel sheets out there to calculate the theoretical wind usage based on pipe measurements, but measuring the real thing is always interesting and sometimes surprising!
That's what tachometer.py does currently. Probably a good part of that code can be reused.
Oh yes, that's one of my dreams in the future, to have a e-paper display for the current tune title/genre/author/year/info. I find the flickering refresh and refresh time (sometimes 10 seconds or so) of many units annoying, but good, fast and non-flickering e-paper displays exist (but can be quite expensive). There are even some bendable e-paper displays out there :-) |
Beta Was this translation helpful? Give feedback.
-
|
Proof of concept - first stage - completed successfully. ESP32 S3 (Dev Kit equivalent) with breakout board. Updated Micro Python to access 16Mb flash. (separately tested adding SD card and finally got that to work too). All code added and working. Battery pack (12v and 5v). Two MCP23017 breakout boards (one I2C line, two different addresses). PCL signal controller (32 channel) with 3.3v input signal to control 12v relays. Valve relays (7 wired in for testing). Playing a basic Midi file. VID_20250105_122812158.mp4 |
Beta Was this translation helpful? Give feedback.
-
|
I like that!! Neat setup, looks way better than my breadboards!!! I am very happy that you could make the whole setup work! |
Beta Was this translation helpful? Give feedback.
-
|
I am very happy that it was, relatively speaking, remarkably easy to build a working Midi organ with so little effort. Your software is comprehensive and easy to use. I am planning on adding a synth unit to provide additional support for bass pipes, drum sounds, and perhaps an additional reed/trumpet rank. I have a couple of SAM2695 units (and amp / speakers). I just need a Midi feed for this, which could come from the organ software, and that would then mean I can fully test with sound before I start on the physical stuff. Next step is to break into the pipework somewhere, put in one of the solenoid valves, and check to see if it actually works and lets enough air to the puffs. Slow and steady progress. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Rather than continuing to post 'issues' I am continuing my I intend to use this myself! as a discussion with an update on progress so far.
Hardware is on hold while I gather the necessary components, and I aim to build the controller with solenoids as a test first. Once all is proven I can consider how to go about modifying pipework etc and installing in the organ.
Using an M5stack Core S3.
A nice unit, and I have managed to get it loaded and connected with the Uiflow tool. I am experimenting with various extension modules - rotation sensors, pressure sensors, and a midi synth unit. It helps to use the Uiflow with blocky to easily find the 'code' for the extra units and the internal display screen, but I find it less satisfactory for programming than directly with python code. I have added Thonny to my PC and found this a great tool - easy to connect to the S3, easy to navigate the flash, and easy to use the REPL to test code directly.
I have managed to write simple code using the M5 libraries to access rotation, pressure sensors and to write to the screen. I have taken the umidiparser code (see different repository) and written a very simple program to load the necessary modules, initialise the synth unit, add the SD card, read a fixed midi file, and then play the midi file sending the midi note on commands to the synth unit. It works!
The hope is that I can somehow use this CoreS3 for front-end display / control, and to add rotation and pressure, and also possibly use the synth for drums etc or an additional pipe register. It would be interesting to have a small amp-speaker to add sub-octave 'helpers' to the base and accompaniment notes.
Using this for the main organ program itself may not be possible without wiping the Uiflow from firmware, and timing may mean that it is just not possible for example to continually read a pressure sensor to provide a gauge meter. My thought is to consider using one esp32 S3 for the main program, and the M5Stack Core S3 unit for monitoring / control with a connection between them.
Using other S3 boards
I bought an adafruit Metro ESP32-S3, which works nicely and I have been able to write micropython to the flash using Thonny, however the adafruit board is intended for circuitpython, and I have struggled with getting this to work. I added all the organ data and software files manually, but found running the code caused a string of issues. I assume the existing UM loader is getting in the way.
So off to yet another S3 board, this time Unexpected Maker ProS3. Staring from scratch I have added Python to my PC (tip - make sure you tick the 'add to PATH' option otherwise nothing works). I have used Thonny to add micropython to the board, and I have run mpremote in Python from my PC command window and executed the install commands. (note, the software install takes quite a long time and nothing much visually happens for a while).
The software is up and running
The organ software works nicely. I have just had to edit the main.py to change the initial NeoPixel pin number for this board. The WiFi works and the board is now configured to connect to my home network, and typing 'organ.local' in a browser finds the organ pages. I have added just the one midi file (to flash) and I am still using the default 20 key config, but it all "works", and I have even found that I can see and play the midi file on the PC!
Next job is to get a breadboard, the MCP23017 expanders, solenoid drivers (I have a 32 channel PNP driver board on order) and wire all this up with real solenoids.
Once the 'system' is proven I can test the solenoid values that I have, and if they work in the organ, it will be a case of building a new wind chest for the valves and installing everything.
Questions to ponder
I appreciate that, when a midi file is playing, there is a lot going on and the code has been written to minimise other activities so as not to stop the music. I would like to be able to add wind pressure monitoring, rotation speed monitoring, current tune name display and stop/start controls etc using the M5Stack CoreS3 display. Since the midi tune-player part is just one section of the code with the rest mostly devoted to running the webserver, would it be possible to separate the two, having the tune-player etc on one esp32-S3, and the webserver and any extra code I would like to add on another esp32-S3? I understand that esp32 can communicate between one to another using ESP-NOW. Since these boards are really very cheap, a multi-board system would take the pressure off the midi player and allow extra features on the 'display' end of the system.
Beta Was this translation helpful? Give feedback.
All reactions