Improving PWM on a DIY Player piano - Page 1
Forum section: electronics / projects

author: jord4231
author_rank: Regular Contributor
timestamp: May 04, 2021, 07:48:54 pm
content: I'm looking for some ideas please.Recently I have completed converting a regular upright piano in to a player piano.It uses 88 24v solenoids that press the back of a piano key directly under the point where the mechanical action of the piano operates.The solenoids are connected to shift registers (via a npn transistor) the shift registers are driven by an arduino that receives midi commands.This all works ok however I find the fastest pwm frequency I can get is around 100hz. I feel this is a limitation of the arduino driving the 11 x 74HC595 .This is not a problem if I am wanting to play full velocity notes, when I want to play softer or lower velocity notes I tend to find the solenoids will not fire or if they do they buzz loudly... too slower of a frequency I feel I need to be up around 100khz or so.So I'm looking for some ideas to speed things up.Ideally I'd like to continue using the shift register boards as all the transistors are soldered on to that board, quite a lot of them...My thoughts so far are1 Replace the arduino with something faster2 Use a separate micro controllers for each of the shift register boards, maybe this will help dedicate more speed to each shift register board?3 Replace the shift registers with dedicated multi channel pwm boards - last resort.I'm sure that someone here will have a cleaver idea or two any help or tips would be great!This is a link to the piano in action. I have since completed it but have not yet taken any video.https://youtu.be/xp2ocvnNoJsAnd yes the piano needs tuning!

author: phil from seattle
author_rank: Super Contributor
timestamp: May 06, 2021, 02:34:16 am
content: Are you bit banging the '595s? Then, a faster micro might make sense. Or use DMA. Or maybe SPI.If you use a RasPi Pico, you could use PIO. A group I'm working with is getting very good performance using PIO to output to a 74HCT595 chain.

author: NiHaoMike
author_rank: Super Contributor
timestamp: May 06, 2021, 03:06:00 am
content: Consider a FPGA, something like an ICE40 would be a good start. Rewire the shift register inputs so that each one has its own data line from the FPGA, with shared clock and latch enable.On tuning the piano, since the piano can play itself, write an app to play each note while using a microphone to check the frequency, then have it check each frequency against what it should be. I suppose the next logical step is to make it self tuning but that could get very complicated... Just telling which notes need adjusting and by how much would already help a lot.

author: MathWizard
author_rank: Super Contributor
timestamp: May 06, 2021, 09:06:07 am
content: Cool project, if I was to ever attempt such a thing for my parent's piano, if u don't mind me asking about how many Yankee bucks is a project like this ? Was it hard to fit in the piano, any pictures ?

author: Jan Audio
author_rank: Frequent Contributor
timestamp: May 06, 2021, 03:47:10 pm
content: You need a DAC for fastest response, PWM always need some smoothing.You need a DAC for every note ?, use 1 DAC with many S&H.

author: jord4231
author_rank: Regular Contributor
timestamp: May 15, 2021, 10:59:56 pm
content: Quote from: MathWizard on May 06, 2021, 09:06:07 amMathWizard I cost around $1000 AUD - 700 or so usd? including the pianoThe internals excuse the cable management for now still got to get to that.Quote from: phil from seattle on May 06, 2021, 02:34:16 amThis is what I'm looking in to thanks Phil lots of research to do. Cheers

author: jmelson
author_rank: Super Contributor
timestamp: May 16, 2021, 03:18:32 am
content: I know you could do way better with a Beagle Bone, using the PRU microcontrollers. There are a pair of 200 MHz 32-bit microcontrollers designed for fast I/O. They have a limited number of direct I/O pins that can be toggled at 5 ns intervals. I've used it on a couple projects where I needed faster I/O.The PRUs have limited code space and limited dual port memory, but it should be plenty for this appilcation.Jon