chuck
New Member
Posts: 40
|
Post by chuck on Feb 19, 2022 16:37:17 GMT
Mocking up a new keyboard case and wrangling a new scanning circuit with the Pi Pico. The Pi Pico is 3.3 volts and that won't make it through the key matrix so I have to bump the voltage up. These sparkfun logic level converters take the place of the op amps I was using before and increase the voltage but if I give it the 5v supply then the return value is too hot for the Pi Pico so I use a couple of resistors to drop the supply to the converters just a little bit instead of using more converters to convert voltages back down. Now I have the Pi Pico scanning the keys and doing note on and note off messages for all 64 keys (three extra at the bottom! Thanks Roland!) But I want to do velocity as well. There's an extra set of contacts I can scan. The circuit and the code will change. And I have some woodworking to do.
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Mar 5, 2022 20:07:01 GMT
The keyboard matrix is 8 by 8 times two... that's a lot of io pins to dedicate to key scanning so the new circuit uses a 74hc138 to turn three of the pi pico PIO pins into 8 lines where one at a time is active low. I'm using a couple of CD4051s in parallel to select (by three more PIO pins) from the 16 returning keyboard lines (only 8 wired up here) to a couple more PIOs that have pull-up resistors to 3.3v. I'm not 100% sure I have my logic right but at least I didn't let out the magic smoke... this time!
|
|
|
Post by rodney on Mar 7, 2022 11:01:00 GMT
that is so cool! I am looking at some keyboard designs for microtonal scales. I am going to try a layout with two rows of keys for 19 steps to the octave in the hope that I'll be able to still reach an octave with one hand (currently impossible using a conventional keyboard like in the vid below ...
I've also been messing with computer keyboards as a cheap isomorphic MIDI keyboard but, of course, no velocity at this stage ...
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Mar 7, 2022 14:21:43 GMT
Microtonal interests me too, that keyboard conversion is very clever. Building a microtonal musical keyboard from the ground up would be next level!
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Mar 8, 2022 22:29:39 GMT
I just was able to toss out the logic level converters when I realized that instead of a key press allowing 5v to flow one way through the diode... the same key press also allows -ground- to be seen from the other side of the diode, vs. the line just floating! That means all that voltage conversion can be replaced with a couple of pull up resistors. This circuit is scanning all the keys using 3.3v powering the 138 and the two 4051s, one for each of the two contacts per key. I'm only reading one of the 4051s right now, I have to add the timing routines to the code to handle the second one and get the velocity. Currently the pico sends midi to an out-of-frame raspberry pi which further sends it to a cv-gate gizmo which the AE Power module reads and sends to the 2OSC/d... next up will be adding volt-per-octave, mod, and gate from the pico for that all-in-one solution!
|
|
|
Post by keurslagerkurt on Mar 11, 2022 6:49:22 GMT
I just was able to toss out the logic level converters when I realized that instead of a key press allowing 5v to flow one way through the diode... the same key press also allows -ground- to be seen from the other side of the diode, vs. the line just floating! That means all that voltage conversion can be replaced with a couple of pull up resistors. This circuit is scanning all the keys using 3.3v powering the 138 and the two 4051s, one for each of the two contacts per key. I'm only reading one of the 4051s right now, I have to add the timing routines to the code to handle the second one and get the velocity. View AttachmentCurrently the pico sends midi to an out-of-frame raspberry pi which further sends it to a cv-gate gizmo which the AE Power module reads and sends to the 2OSC/d... next up will be adding volt-per-octave, mod, and gate from the pico for that all-in-one solution! This is some real clever designing/engineering! 😄 Looks like a a very nice project, really curious to see it evolving
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Mar 21, 2022 4:37:02 GMT
The circuit works on the breadboard, time to break out the soldering iron... _ The breadboard also has a 4x dac breakout board over i2c on it giving me volt-per-octave in addition to midi in/out (not shown in the circuit) so that goes below the pi pico on this board. I have more wire to place... the back so far has just ground, power and i2c. When i plug it in it does not burst into flame so that's encouraging! The dac only does zero to four volts. Even if I scale it so it does zero to 5v I have 64 keys on this keyboard... over 5 octaves. I'd need more than five volts to get the full key range unless I add in a keyboard split, which I totally can do and probably will. It's too bad the high/low switches on the 2OSC/d don't also have CV inputs because that would be one way to get the wider range. Attachments:
|
|
|
Post by pt3r on Mar 21, 2022 6:53:03 GMT
Wow that look really clean and cleverly designed. I hear you on the CV controlled range that would be a really nice feature to add to the OSCillators, the same goes for a CV controlled rate for the LFOs. I has happened already a few time that I really wished there was the possibility to set the LFO's tempo via a CV. You could perhaps hack your way around the range switching by letting the pico address one osc for the lower range and the other osc for the higher range?
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Mar 21, 2022 14:09:59 GMT
Wow that look really clean and cleverly designed. I hear you on the CV controlled range that would be a really nice feature to add to the OSCillators, the same goes for a CV controlled rate for the LFOs. I has happened already a few time that I really wished there was the possibility to set the LFO's tempo via a CV. You could perhaps hack your way around the range switching by letting the pico address one osc for the lower range and the other osc for the higher range? That's a good idea! I'll try that out as soon as my next 2OSC/d arrives... I think I fried the top half of my current one with some wild voltages... yeah, outside of 5v, oops.
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Mar 23, 2022 15:10:14 GMT
Still soldering the permanent circuit. Here's what it goes in:
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Apr 4, 2022 14:46:33 GMT
So very close! They soldered circuit works, both contacts are scanned, I hooked up a second channel of CV from zero to 4 volts for velocity and can patch that into a VCA. I can make loud presses and quieter presses of the keys! But. Repeated presses are irregular. The timing of the keyboard scan is too loose. I think I was too clever in my circuit, having both a 1 of 8 decoder cycle through rows and also a couple of 1 of 8 multiplexers cycle through the columns to read the values... if I dedicate more input pins to the columns the pico can read all the results of a row at once giving me an 8x speedup of the scan rate. Perhaps that and some code optimizations will get me the smooth playing that I want. Good thing I put those chips in sockets.
|
|
|
Post by keurslagerkurt on Apr 4, 2022 14:58:57 GMT
What a beauty!!!
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Apr 4, 2022 17:31:43 GMT
oh wait... the pico has two cores and I am only using one. Maybe if I put the matrix scan on its own core in a tight loop that will clear out the irregularities. Back to the c/c++ sdk!
|
|
|
Post by pt3r on Apr 4, 2022 20:45:26 GMT
This just gets better and better, very impressive build.
|
|
|
Post by keurslagerkurt on Apr 5, 2022 11:36:03 GMT
oh wait... the pico has two cores and I am only using one. Maybe if I put the matrix scan on its own core in a tight loop that will clear out the irregularities. Back to the c/c++ sdk! Yeah the pico is quite incredible. Also might be worth checking out the GPIO state machines, which are super good at handling ultra-tight loops and work completely independent from the two cores. Info can be a bit scarce, although the datasheet is def pretty elaborate on them. This video is also quite an interesting first look:
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Apr 9, 2022 0:32:51 GMT
The circuit is saved! Using the other core took care of the timing issues. Now I can play softly or loudly and the velocity of the key comes out as proportional voltage. I'm working on the sensitivity curve but that's just a lookup table and nothing to fret over. And since I have four analog outputs on this circuit I can have it be monophonic with velocity and two other mod signals (pedal? Pitch bend wheel? Hmm...) or duophonic with velocity, or quadraphonic without velocity. I also received some more modules and now I can make two complete voices for duophonic playing: I damaged the 2OSC/d at the far left and so I'm not using it here. Anybody know what itty-bitty little component might blow and cause just one of the two oscillators to switch between high and inaudible instead of low and high like it's perfectly operating sibling on the same module? Tangible Waves modules are inexpensive enough that I'm not really worried about it, I have another on the way. My only problem now is that the keybed scanner and midi module I have built is too big. Clearly it is time to break out KiCAD and whip up a pcb design.
|
|
pol
Wiki Editors
Posts: 1,365
|
Post by pol on Apr 14, 2022 20:30:51 GMT
Impressive stuff, well doen, any chance of a video of it being played?
|
|
|
Post by keurslagerkurt on Apr 15, 2022 8:04:58 GMT
The circuit is saved! Using the other core took care of the timing issues. Now I can play softly or loudly and the velocity of the key comes out as proportional voltage. I'm working on the sensitivity curve but that's just a lookup table and nothing to fret over. And since I have four analog outputs on this circuit I can have it be monophonic with velocity and two other mod signals (pedal? Pitch bend wheel? Hmm...) or duophonic with velocity, or quadraphonic without velocity. I also received some more modules and now I can make two complete voices for duophonic playing: <button disabled="" class="c-attachment-insert--linked o-btn--sm">Attachment Deleted</button> I damaged the 2OSC/d at the far left and so I'm not using it here. Anybody know what itty-bitty little component might blow and cause just one of the two oscillators to switch between high and inaudible instead of low and high like it's perfectly operating sibling on the same module? Tangible Waves modules are inexpensive enough that I'm not really worried about it, I have another on the way. My only problem now is that the keybed scanner and midi module I have built is too big. Clearly it is time to break out KiCAD and whip up a pcb design. Congrats, thats an incredible achievement honestly! Regarding the 2Osc, not really sure, but if you still get sound but its pitched higher, i would suppose the charging capacitor of the Osc circuit got hit. If the IC's got hit, you would probably not get any signal out.
|
|
|
Post by rodney on Apr 15, 2022 11:58:28 GMT
We are not worthy! m(_ _)m
|
|
chuck
New Member
Posts: 40
|
Post by chuck on Apr 15, 2022 13:49:13 GMT
Impressive stuff, well doen, any chance of a video of it being played? ... you mean these things are for making music? Be prepared for some very mediocre keyboarding skills and it may take some time to figure out how to take, upload, and post a video but okay, you asked for it!
|
|
pol
Wiki Editors
Posts: 1,365
|
Post by pol on Apr 15, 2022 16:13:57 GMT
Impressive stuff, well doen, any chance of a video of it being played? ... you mean these things are for making music? Be prepared for some very mediocre keyboarding skills and it may take some time to figure out how to take, upload, and post a video but okay, you asked for it! If I can do it, anyone can, . Do pm me if you'd like some help (not with the keyboard skills, mine aren't great either!)
|
|
|
Post by rodney on May 26, 2022 14:51:46 GMT
We are not worthy! m(_ _)m As someone else said, this just keeps getting better!
... and I am searching for an even more humble emoji than the above (Japanese old-school emoji representing someone prostrated before you with their knuckles and forehead touching the ground m(_ _)m ).
It's inspiring me to figure out my next step in keyboard hacking.
I think that, for the computer keyboard idea, I'll start by seeing if I can fit two of the plastic switch arrays in the one keyboard unit, then do a test of whether there is in fact a consistent delay between the two layers switching.
Then I'll look at whether it is possible to simply use the two existing USB and scanning circuits from both keyboards together and simply compare their timing. That would be too easy, and I suspect a few problems there.
If that fails, I'll start religiously studying your circuit and software.
The other chips I am curious about are the PSoC series by Infineon (formerly Cyprus). They have programable hardware blocks, a bit like FPGAs, that let you set up some operations outside the main processing unit (in this case, the Cortex M-series processors). I have a demo board for the PSoc6 and an old one for the PSoC4, but I'm a bit overwhelmed by their complex toolchain(s).
The other thing I want to try is to 'simply' use two rows of the standard midi keyboard velocity sensing switch pairs used in MIDI keyboards. Luckily, I have found a few on the street lately. I also have a 3D printer, and access to better ones through a local university.
|
|
chuck
New Member
Posts: 40
|
Post by chuck on May 26, 2022 19:28:53 GMT
rodney pol I'm just hacking together circuits and code I've scavenged from other people... I appreciate your interest though! The keybed scanner is just sweeping two sets of contacts at the same time and I found that after I got the frequency of the scan up to over a megahertz (I think I'm at 8 at the moment) and not randomly paused by other activity I was able to get useful times between contact one and contact two that I could turn into velocity values. Since I have 64 keys that means there's only a brief window on the scope for any one key's voltages to settle in the sweep. I had to use a sequence of 'NOP' delays rather than an sdk function call to get the precise timing I wanted on a core I set to do just the scan. I'm still refining the code. If I need more precision than this I can split the keys into groups of 32 or 16 I suppose... at the expense of using more input pins to be read in parallel. In looking at parts on the Internet I see that almost all velocity sensitive keybeds today use rubber strips with contacts on them, pressed down by the force of the key lever, one contact making a connection just before the other, like this replacement part I ordered: The controller I built has four analog outputs so I can produce 1, 2, or 4 volt-per-octave notes at the same time. Four separate digital outputs provide the gate for the notes. I need to install a switch so I can choose 1 2 or 4 notes on the fly. Before I had it putting out two notes, each with a velocity value but since I got another 2OSC/d I've been playing it with 4 note polyphony but no velocity. The rp2040 is powerful and cheap! Much like AE!
|
|
|
Post by pt3r on May 27, 2022 7:51:33 GMT
No need to be so modest about your accomplishments, we are all building on shoulders of giants. This is such a fascinating project, not sure I can provide a lot of technical support so I'm mostly lurking and rooting for you but I was wondering If you could put another 4 analog outputs and 4VCA module in there then you can of course patch 4 note velocity and velocity.
|
|
chuck
New Member
Posts: 40
|
Post by chuck on May 27, 2022 23:31:31 GMT
No need to be so modest about your accomplishments, we are all building on shoulders of giants. This is such a fascinating project, not sure I can provide a lot of technical support so I'm mostly lurking and rooting for you but I was wondering If you could put another 4 analog outputs and 4VCA module in there then you can of course patch 4 note velocity and velocity. Yes indeed... it's just another 4 channel DAC module, easy to wire up. But maybe I'll take this to the next level and draft up a pcb. I have a need for more keyboard scanners and midi dac outputs... three more of them at least. I have a big old church organ with two manuals and a full pedal-board that I need to "upgrade." I might be biting off more than I can chew. We'll see. The bit in the middle is the most worrisome part (the rp2040.) I've barely started with the connection it needs and the schematic needs more parts for output. The bottom is a replica of the scanner I currently use, just smt instead of strip-board.
|
|