Close
0%
0%

Canta-Cart

Card-sized musical instrument with touch keys

ayuAyu
Similar projects worth following
Canta-Cart is a touch-operated musical instrument/synthesiser that takes the dimensions of a standard ID-1 card (85.6 × 53.98 mm). A portable little tune-maker in the pocket, it is easy for anyone to get hands on, yet versatile enough for the more aspiring of minds. It is plug-and-play — a USB-C power supply will take its sounds anywhere.

Additionally, the total BOM cost of CN¥4 / US$0.6 makes it an ideal greeting giveaway.

🎥 Video: https://vimeo.com/970898009 (more coming)
🕹️ Try in the browser: https://ayuusweetfish.github.io/Canta-Cart/synth/
🌳 Repo: https://github.com/ayuusweetfish/Canta-Cart (documentation WIP)

🎛️ Controls

On the card are 12 touch keys (10 for sounds, 2 for transposition). The sounding keys correspond to the pitches in a diatonic major scale, spanning a tenth interval.

The transpose buttons open up to a variety of ways to extend this. They work as follows:

  • Press once: move along the scale.
  • Hold and play a note: accidentals.
  • Press one while holding the other: key change.

The rationale is that most melodies (in music cultures compatible with the Western tonal theory) span a pitch range of around a tenth, at least over short periods, due to the register of the human voice and how musical instruments and compositions tend to imitate and invoke it. Thus, ten keys are mostly sufficient for a player to reproduce most melodies. The transpose buttons open a way to pitches beyond the ten-note major scale in cases where they are needed, covering the remaining cases as well as providing abundant chances for harmonies, musical textures, etc., through which delicate musical expression becomes more than possible.

⚙️ Inner Workings

(Please refer to the firmware source for all details.)

Capacitive Sensing

Touch sensing is achieved by utilising the step response of an RC network.

The circuit consists of a large resistor (~1 MΩ) in series with the sensing electrode. The latter can be treated as a capacitor to the circuit’s ground (not necessarily earth; a battery negative reference works just fine), whose value increases as human body parts approach it. A driving pin feeds the network with a step signal (namely, drives it high) and monitors the voltage change across the resistor, waiting for the sensing pin to go “logical high”. As the step response of this network is an exponential function (the derivation of which is explained in any basic electronics textbook), for the voltage at the sensing point to rise above the logical high threshold V_IH = k · V_CC (with a typical value of k = 0.7), the time taken is -ln (1 - k) · RC which is linearly dependent on the sensed capacitance C. By repeatedly sampling GPIO pins, the capacitance values at all electrodes can be straightforwardly deduced.

Run a simulation of the circuit here.

Audio Synthesis

The synthesiser is a basic triangle wavetable synth combined with an attack/release envelope. All calculations are carried out with 32-bit integers, minimising the time spent in synthesis and reducing overall latency to under 1 ms.

Audio Output

Audio is sent to a DAC through a digital bus comprising three signals: word select (WS), bit clock (BCK), and serial data (DATA). The DAC IC in the circuit expects the LSBJ format, which closely resembles the standard I²S. Our microcontroller does not have a ready-to-go peripheral for such formats, but it is possible to work within the limitation: BCK and DATA can be covered by an SPI output, and WS can be supplied by a carefully synchronised PWM timer channel. The DMA provides a half-complete interrupt, easing the implementation of a double buffer.

Why do these strange limitations arise? To squeeze out every penny/cent, of course! Which leads us to…

🔥 The Muntz Wildcard

Cost-effectiveness was an overarching consideration in the design. This gave rise to a few absurdities in the implementation, but as things were pieced together, they amounted to a knockdown BOM cost of US$0.6 per unit. As quite a few PCB houses now provide free prototyping services for boards of this size, this is the final manufacturing cost of the device. (Components can all be manually soldered with a hot air gun or an iron; I’m by no means a seasoned maker as electronics is only my side research as a design-focused student, but I did it all simply with solder paste and a hot air gun, without a paste stencil, a magnifying glass, or solder flux. YMMV, though.)

The microcontroller is at the heart of the device and often a major contributor to the BOM cost. For this design, I looked at...

Read more »

  • 1 × PY32F003F18U6 Microcontroller (Cortex-M0 32MHz)
  • 1 × TM8211 Audio DAC (16-bit)
  • 1 × FM8002A Audio amplifier (mono 2W)
  • 1 × YSX321SL Crystal oscillator (32MHz)
  • 1 × Speaker Speaker (8Ω 1W)

View all 7 components

  • Fixed. Fixed…?

    Ayu5 days ago 0 comments

    Debugging gets quite hectic without a correctly pitched probe header, rendering two hands and ten fingers inadequate, but the new probes I ordered several days ago has arrived this morning — what better day to make the final push?

    Three more assemblies. This has become my first PCB prototype batch that all got assembled.

    Instead of the original intended speakers, I went for ones of a larger type, also rated 8Ω 1W, but free from distortions at the desired amplitude. The sounds came out quite clear.

    Spread some cleaning agent on the boards, and wash it away with water. Everything was good, except that the speakers all got stuck onto the board. It would not move a bit, failing all attempts with tweezers, jumper wire headers, and safety pins. I don’t know the exact reason, but I suppose it might be the organic compounds in the solution melting the plastic…? Maybe I can try re-applying the cleaning agent to see whether it can be removed this way. There is a Chinese idiom that goes, “to remove the bell from a tiger’s neck, it calls for the very person who tied it there” (解铃还须系铃人). Well, it may as well apply here.

    That aside, now that everything seems ready…

    One last remaining issue (for this revision) is that the device makes a continuous buzz if plugged into certain types of power sources (e.g., USB receptacles on power strips). A laptop’s USB outlet presented no problem. I can’t find my portable power bank, so that remains unknown, but I speculate that it should work fine and the noise comes from mains hum. But that is left to be checked against later!

  • Quick update: it's working

    Ayu6 days ago 0 comments

    Things go on in life, but it's been quite smooth sailing regarding this little one.

    Firmware development was a breeze — Puya provides a library package that is largely compatible with STM32's HAL in terms of concepts and conventions. I2S audio was emulated with DMA-driven SPI plus a timer outputting PWM. The entire instrument works as intended. I'll record a video soon!

    One major setback is that the 20-mm 8Ω 1W speaker is proving inadequate, causing noticeable distortion in the sound — the issue disappeared when I replaced the speaker with a larger one rated 4Ω 3W. Seems like something to be thought over.

  • Hands dirty! But…?!

    Ayu06/24/2024 at 17:51 0 comments

    The board and the components have all arrived!

    Applying solder paste by hand. I did not rush to a stencil as I felt there were too many moving parts this time — all the ICs on this board I have never worked with before, so I’m actually expecting revisions before a finalised design.

    Soldered everything with a hot air gun. 0402 packages are quite a bit naughtier than 0603’s, especially when you’re dealing with a row of black resistors being nudged around on black solder mask! I think I’d switch to a resistor array if I’m doing a revision.

    Alcohol cleaning left some white traces of solder flux on the board, so I tried the cleaning agent for the first time. It smelt strange even through a face mask (stranger than any solder flux I’ve encountered), but worked out pretty well.

    We’re finally ready to launch the MCU and start blinking!

    Now comes the twist: I cannot find my DAP debug probe. I remember nothing about its location despite an exhaustive search. This got me stuck for two hours, I guess this is just part of my ordinary ADHD engineering experience. Well, that does not stop me by a least significant bit. Just flash a Raspberry Pi Pico with the debug probe firmware. Voilà! A new probe! Then solder wires to the test pads and the power line. Now there doesn’t even need to be a clip to hold the probes, as these jumper wires can be simply plugged.

    I know, the orange wire fell off very quickly. Once it was fixed, I was able to run pyOCD and flash the firmware through the Pico probe. Does it work? There is no activity LED on this board, but the DMM looks at pin A0 — accessible at one of the touch pads — and says yes, it toggles.

    That might not seem like much progress, but that concludes the day well anyway. How will things be going tomorrow? I’m getting curious as I practise on the simulator ^ ^

  • Getting started, with a simulator in the browser

    Ayu06/24/2024 at 07:39 0 comments

    Hi all! This is my first project log on Hackaday.

    This project, Canta-Cart, is a card-sized musical instrument with touch keys — to be an entry to the Business Card Challenge. It comprises 10 keys that make sounds of a diatonic major scale (spanning a tenth interval) and 2 transpose buttons for accidentals and overall transposition.

    The design of the electronics has been completed. While they are on their way from the factory/warehouses, I have implemented a simulator on the desktop computer (also ported to the web browser) as a testbed for synthesiser and interaction design. It worked out quite well — tunes can be spelt out without friction on this keyboard; harmonics and musical textures are achievable, especially on the smartphone touchscreen, which is free from the limitation of key conflicts.

    This simulator is now live at https://ayuusweetfish.github.io/Canta-Cart/synth/. It supports touchscreens and computer keyboards and has help information built-in.

    Meanwhile, I've also looked into how the PY32F003 microcontroller works. This is selected in favour of my go-to STM32G0 in order to reduce the overall cost — at 1 Chinese yuan (US 15¢) it brings the entire device even closer to a business card to give away lots of. Resource material on it does not seem abundant, but after a bit of scouring I managed to put together a minimal, stripped-down LED-blinking firmware project. It compiles, but I'll have to wait until the components arrive to test whether I've got anything off-track.

    The circuit board and the components are expected to arrive tomorrow, after which I will get down to the workbench to assemble the parts. Let's look forward to it.

View all 4 project logs

Enjoy this project?

Share

Discussions

msegev wrote 5 days ago point

Nice! Look forward to the video.

  Are you sure? yes | no

Ayu wrote 5 days ago point

Glad to see your interest! I've posted a very short video at https://vimeo.com/970898009. Please take a look! ^ ^

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates