Pages: [1]   Go Down
Author Topic: Emulating a piano keyboard  (Read 422 times)
0 Members and 1 Guest are viewing this topic.
New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there!

I've been given a old 1980's 61 key electronic piano, and it has no keyboard! I was wondering if there was a way to emulate a 8x8 keypad matrix on a Arduino Uno, Due, or Mega?
I was thinking that I could send MIDI data to the Arduino, and get it to trigger the appropriate key(s). Having 61 relays is a bit out of the question, but any suggestions or pointers towards the right path would be greatly appreciated!  smiley-surprise
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anything's possible no doubt. Perhaps more circuit details would bring forth more answers. You need to close 61 circuits, or just 16 (8 x 8)?
Logged

New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just 16, the keyboard is in a 8x8 matrix, 8 columns and 8 rows. I don't mind using relays, now that I realise I don't need 61 of them.
« Last Edit: September 17, 2013, 03:30:13 am by Clym5 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

May I suggest optocouplers instead of relays: Quieter, can be driven directly by Arduino, smaller, much cheaper in numbers. The only drawback is that unlike relay contacts, the output transistors in optocouplers are polarity conscious - assuming NPN output transistors in the optocouplers, you will need to make sure that the collector of each opto output goes to the more positive side of the keyswitch it is replacing, and the emitter to the more negative side.

There is one potential problem though: How many note polyphonic is this piano? Although your optocoupler or relay outputs can be wired in an 8 * 8 matrix, the worst case scenario is that you may have to be able to turn on quite a few of them (say at least ten, the maximum number of keys a human player could press) at the same time. This means that there is a requirement for the controller to be able to press, hold and release ANY of the piano keys independently or together in an almost infinitely variable number of ways. Put simply, each of your optos or relays will need an arduino output dedicated to control it. Practically, this means you'll need to use a number of output expanders such as I2C to 8-bit port ICs, ie, PCF8574. 
« Last Edit: September 17, 2013, 07:12:40 pm by SiriusHardware » Logged

New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The piano can handle more than 10 notes at once, but I wouldn't mind if the Arduino could control only 2 or 3 at a time. I'm just about to see if any of my local electronics stores have optocouplers.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not totally convinced optocouplers on their own will do it, because in a keypad matrix situation, there is not necessarily a "ground".
Logged

New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any way to manually trigger keys by shorting pins on the mainboard? Would I need a resistor for that? I thought it might be handy to know what pins do what.
Logged

NSW Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 2292
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not totally convinced optocouplers on their own will do it, because in a keypad matrix situation, there is not necessarily a "ground".

Not necessarily, but unless the matrix uses some really strange multiplexing, or "Charlieplexing", either rows or columns will be strobed low or high and the other, pulled high or low to sense it.  Optocouplers would suit perfectly as the outputs "float", though you are looking at one per "key" and - you cannot multiplex the input side!

If it is polyphonic (more than two), then the matrix necessarily contains diodes, and optocouplers would automatically perform this function.

And again, a matrix must be multiplexed, so the trick is actually to figure out exactly how it is multiplexed, how fast and how regularly, and produce a program which matches the (eight) strobes to the (eight) sense lines, using only 8 outputs and 8 inputs.
Logged

Victoria, Australia
Online Online
God Member
*****
Karma: 24
Posts: 982
Electronics Engineer/Industrial Control
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I don't want to put a spanner in the works but how do you know the keys were single switches, usually they are 2 switches, one to signal the key has just started to be pressed and another to signal when the key is fully depressed. This is how the circuitry knows how hard the key was pressed and thus the volume of that keys  note.
Yours might not be this elaborate but there is the possibility.
Tom... smiley
Logged

Everything runs on smoke, let the smoke out, it stops running......VK3DMK

New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Tom, any suggestions are help! Even if they are a spanner in the works!

This piano isnt very high-end, just a 1980's good home electronic piano. I dont think it has velocity sensitivity, as I was given the "remains" of the keyboard today, and I can see that when the key is pressed, it just pushes a piece of copper onto a metal bar to make the connection. The keyboard has diodes on it, definately polyphonic.
If the lack of pins on a Uno is a problem, I have a a Mega and a Due sitting somewhere.
Logged

New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In reply to Paul,

Would it really be needed to find out how fast the piano scans the keyboard? I can find out the different combinations for the notes by shorting out the pins on the mainboard of the piano, so I think I've got that one sorted.

I only ever seem to use my arduino for detecting and generating square waves, so anything outside that is all new. Just a terrible excuse for my incompetence! :3
I also can't quote people on my phone.
« Last Edit: September 18, 2013, 05:47:44 am by Clym5 » Logged

NSW Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 2292
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Would it really be needed to find out how fast the piano scans the keyboard? I can find out the different combinations for the notes by shorting out the pins on the mainboard of the piano, so I think I've got that one sorted.

The point is - you are faced with either 61 relays, contacts, optocouplers or what-not, with a whole menagerie of components to operate these and emulate the original mechanical keys, or else you figure out how to make the mainboard think that those keys exist by determining what it is "looking" for as it scans, and feeding it a code for that moment (of scanning) which would correspond to a keypress - a virtual key.

To do this, you have to figure out (a CRO is useful, but this is digital, and an Arduino can be used to analyse patterns) what this scanning or "polling" looks like, to see whether an Arduino can be used to detect and respond to it in the necessary timeframe.  Given that this is a "HID", it should be a relatively slow process.
Logged

New Zealand
Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, alright. I'll get my oscilloscope out tomorrow and have a look at how it scans the keys. Thanks for all the help so far!
Logged

Pages: [1]   Go Up
Jump to: