Digital piano build - Page 1
Forum section: electronics / projects

author: TedWakeshaw
author_rank: Newbie
timestamp: September 17, 2024, 10:12:15 am
content: Hi everyone,Some time ago, I started building a digital piano. The project is based on a Teensy 4.1 board. The main idea is to create a fully functional, full-size digital piano with velocity sensitive, weighted keys. The Teensy 4.1 will serve as the MIDI controller, and a Raspberry Pi will act as the MIDI synthesizer. Each key will have three sensors.At the moment, I’m working on a keyboard with single sensors per key, so there’s no dynamic response yet. To obtain multiple inputs, I’m using 74HC166 shift registers connected in series (eventually, there will be 3 rows of these registers).If anyone is interested, here’s a link to a video showing the build process:I’ve run into a small issue at this stage. Sometimes the keyboard works fine, but occasionally some keys randomly start repeating by themselves, or pressing one key triggers multiple notes at once. Any ideas what might be causing this? Below is the source code:Code:#define ioSelect 8#define clockPulse 9#define dataOut 10int note;int noteState;int edgeTestSteps = 300;int edgeTestStep;int edgeState;int j;void setup() {pinMode(ioSelect, OUTPUT);pinMode(clockPulse, OUTPUT);pinMode(dataOut, INPUT);}void pianoKeys(){digitalWriteFast(ioSelect, 0);digitalWriteFast(clockPulse, 0);digitalWriteFast(clockPulse, 1);digitalWriteFast(ioSelect, 1);for(j = 0; j < 88; j++){delayNanoseconds(200);note = 21 + j;if (digitalReadFast(dataOut)){if (noteState == 0){if (edgeState == 1){edgeTestStep++;}else{edgeTestStep = 1;edgeState = 1;}if (edgeTestStep > edgeTestSteps) {usbMIDI.sendNoteOn(note, 69, 1);noteState = 1;edgeTestStep = 1;}}}else{if (noteState == 1){if (edgeState == 0){edgeTestStep++;}else{edgeTestStep = 0;edgeState = 0;}if (edgeTestStep > edgeTestSteps) {usbMIDI.sendNoteOff(note, 1, 1);noteState = 0;edgeTestStep = 0;}}}digitalWriteFast(clockPulse, 0);delayNanoseconds(10);digitalWriteFast(clockPulse, 1);}}void loop(){pianoKeys();}Any comments and suggestions are welcome!

author: Phil1977
author_rank: Frequent Contributor
timestamp: September 17, 2024, 10:27:39 am
content: Nice project!Can you post a sketch of the whole button circuit? Of everything that´s behind the shift register, including the power connection of the buttons?I´m quite sure it´s about some parasitic capacitive or inductive coupling between or towards your buttons. Do you have a scope available to measure the voltage slope when a button is pressed?

author: moffy
author_rank: Super Contributor
timestamp: September 17, 2024, 11:17:53 am
content: If you are using a switch type sensor per key at present, you will need to debounce them, switches don't open or close cleanly, they bounce between open and closed before finally settling. Unfortunately with the hammer mechanism that mechanical/electrical oscillation might be prolonged and give false readings. The judicious use of capacitors per switch usually helps, it would also help with the crosstalk if that is the cause of multiple notes being triggered, but it might also be mechanical vibration being coupled to the other switches when a key is pressed hard.

author: PGPG
author_rank: Frequent Contributor
timestamp: September 17, 2024, 11:58:42 am
content: My experience is that if any electronic device behaves differently than you expect the most probable source are problem with capacitors.Looking at your PCB I don't see any blocking capacitors.Each digital IC should have blocking capacitor (like 100nF) connected between its VCC and GND pin with as short as possible connection. Without them digital circuits can do everything you would never expect from them.My suggestion - consider making all in SMD technology. Hand soldering SMD (like SO14 and 0603) is even easier than working with THT elements. You need not to revert PCB when soldering.Well designed PCB (with one layer being whole GND) will be more robust against any disturbance (try to use cellphone near your piano PCBs).You can design PCBs using KiCad (free PCB design software).And local information (you of course like most people here can use china manufacturers).Typically once per month 'technoservice' have a PCB-day. Orders from such days have special price.Standard orders - you pay lot (I don't know actual prices) for preparing documentation for your PCB, but next time (even years later) you can order thousands of the same PCB paying only for cm².Prototype orders - you pay much less for preparing documentation (not sure - may be around 80PLN) but more for cm². Number of the same PCB in prototype order is probably limited but you can make a PCB containing many of your PCBs and it is for them one ordered PCB (times that limited number). They don't keep your documentation - next time you pay once more for it. They simply put many orders together for manufacturing so can't repeat only yours.Nearest PCB day is 19.09. You pay 1PLN for processing costs for prototype orders.As I remember all PCB days were always at Thursday. You can try to ask them.I can't find it at their homepage (may be I'm trying at some old page - its not me who orders our PCBs - I'm little lost in their www) but I have link from mail they send to us:https://app.getresponse.com/view.html?x=a62b&m=Boydbv&mc=Id&s=BrsZtks&u=MDVgB&z=EQdlwGn&Edit.It looks that they simply have not up to date news on their site (tspcb.pl). I have send them a message about it.

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2024, 12:58:15 pm
content: The capacitors recommended by PGPG are also called decoupling/bypass capacitors.This blog post has a good explanation of why and how to use them:https://www.vagrearg.org/content/decouplingand includes this pic of of a suggested method of including them on a breadboard:

author: TedWakeshaw
author_rank: Newbie
timestamp: September 18, 2024, 09:41:47 am
content: Thank you all for your responses.Quote from: Phil1977 on September 17, 2024, 10:27:39 amThank you for your kind words.Quote from: Phil1977 on September 17, 2024, 10:27:39 amUnfortunately, I don't have a scope.Quote from: moffy on September 17, 2024, 11:17:53 amActually, I’ve implemented a kind of debounce:Code:if (edgeTestStep > edgeTestSteps) {usbMIDI.sendNoteOn(note, 69, 1);noteState = 1;edgeTestStep = 1;}The MIDI note is not triggered until the same input state is confirmed 300 times in a row. So, it's probably not that. I'm pretty sure bouncing would manifest differently.@PGPGThank you for the detailed response. Those capacitors make a lot of sense. I did some reading on the subject, and I'm almost certain this is the cause, especially since I have 11 shift registers connected in series, and the power for the next one is taken from the previous one. I measured the supply voltage on each shift register, and the voltage drops with each subsequent one. On the last shift register, the voltage drop is significant, and the problems usually occur with the later shift registers. I’ll try running a separate power line with thicker wires and solder a decoupling capacitor to each shift register.Quote from: PGPG on September 17, 2024, 11:58:42 amI'm not a fan of SMD, but maybe I’ll come around someday. I guess I’m a bit old-fashioned and conservativeQuote from: ledtester on September 17, 2024, 12:58:15 pmThank you for the link. Very interesting and useful post.

author: PGPG
author_rank: Frequent Contributor
timestamp: September 18, 2024, 12:39:07 pm
content: Quote from: TedWakeshaw on September 18, 2024, 09:41:47 amScope is 'must have'. For me it was so 'must have' that to have it I have designed and build one in 1982 (you can find its description here:https://archive.org/details/Re0184OCR/Re_04_84_OCR/page/n5/mode/2up).Nowadays, for not a lot of money, you can have scope that I couldn't even dream those time. If not 'true scope' than at least USB scope.Quote from: TedWakeshaw on September 18, 2024, 09:41:47 amVoltage drop that you see is not the main problem. Problem are short current pulses (ns range times) taken by ICs when they switch their state (you can't see them with voltmeter). This current pulses generate short voltage drop at supply. But not the wire resistance is the main factor but the wire inductance (the longer distance from supply (supply certainly have capacitor at its output) the higher inductance).I'm sure that adding capacitors to each IC without changing wires will solve your problem. But of course if you see too big voltage drop at wire it is worth to change them.Quote from: TedWakeshaw on September 18, 2024, 09:41:47 amFor prototype like assembling THT is better, but when you design PCB for your device than SMD is much better. Try once and you will not get back to using THT in design. I have changed from THT to SMD around 1990.

author: Phil1977
author_rank: Frequent Contributor
timestamp: September 18, 2024, 01:21:55 pm
content: It would really help if you would sketch your button circuit out. It helps you to understand what's happening and it helps us to explain.Adding capacitors is one important step and may be enough to get rid of the worst problems. But if you want the piano to flawlessly detect the key inputs then you really should think about reasonable dimensioning of caps and resistors. A standard pull-up or pull-down resistor for example may have a huge tolerance on a breadboard test design but that doesn't mean any arbitrary value will be suited for reliable operation.I think you really can get a lot of useful information in this forum, and especially hands-on-projects are usually really well supported. But you need to give some starting points like all the connections of the key contacts to power rails and shift registers.

author: ledtester
author_rank: Super Contributor
timestamp: September 18, 2024, 05:04:25 pm
content: Quote from: Phil1977 on September 18, 2024, 01:21:55 pmFrom the video it looks like a standard daisy-chain of 74hc166 shift registers. Each protoboard consists of three '166 chips and it looks like there are four such boards. There are 10K pull-ups (or pull-downs) on the shift register inputs (at 19:22 in the video.)At 25:47 you can see how the keys work:https://youtu.be/jvl6SZLRJpM?t=25m47sWhen a key is depressed it lifts a wire off of a rod that runs the length of the keyboard. The rod is probably grounded and so the 10K pull-up presents a HIGH signal to a shift register input.The signals running between the protoboards would have to be: power, ground, SH/LD, CLK and SER/QH.

author: dietert1
author_rank: Super Contributor
timestamp: September 18, 2024, 05:14:55 pm
content: A nice build! As a boy i made something similar for an analog synthesizer together with a friend. We wanted to be a band.For sensing the dynamics one would need analog position sensing for each key. Something cheap like an IR sensor. The shift registers would get replaced by multiplexers, probably with some buffer amplifier to drive the cables.Regards, Dieter

author: nctnico
author_rank: Super Contributor
timestamp: September 18, 2024, 06:13:31 pm
content: Nice to see people are still interested in this kind of projects. I've built something similar nearly 30 years agoBut I used a matrix to scan the keys. Much less electronics and wiring.Velocity sensing is typically done by measuring the time between opening and closing the contacts on each key (each key has a normally open and normally closed contact).

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 18, 2024, 06:23:21 pm
content: Quote from: dietert1 on September 18, 2024, 05:14:55 pmFor sensing the velocity there is no real need for analog signals. Just setup a scanning matrix with two bars per section and check per key if it is on the lower bar or the upper bar or in between. When it leaves the bottom bar start a count, or read a timer value and when it touches the top bar stop the count or read the timer value again and subtract the two to get the elapsed time. Scale it to get a proper velocity value.The attached image shows how this is done in the Siel Opera 6. There it is scanned with an old eight bit microcontroller, so with a modern day MCU it should be a piece of cake.Another more advanced option to also get polyphonic after touch as well as the velocity an analog hall sensor can be used. Stick a magnet underneath each key and position analog hall effect sensors underneath. Scan the analog signals with a MCU and set values for upper, lower and after touch positions. When a value passes a set value take action to measure the velocity or the after touch.

author: ledtester
author_rank: Super Contributor
timestamp: September 18, 2024, 08:09:27 pm
content: The OP experiments with measuring velocity via the two switch contact approach in this video:https://youtu.be/WKrjwQOasvgand another person has a demo of the Hall effect sensor approach here:https://youtu.be/tgWXtYCHDI4

author: tooki
author_rank: Super Contributor
timestamp: September 18, 2024, 08:50:07 pm
content: You also might want to take a look at how Yamaha did the sensing in most of their AvantGrand digital pianos (which have a practically unmodified full piano action, just without strings). They use optical fibers to implement remote optical density sensing without adding bulk to the action. (The fibers shine light through a gradient on a moving flap, giving continuous position information, rather than just on-off sensing of multiple positions.) Apparently the newest models now use magnetic sensing, but I don't know whether it's binary or continuous.(A friend of mine, who is an accomplished recreational pianist, bought one (at his home in USA) after spendingover three hoursplaying them at the big music store here in Zurich. The salesman was apparently delighted to have such an enthusiast, even knowing that it would not result in a sale.)

author: Postal2
author_rank: Frequent Contributor
timestamp: September 18, 2024, 10:25:40 pm
content: In the Soviet set for children "musical keyboard Start-9069" (which I have), the pressing force is registered by means of 5 contacts that close in sequence when the key is moved.https://rw6ase.narod.ru/index1/konstr/rk_komplek/start9069.html

author: dietert1
author_rank: Super Contributor
timestamp: September 18, 2024, 11:15:01 pm
content: Just saw linear hall sensor TI DRV5053 at Digikey, € 40.53 for 100 pieces. In addition one needs the magnets. A cheap and pretty robust solution.Regards, Dieter

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 18, 2024, 11:57:58 pm
content: Quote from: tooki on September 18, 2024, 08:50:07 pmThere are increasing numbers of interesting opto sensors tooThis one from Vishay has 2 emitters and 4 PhotoTX to give a mix of linear and digital.and this one from Nisshinbo has reflective with lens, so is almost linear 0-4mmOther lens-reflective PhotoTX models are ITR1502SR40A/TR8 Everlight Elec and Sharp GP2S700HCPVishay also have a TCND5000, that is lens reflective, using PIN photodiode to remove PhotoTX HFE variations.

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 19, 2024, 05:52:32 am
content: A possible solution for using the hall effects is to make a PCB per octave that fits underneath the front of the keys. No need for analog multiplexers when a cheap MCU like for instance the STM32F103C8T6 is used. With the two ADC's it can read two keys at the same time and multiplex them over 6 channels each. With a sample rate of 100kSa/s per key it should be fast enough to get usable data for velocity and after touch.Then connect the boards in series via the available UARTS to send out the MIDI data. Have all but the last one send at the highest baud rate it can handle, which is many times the MIDI baud rate, and have the last one send it out at the normal MIDI baud rate.Needs some priority system on the data between the boards to not be swamped by after touch data, but that is not that hard to implement.Use a couple of pins to configure the octave the board is used for and another one to indicate it being the last one. This way the software can be the same for all the boards.

author: TedWakeshaw
author_rank: Newbie
timestamp: September 19, 2024, 11:47:44 am
content: Wow, I didn’t expect so much interest and so many posts on my thread! It looks like this forum has an amazing community.As I’m reading through your replies, I realize that even though I’ve been into electronics as a hobby for over 20 years, I feel like a total noob compared to you all!Quote from: PGPG on September 18, 2024, 12:39:07 pmI know, I’ve been thinking about getting a scope for almost 10 years now, but somehow I’ve managed to get by without one so far.Quote from: PGPG on September 18, 2024, 12:39:07 pmThat’s incredible! I’m impressed. I wasn’t even born yet at that time!Quote from: PGPG on September 18, 2024, 12:39:07 pmYeah, I get it. What I meant is that it seems like those short current pulses you're talking about might have a bigger impact when there’s a voltage drop. At least that’s how I understand it.As for SMD components, I’ve got hundreds, maybe even thousands of THT parts at home because I always end up buying some extras whenever I make a purchase. And guess how many SMD components I have? Exactly zero. This reminds me of the time I had to repair my mother-in-law’s plasma TV and had to drive across the whole city (Lodz) just to get one SMD resistorQuote from: Phil1977 on September 18, 2024, 01:21:55 pmLike ledtester said, the aluminum rod is grounded, and wires are constantly in contact with it. When a key is depressed, the wire is lifted from the rod. All the shift register inputs are connected to Vcc through 10k resistors. There are four PCBs—three of them have three shift registers each, and the last one has two.In the future, I plan to add two more rows of shift registers to measure the speed of the keys, like in this video:Quote from: ledtester on September 18, 2024, 08:09:27 pmI chose this method of connecting multiple keys instead of a matrix for easier programming and indexing of the keys. And since I managed to buy 40 shift registers for less than $40, I figured it was worth it. Initially, I considered optical sensors, but I went with the mechanical solution because it’s cheaper. The great thing about DIY projects is that you can always upgrade them later on!

author: nctnico
author_rank: Super Contributor
timestamp: September 19, 2024, 12:09:18 pm
content: For long term, an aluminium rod is not the best solution due to corrosion. Try to find a stainless steel rod and use stainless steel springs. Stainless steel wire for making springs is widely available as well. As stainless steel has some nickel in it, I expect this to last much longer compared to aluminium. However, using something like a micro-switch (without a click) would be more durable as the contacts are made from the proper materials.

author: Phil1977
author_rank: Frequent Contributor
timestamp: September 19, 2024, 12:37:24 pm
content: Thanks for the diagrams!For the very beginning I´d add two components per key:the 1k-resistor in the switch line reduces current peaks when the key is released. The capacitor should average out all bouncing <1ms while still keeping the latency for detection of a pressed key (open contact) <10ms.It´s just the first mod I would try - I´m sure others have other maybe better ideas. But it definitely should improve the reliability of the inputs.And as already mentioned: You should definitely put decoupling caps to the power rails. At least per shift register IC you should spend 1 cap, e.g. 100nF.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 19, 2024, 12:39:14 pm
content: Quote from: TedWakeshaw on September 19, 2024, 11:47:44 amNice idea for the key contacts!The same idea can be used to read the keys velocity, by adding a second contact for each key. The second switch is identical with the first contact, just that the tip must be bent a little more, such that the height (distance) between first and second contact opening is the same in all keys, so one switch will open a little later. How much later, is dictated by the key velocity.By measuring (in software) the time between the first switch and the second switch opening, the velocity/force of the keypress can be measured (to control the note volume).

author: BrianHG
author_rank: Super Contributor
timestamp: September 19, 2024, 12:40:19 pm
content: If you plan on keeping the aluminum rod and spring contacts, google:gold plating aluminum kitPlating both you springs and aluminum rod with a good thick layer will keep the contacts corrosion free.This will improve the aging consistency of your hardware switch solution.However, this most likely wont ultimately solve your signal bounce issue. Though, it may be possible to solve this with software if your switch contacts and signal ground are clean throughout.As others have pointed out, a scope is a must to inspect exactly what is going on.Even a sub 100$ toy oscilloscope (not recommended) would still at least show you some details in the low frequency domain of a mechanical switch.As others have pointed out, if you were to go to hall-effect magnetic sensors with a small magnet on each key, there would be 0 contacts to ever break down or wear out. Also, if you replaced the cmos digital serializers with something like an MCU with multiple ADC inputs reading each sensor, you could then determine velocity and depth of each key press if you wanted to engineer such a capable keyboard.

author: PGPG
author_rank: Frequent Contributor
timestamp: September 19, 2024, 02:32:26 pm
content: Quote from: TedWakeshaw on September 19, 2024, 11:47:44 amWhere you have smaller voltage you have also longer distance from supply. I think that this distance in sense of wire inductance have bigger influence than DC voltage being smaller.You use HC serie. 2V is enough for them to work.Quote from: TedWakeshaw on September 19, 2024, 11:47:44 amIn 70s and 80s I was collecting elements as it was not possible to buy what you need but you could only buy what just was at the moment accessible. Having a big set of elements was the only way to go. All my designs were made to use only elements I just have because in other way it could took me years to get the part I need. Even my oscilloscope was designed only with elements I had bought in past not knowing what for they will be used. This way I had a big collection of elements I have never used.About 10 years ago I throw away most of my old THT elements to make room in my matchbox cabinets for modern elements.Quote from: Phil1977 on September 19, 2024, 12:37:24 pmIf 10k would be at switch side of 1k you will be driving IC input with true 0 and not 1/11 of VCC.Then you could replace 1k with 100k and 47n with 470p to make both state changes with almost the same time constant.

author: TedWakeshaw
author_rank: Newbie
timestamp: September 20, 2024, 08:33:29 am
content: Quote from: nctnico on September 19, 2024, 12:09:18 pmI'm aware of that. The springs are made of stainless steel. I was thinking about sanding down the rod with sandpaper and coating it with graphite paint, but I'm not sure if it will stick.Quote from: Phil1977 on September 19, 2024, 12:37:24 pmI'm very grateful for your suggestions.Quote from: RoGeorge on September 19, 2024, 12:39:14 pmThe wire I used is quite flexible, and it would be difficult to maintain even spacing between them. I have a different idea for measuring velocity.Quote from: PGPG on September 19, 2024, 02:32:26 pmI wish I could understand what you wrote.

author: Phil1977
author_rank: Frequent Contributor
timestamp: September 20, 2024, 08:57:03 am
content: QuotePGPG link proposed to further modify the resistance values to smaller currents and to corresponding lower capacitances. That´s for sure possible but I can't see a strict necessity for it.With the circuit I proposed your low-level (pressed key) is 1/11 of VCC due to the ratio of the resistors. But that´s absolutely okay, for a 5V-system that means it´s slightly less than 0.5V, and everything below 1.35V is guaranteed to be detected as low by the shift register IC.

author: PGPG
author_rank: Frequent Contributor
timestamp: September 20, 2024, 12:21:18 pm
content: Quote from: TedWakeshaw on September 20, 2024, 08:33:29 amI wanted to show you step by step these operations but I have never inserted a graphic at this forum and I see I don't know how to do it.I have experience only with KiCad forum and there I simply drag-drop file on my post and done. Never had any problem with it.Here.Dragging picture at post - not works.I opened under post "Attachments and other options" and sometimes when I used "Select file" it was added under this box and box all the time said "File not selected".At the end I managed to have there three lines in each I have file specified (I got it there by "Select file" and "Show all files" and then clicking my file.In each line I have selected "Inline full-size image" and at the end of my message I have commands attachimg one by one starting from 1 to 3 (and my files have names ending with 1..3 in the same order, but in preview I have as attachment 1 info that here is C:\fakepath\Piano_2.png, but Piano_2 was selected for second attachment and not for first and C:\fakepath is not existing at my PC. Then as attachment 2 the same way is my Piano_3.png listed and then when I would expect attachment 3 I see info "Specified attachment is not availabe" what can be supposed is related to my first attachment that should be before those two. All files were selected by me the same way. Seeing difference I have selected them all once more time step by step.Let us see what will be really shown.[ Specified attachment is not available ]Editing after posting.I'm surprised that my attachimg=2 and attachimg=3 are shown as first and second (even in preview I see C:\fakepath) and still don't know what is wrong with my attachimg =1 (that should be before them).So first picture that was a copy of original is simply not visible but those two are two steps previously described by me in text. I wanted to write the right sentences between them but now I don't know which text would be shown where as someway forum software sorts my attachimg differently than I see them in my post text.

author: tooki
author_rank: Super Contributor
timestamp: September 21, 2024, 11:27:04 am
content: Quote from: PGPG on September 20, 2024, 12:21:18 pmThis forum’s image handling is quite bad, so I have mostly given up trying to put them inline while writing. Most of the time I simply leave them as attachments and refer to them by name in the text, and if I reeeeeallly need them inline, then I do the inline tags as an edit afterwards. (I.e. post the message first, so that the attachments are uploaded and their order becomes known, then go back and edit the post.)

author: NiHaoMike
author_rank: Super Contributor
timestamp: September 21, 2024, 01:13:45 pm
content: Have you considered using computer keyboard switches? Those are already optimized for a similar application.Quote from: TedWakeshaw on September 19, 2024, 11:47:44 amGet a "LHT00SU1" scope + logic analyzer for about $25, used with the free software Sigrok. It's desirable to have one even if you have a nice scope since the record length is only limited by how much RAM your PC has.

author: PGPG
author_rank: Frequent Contributor
timestamp: September 21, 2024, 02:08:56 pm
content: Quote from: tooki on September 21, 2024, 11:27:04 amGood to know. I supposed it is only me having a problem with something that should simply be simple.I suppose (but didn't checked) that may be the reason of my problems was that my files were at drive D:\...\...\...\MyFile.png and after inserting got path C:\fakepath\MyFile.png like software didn't understand that there are more drives than only C: but even having there (in preview) fakepath it found them (only 2 from 3).By the way.I didn't found the way to select part of somebodys text and then Quote it (only what I have selected). Is it possible or the only way is to quote all and delete what is not needed?

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 21, 2024, 02:51:29 pm
content: Quote from: PGPG on September 21, 2024, 02:08:56 pmThat is what I do too. Delete what is not needed. Have not found another option yet. To split something into separate sections I copy the [quote ..... line.

author: PGPG
author_rank: Frequent Contributor
timestamp: September 21, 2024, 07:20:56 pm
content: Quote from: pcprogrammer on September 21, 2024, 02:51:29 pmI am really surprised. Before recently coming here I was only at one forum (KiCad since 2017). There I just select few words I want to answer for and click Quote and I have them quoted in new post (or in currently edited). If want to add picture, link or zipped project I just drag or copy what I need on my post and I see at once how my post will look like (need not to press Preview).I came here because if someone asks there electronic question he is told that it is wrong place for his question and he should ask it here.Here are much more people than there so for me it's really weird that forum software is hard to be used. It practically discourages writing.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 21, 2024, 07:42:45 pm
content: I see a (probably temporary) circuit built on some matrix board, and that combined with long cables ("long" here is >100mm) is a bad combination. I also do not see any decoupling capacitors on that PCB, which makes the combination even worse.I suggest you:1. Add decoupling capacitors to those matrix PCB's.2. Replace all connectors with IDC headers with at least twice as much pins, and then connect all the odd (or the even) pins to GND. This sort of shields the (presumably) TTL level signals over those cables.Connecting all odd (or even) pins on an IDC connector is very easy on matrix PCB. Just solder a long wire over one row of the pins.Do you have an oscilloscope? I guess that reflections and GND bounce and interference / EMC on those long cables with TTL signals will be horrible. Probably it helps if you put 50 to 100 Ohm resistors in series with the outputs of all the TTL IC's. Together with the cable impedance these form a lowpass filter and dampen nasty effects.Some 20 years ago I built an Eprom programmer connected to an LPT port, and it completely drove me crasy why it did not work. It was mostly TTL IC's on matrix board, but it did have plenty of decoupling capacitors. After a few days of head scratching I built a second PCB, which had exactly the same symptoms. In the end I fixed it (both PCB's) by adding a 10nF capacitor to a signal over the LPT bus that was used as a latch for the TTL chips. Without that capacitor, it did not work reliably at all. With the 10nF capacitor it did work reliably, but only with an LPT cable of upto 1 meter. If I used a longer cable it picked up too much crosstalk and it overwhelmed that capacitor. Back then I did not have an oscilloscope. If you don't have an oscilloscope, go buy one first. Those things are indispensable when designing electronics, even for digital stuff like uC hardware and TTL stuff.

author: ledtester
author_rank: Super Contributor
timestamp: September 21, 2024, 07:58:57 pm
content: Quote from: Doctorandus_P on September 21, 2024, 07:42:45 pmThere are only three or so digital signals between the boards. Would using a twisted pair for each signal help (each signal paired with a ground wire)?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 21, 2024, 09:24:06 pm
content: Twisting the wires would probably also help a bit, but mostly because capacitive coupling is less when the wires are twisted (compared to a flatcable). If you want to go really fancy, you can use RS485 or CAN drivers for twisted pairs and use real differential signalling, That would be good for long distances but it's much overkill here.But I'm no expert at signal integrity. If you want to know for sure, then buy a real scope and measure it (The toy scopes below EUR150 are fun, but not trustworthy enough to do any real work. I'm still amazed and flabbergasted by the amount of scope I got when investing EUR450 into a Siglent SDS1104X-E. If you're tight on budget you can limit yourself to two channels (which I consider the minimum) and still have a decent scope for EUR 300.Earlier in this thread the LHT00SU1 It's a fun thing for EUR 35 (USBee clone, compatibility with Sigrok / Pulseview apparently), but I doubt very much that you will see on it what sort of a mess a TTL IC driving a meter of wire generates. I don't know how much latency you can tolerate with audio, but a low signalling frequncy combined with heavy enough filtering to dull the edges of the signals may be an option too.

author: BrianHG
author_rank: Super Contributor
timestamp: September 21, 2024, 09:32:39 pm
content: has anyone considered using an old cmos CD4014 with a 15v supply instead.Use a 220k pullup and 220k series to the smoothing cap at each input pin.The 4000 series cmos powered at 15 volt will require a significant 7 volt swing at each input to toggle from a logic 1 to logic 0.Unlike the 5v powered 74HCxxx logic variant which toggles with a 2.5v swing.You will will need a logic level shifter for the final serial link to the MCU board.

author: ledtester
author_rank: Super Contributor
timestamp: September 21, 2024, 10:44:35 pm
content: Quote from: BrianHG on September 21, 2024, 09:32:39 pmThe OP is using a Teensy 4.1 mcu board so Vcc is likely to be 3.3V.

author: BrianHG
author_rank: Super Contributor
timestamp: September 22, 2024, 03:07:24 am
content: Quote from: ledtester on September 21, 2024, 10:44:35 pmSo, an approximate 1.6v swing for the 74HCxxx series.

author: Phil1977
author_rank: Frequent Contributor
timestamp: September 22, 2024, 05:58:09 am
content: Please don't intimidate anyone with things that make it too complicated!Timing integrity needs to be around 1ms, the used improvised button contacts will definitely not do better.That means 10kHz of bandwidth per line are more than sufficient - and any higher frequency is anyhow filtered away by the proposed RC-filter (the combination of resistor and capacitor defines the simplest possible frequency filter - that´s why it´s called RC-filter.)10kHz does neither need twisted pairs nor termination. It´s also no super high impedant input with the 10k-resistors. Probably super simple cabling as used by the OP is just fine.It may be a good idea to use a twisted pair of cable (GND+signal) for the digital communication between the shift registers and the MCU.And I personally like the low-key attitude the OP shows in his video. It´s nice to see you can do electronics also with simple methods like hand soldering and improvised buttons. Of course, *everything* could be engineered in a better way. But I think projects like this can be more inspiring if you see they are accessible without CAD- and FEM-designs or special components and materials.

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 22, 2024, 06:19:19 am
content: Quote from: Phil1977 on September 22, 2024, 05:58:09 amTo determine velocity you will need higher speeds than that 1ms.A single note on message takes 1ms to send, so detecting a key press needs to be done with at least that speed, which for an 88 key piano means the scanning rate needs to be at minimum 88kHz. Still relatively slow, but for better performance I would double that speed.Still no need to take a lot of special measures, but being aware of possible shortcomings never hurts when something starts to give problems. And that is what the OP is having, problems.The responses on this forum do seem to intimidate beginners and amateurs though. The OP has not returned to follow up after the first page. I have seen this with many threads.

author: Phil1977
author_rank: Frequent Contributor
timestamp: September 22, 2024, 06:48:15 am
content: Quote from: pcprogrammer on September 22, 2024, 06:19:19 amYes, but as far as I understood the OP the velocity detection is just an option for the future and he hasn't decided what system (two step, analogue force detection, ...) he wants to use for that.And I think he just isn't active 24/7 but he is reacting to this thread

author: TedWakeshaw
author_rank: Newbie
timestamp: September 23, 2024, 08:16:09 am
content: Quote from: pcprogrammer on September 22, 2024, 06:19:19 amThe responses do not intimidate me. Yes, it's true that digital electronics is relatively new to me. I haven’t posted anything in the thread lately because there’s just so much to take in, and I need time to process it all. From the sources I studied, everything seemed so simple and straightforward, and I didn’t realize there could be so many issues with what appears to be a simple digital signal. I’m reading all the replies, trying to understand, and thinking about how to improve things based on your suggestions. I’m really grateful to everyone who has taken the time to contribute to this thread, and I truly appreciate every response and the willingness to help. I have a lot to learn, and I need time for that—time which I don’t always have as much of as I’d like.

author: dietert1
author_rank: Super Contributor
timestamp: January 05, 2025, 01:35:48 pm
content: Just happened to view this nice video:Regards, Dieter

author: dietert1
author_rank: Super Contributor
timestamp: September 28, 2025, 01:42:41 pm
content: Recently we bought a YAMAHA PSR E383 keyboard. It's an entry level product, but already with touch sensistive keys, that means it will produce different sound levels depending on how rapid a key is pressed. It simulates a traditional mechanical piano, except the version we got has less keys (5 instead of 7+ octaves). We paid R$ 1550 (about 250 €).After using it for some weeks i have a comment: I would no longer recommend to try a DIY build. Even if one succeeds to make a useable touch sensitive keyboard, the YAMAHA product is still far superior to anything one can DIY as it includes a very sophisticated firmware with Midi and audio support etc etc. Just amazing!The web finds offers for Yamaha replacement parts, so one can get an idea how it works.Regards, Dieter

author: tooki
author_rank: Super Contributor
timestamp: September 29, 2025, 04:02:48 pm
content: Quote from: dietert1 on September 28, 2025, 01:42:41 pmIs that in any way surprising? Yamaha has been making musical keyboards since 1974 (and simpler electronic organs since 1959!), so they’ve had literally decades to develop them, including cost reduction, and of course enormous expertise.Like so many DIY electronics projects today, doing it yourself is something you do for the fun of it, not because it makes even 1% logical or economic sense!

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 29, 2025, 04:31:03 pm
content: Indeed. Getting anywhere close to the performance and quality of even an old Yamaha synth would be a huge project spanning years and years and probably thousands of bucks along the way.But you usually don't do it for saving money.But when it comes to synths, these days you can absolutely DIY the sound generation part, possibly with your own algorithms if you feel like it (or just reproduce existing ones), for a pretty low cost.The expensive side would be all the mechanical parts, especially of a keyboard: but unless you're really into keyboards themselves, it would make indeed little sense to DIY one. You'd buy an existing MIDI keyboard controller and can DIY sound synthesizing to your heart's content with relatively inexpensive hardware.

author: dietert1
author_rank: Super Contributor
timestamp: September 29, 2025, 11:56:00 pm
content: There seem to be open source midi parsers on the web, for example:https://github.com/abique/midi-parser. I did not try that yet, but i assume one can receive the keyboard events using that method. The YAMAHA keyboard supports Midi output over a USB connection.I managed to use the keyboard to play midi files that i downloaded from the web. As the keyboard specs 650 built-in voices it has everything necessary to produce realistic sound of a complete orchestra. I tried about 100 examples with quite impressive results.In order to make that work on a Win10 computer i installed 'Coolsoft MidiMapper 2.1.2' as MS Windows itself no longer supports routing Midi streams to connected devices, but always wants to use its own sound generator.I think i also installed a YAMAHA driver to get the "Digital Keyboard" Midi device.Regards, Dieter