• First Prototype Problems

    deʃhipu01/05/2021 at 18:52 0 comments

    The PCBs arrived from @JLCPCB today.

    Assembling one and flashing CircuitPython on it only took a moment, but I had to wait until the evening with programming it.

    I wrote this simple test program that just displays the state of the "holes" and the pressure sensor reading on the USB serial:

    import board
    import time
    import struct
    import busio
    import touchio
    class BMP280:
        _buffer = bytearray(3)
        def __init__(self, i2c, address=0x76):
            self._i2c = i2c
            self._address = address
            self._buffer[0] = 0xf4 # ctrl_meas
            self._buffer[1] = 0b001_001_11
            self._i2c.writeto(self._address, self._buffer, end=2)
        def get_pressure(self):
            self._buffer[0] = 0xf7
                self._buffer, self._buffer,
                out_end=1, in_end=2)
            return struct.unpack_from('>H', self._buffer)[0]
    holes = tuple(touchio.TouchIn(pin)
        for pin in (
            board.AREF, board.A0,
            board.A4, board.A6,
            board.A3, board.A1
    i2c = busio.I2C(scl=board.D6, sda=board.MOSI)
    sensor = BMP280(i2c)
    base = sensor.get_pressure()
    base = sensor.get_pressure()
    while True:
        print(sensor.get_pressure() - base)
        mask = 0
        for hole in holes:
            mask = (mask << 1) | hole.value

    It's very simple, but it already allowed me to see two potential problems.

    First of all, I put traces to the two left-hand "holes" close to the left bottom "hole", which means that you will sometimes touch those traces by mistake, and it's enough to trigger it. The next version will have those traces on the other side of the board, safely shielded with a generous ground fill. Easy.

    Second, my initial tests with the sensor were very brief, and I actually converted the value I was reading from the registers wrong, so I didn't notice that the sensor actually "swings back" after I blow into it, and takes a good minute to stabilize back to the ambient pressure. That is a considerable problem if we want to be able to play faster than one note a minute.

    For now I'm planning to make it trigger by observing the first derivative — the change in value, if you will — instead of the absolute value read from the sensor. This also solves the problem of the drift that the sensor has, and the challenge of being able to play while riding an elevator. It will complicate the code somewhat, unfortunately. If I can't get it to work, I will probably switch to a microphone. 

  • PCBs

    deʃhipu12/23/2020 at 18:45 0 comments

    I could prototype this project now with some Adafruit Feathers and carboard and wires, using the breakout for the sensor and some tinfoil for the touch pads, but I decided that I'm lazy, and went right into the PCB design step. I came up with this:

    The "antenna" thing on the top is where you attach a piece of a silicon hose, so that you can easily replace and wash it if you need to. There are also six pads for the "holes" — two on the back, and four on the front. Unfortunately that used up all the touch-capable pins on the SAMD21, so I can't use the DAC pin anymore (it's one of the touch pins), so at least this version is going to be only a MIDI controller, with no audio output of its own. There is also no battery necessary, since it's going to have to be connected to USB anyways, taking power from there. Depending on how well that works, I might find ways of adding more features to it later.

  • What? Why? How?

    deʃhipu12/22/2020 at 22:39 0 comments

    Ocarina is a pretty unique instrument. It's officially woodwind, even though it usually doesn't contain a single piece of wood, being made out of ceramics (though wooden ocarinas do exist, as well as plastic). It usually has much richer and more interesting sound than all kinds of pipes. And thanks to its appearance in several computer games, you can easily find a lot of game music converted to ocarina tabs. The six-hole ocarina is a specific type of this instrument, that has six holes, and often can be worn on your neck as a pendant.

    There is one big problem I have with my ocarinas, though, and that is probably common to a lot of people who want to practice playing instruments — nobody wants to listen to you practicing, especially if you are pushing your current skill and making a lot of mistakes. For piano players this is a solved problem: just get an electric keyboard and play wearing your headphones! While there are also electronic woodwind instruments, they are usually a bit weird, look nothing like a six-hole ocarina, and use completely different fingering than an ocarina does — so not very good for practice.

    So I'm going to build my own. I need a sensor for detecting how hard you are blowing, and six touch-sensitive pads, for detecting which holes are covered and if they are covered whole or just partially (for bending). I'm going to start with a simple USB MIDI output, so that I can use a synth program on my computer to actually make the sounds, but maybe I will also make a standalone version with a headphone jack and a battery — we will see how the project progresses.

    The first thing, and probably the hardest, is to decide on the breath sensor. The most obvious solution is a pressure sensor, placed inside some kind of a pipe, so that I can measure the air velocity. If that doesn't work, I can use a variety of other solutions, from a microphone to a heater and temperature sensor.

    So I took a BMP280 breakout board, blue-tac-ed a piece of straw with a hole on the side on top of it, and tested what readings I can get from it. Initial tests are very promising, I can see a marked increase in the sensor readings while blowing into the straw. More testing is necessary to see how well this behaves, but I'm hopeful.