Pretty much exactly what the title describes, can play 4 channels of polyphonic squarewaves at once triggered by 13 capacitive touch keys
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
piano v1.1.brdEagle PCB v1.1 (with 2 Batteries)brd - 106.46 kB - 05/27/2022 at 12:16 |
|
|
piano v1.1.schEagle Schematic v1.1 (with 2 Batteries)sch - 441.94 kB - 05/27/2022 at 12:16 |
|
|
piano_v1.1_2021-04-20.zipPCB Gerber Files v1.1 (with 2 Batteries)Zip Archive - 162.67 kB - 05/27/2022 at 12:15 |
|
|
Touch PCB Piano Case.STLCase v1.0 3D Print Stereolithographic File (with 2 Batteries)Standard Tesselated Geometry - 139.05 kB - 05/11/2021 at 15:46 |
|
|
piano_2021-04-07.zipPCB Gerber Files v1.0Zip Archive - 155.05 kB - 04/20/2021 at 12:33 |
|
Design info TDB but here's some glamour shots for now ;-)
To start off, thanks to JLCPCB for sponsoring this project and providing the pcbs I designed. JLCPCB Prototype for $2 (Any Color): https://jlcpcb.com/DYE
So what do the polyphonic waveforms actually look like when playing four different notes?
My first experiments with touch pcbs went pretty well so I figured I'd move on to making something more ... complex and interesting. A little backstory, my sister is the more musically inclined one in our family so when she was young she took piano lessons for a number of years and she was very good at it. Every year for her birthday I make her something so I figured this year it would be something musical, specifically related to the piano.
Her bday isn't till September so that gives me plenty of time but I figured that my recent interest in touch sensing could be combined with my recent audio experimentation in my UV timer controller project (where I played with custom beeps played through a piezo when the timer went off). So what better project than a touch piano! I'm just hoping that she doesn't read my project posts or watch my videos :-) in the meanwhile.
The first step was to design a pcb using what I've learned in the last log. Here's the design I came up with:
I tried to keep the key size and spacing reasonable for a human sized finger. I also wanted to keep everything as thin/flat as possible so I opted for all surface mount components, including the speaker (a magnetic one, but a piezo would work as well). I opted for a CR2032 to provide power with one of those thin metal battery holders that can simply be directly soldered to the pcb. To round out the features/components I use my goto atmega328p, two leds to indicate power and button presses and finally a small slide power switch. I did think about doing soft power control either using a momentary button (to minimize power draw) or another touch button but figured I'd keep things simple and just use a switch. Other than that I added two header spots, one is for icsp in case I needed to flash the bootloader/fuses on a new chip and the second is a serial port for programming using a cheap usb serial dongle. I think in the next board revision I'll add these hidden on the other side to interface with a pogo adapter so they aren't visible on top.
So now I had a pcb designed and a reliably working touch sensing library. While I wait for the boards to be manufactured and sent from China I proceeded with the next step which was to tackle the rest of the software. I first started with the beep/bloop software I'd written for my UV timer controller project had some serious limitations. For starters it was really meant for playing preprogrammed tunes so it was blocking (meaning nothing else could run while playing), and also it could only play one note at a time.
I could just throw a single timer at each channel (the atmega328p has three timers), but that would only net me three channels and regular delays that rely on timer0 would stop working accurately. I needed a software solution.
To address this I knew I had to move the squarewave generation to use an interrupt. Since the human hearing range is specified to be around 20kHz I set that as my upper end. This meant I had to use at least a 40kHz interrupt (since one period of a squarewave requires two edge changes). Below is a little diagram I drew up to demonstrate how the interrupt and output frequency generation would work.
To start off, thanks to JLCPCB for sponsoring this project and providing the pcbs I designed. JLCPCB Prototype for $2 (Any Color): https://jlcpcb.com/DYE
First step in this project was to read up on some literature (links below and in video description) on designing custom touch sensitive pcbs and design a few prototypes to see how sensitive touch pads would be. I filmed a video where I test out two such boards I designed, one slider and one scroll wheel. I utilized the arduino "CapacitiveSensor" library (credit goes to the authors Paul Bagder and Paul Stoffregen) to do the touch detection. I've written similar touch routines in the past for pics (in fact one of the first videos on my channel was a demo of my software written in assembly for the pic16f84a), but in the interest in spending my time on pcb design I opted to use a tried and true library.
A main takeaway from my research and designs is that the clearance between two distinct button pads is fairly important to not getting false positives on an adjacent button when the other is pressed, literature suggested at least 30mil. In fact the clearance between a button or trace to any other copper (including ground) should keep this minimum distance in order to minimize noise and crosstalk. Additionally using a grid/mesh ground plane is suggested to help with those as well (literature all note to set the angle of the grid pattern to 45 degrees of pad/trace routing but in eagle this is not very easy to do so I just left it at 0 degrees and the boards still work fine). Sensitivity is mainly affected by button size as well as the choice of sense resistor. In my case I found 1M works reliably, but it can be increased for extra sensitivity (can detect proximity not just touch, but at the cost of longer polling periods) or decreased for direct touch detection (polling period is quicker).
References I used in the making of these prototypes:
https://www.arduino.cc/reference/en/libraries/capacitivesensor/
https://github.com/NicoHood/HID
https://datasheet.datasheetarchive.com/originals/library/Datasheet-071/DSA00359316.pdf
https://www.ti.com/lit/an/slaa877/slaa877.pdf?ts=1616682272626&ref_url=https%253A%252F%252Fwww.google.com%252F
https://www.nxp.com/files-static/training_pdf/WBNR_8BIT_TOUCHSENSING.pdf?&lang_cd=e
https://www.nxp.com/docs/en/application-note/AN4600.pdf
Create an account to leave a comment. Already have an account? Log In.
Have you considered using different resistors in the adder, basically constructing a 4 bit DAC on the hardware side, and doing the multi channel adding on the software side?
Like PORTC = (PORTC & 0xf0) + f0on + f1on +f2on +...
If my theory is correct this should add a lot of channels, or enable more advanced waveforms, like sawtooth or triangle.
I've seen a few synth projects that do exactly this, I'll have to play around with it for the next revision.
I had modified the int sensitivity=50; //40; rebuild the ino file from Arduino IDE. It output two hex file,one is TouchPiano.ino.standard.hex, the other is TouchPiano.ino.with_bootloader.standard.hex, when I burned the one of the two files. It can't be work.Nothing output from Buzzer. How solve this issue?Thanks!
Did you also "To force the touch sensing routine to a safe value try commenting out the cal() on line 662". Otherwise the autocalibration function will overwrite the sensitivity variable anyway. Also you should check that the soldering is all good first by running the blink example to make sure the fuses are set correctly and the oscillator is running.
Thank you for your shared this impressively project. I had PCB from JLC, use the 3v passive buzzer, download the hex file to the chip.Only P1 led light on.If I press the touch key, anything to listen from buzzer.How to solve this issue.Thanks!
Have you soldered all resistors? If the LED labelled L doesn't light up when you press a key that means for some reason the atmega isn't detecting a key press.
To force the touch sensing routine to a safe value try commenting out the cal() on line 662 of the ino file, setting the sensitivity variable to 40 or 50 on line 69, recompiling in the arduino ide and reburning the program onto the atmega using either serial or icsp.
How about the buzzer, is passive buzzer or active buzzer?
It's a passive buzzer/speaker. The frequency generation is done in the atmega.
有没有试过不同的音符叠加在一起会有颤音,就是刺耳的声音,我怀疑是奇数谐波叠加的问题。
Have you ever tried to have different notes superimposed together and there will be trill, that is, the harsh sound. I suspect it is the problem of odd harmonic superposition
I initially thought that could be the issue, but the slight rattling sound I can hear in person but not easily in a recording doesn't happen with a piezo attached instead of the electromagentic speaker. This makes me think it's something mechanical related to the physical properties of the speaker.
Become a member to follow this project and never miss any updates
Is there a BoM somewhere? I can't find it.