0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« on: August 13, 2010, 07:29:50 am » |
Hello there.
I plan to make a dual (91 keys * 2) musical keyboard with 36 effect keys.
Everything will play (and record) on PC (using a modification of Zynaddsubfx) and I just need a way to "read" these keys in a program.
Basically, I want some quick-start solution to be able to get which key was pressed and when. I just need an interface that identifies every key and sends this event to PC.
I don't know what's the best solution though.
Thanks in advance.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #1 on: August 13, 2010, 07:34:50 am » |
Maybe hack the guts of two PS2 keyboards - which have nice mapping circuitry so that each key gets a unique number etc?
Connect the data & clock lines from each to different pins on the Arduino.
Then you could probably read the scancodes from each keyboard.
E.g (made up numbers). Scancode x15 from keyboard 1 = C#3 Scancode x15 from keyboard 2 = F7
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #2 on: August 13, 2010, 07:46:28 am » |
Thank you. The problem is the keyboards are assembled already... and they have simple normally open switches. 
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #3 on: August 13, 2010, 07:55:51 am » |
You've already built the musical keyboards e.g. with 218/220 (+ pwr, grnd) wires hanging out of the back?
Or have you bought them but intending to modify them?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #4 on: August 13, 2010, 08:03:10 am » |
I'm intended to modify 2 trashed keyboards. They don't have pwr or anything, they are just a bunch of electrical(electronic) switches. And I just need a way to read on PC which switch is pressed. I would use serial ports if they were enough, however, 218 are too much. And USB is way better.
Thank you.
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6820
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #5 on: August 13, 2010, 08:52:03 am » |
Serial/USB is how to send the data to the PC and a different issue to decoding the switches. just a bunch of electrical(electronic) switches Do you have access to two wires from each switch? Nothing immediatey springs to mind except 30 shift registers  but there's bound to be some keyboard decoder chips out there.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #6 on: August 13, 2010, 09:19:11 am » |
Serial/USB is how to send the data to the PC and a different issue to decoding the switches. I know, but I would connect the cables directly into the PC if i had enough ports. Do you have access to two wires from each switch? Nope, one wire is common (don't know if is correct to say this) for all the switches. I have acces to only one wire from each switch. Nothing immediatey springs to mind except 30 shift registers Smiley but there's bound to be some keyboard decoder chips out there. Maybe there's a simple way to "expand" the io ports in Arduino  . Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Vermont, USA
Offline
Full Member
Karma: 0
Posts: 170
ElectroMech
|
 |
« Reply #7 on: August 13, 2010, 09:28:36 am » |
Maybe there's a simple way to "expand" the io ports in Arduino Cheesy. ..Parallel in - Serial Out shift registers. Lots of them.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #8 on: August 13, 2010, 09:37:19 am » |
..Parallel in - Serial Out shift registers. Lots of them. What? Sorry, but i'm software programmer. I know almost nothing about electronics  . I wonder if this is the right way for me... I'm not giving up though. Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6820
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #9 on: August 13, 2010, 09:50:32 am » |
Parallel In Serial Out (PISO) shift registers take 8 inputs and shift them serially out from one pin. You can hook as many as you like together, so in your case you would connect 28 of them in a line, pulse one of the Arduino pins 28*8 times while reading another pin and saving a byte every 8 pulses.
At the end of this you have 28 bytes in RAM that represent the state of 224 inputs.
It's easy to do and will only need 3 pins, but presumably you will be playing music so the only problem is that as a C function it might be too slow if you are expecting an instant response.
|
|
|
|
« Last Edit: August 13, 2010, 09:51:34 am by graynomad »
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 0
Posts: 1103
Arduino rocks
|
 |
« Reply #10 on: August 13, 2010, 10:12:26 am » |
No need to speculate...Using standard Arduino techniques takes 150us to shift in one bit. The whole lot thus will need 36 ms = 1/28 sec which is a noticeable time for the ear (and even for the eye). It can be done faster, but there will be a lot of processing involved anyhow, not to speak of sending the data, though you will send the differences only of course.... The build-up and wiring of 28 chips on a PCB is also not an easy task for someone with little experience. There are 16 bit PISOs though ( http://www.unicornelectronics.com/ftp/Data%20Sheets/74ls674.pdf) but a little bit difficult to find... Alas, the common ground of the switches prevents any sensible matrix design.... ---- Edit some hours after.. Sorry this was a slip of my memory. I checked it with a scope: It takes 14 us only for 2 digitalWrite and 1 digital Read
|
|
|
|
« Last Edit: August 13, 2010, 05:19:37 pm by mpeuser »
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 0
Posts: 1103
Arduino rocks
|
 |
« Reply #11 on: August 13, 2010, 10:29:41 am » |
All right, there is another not so well known appproach, using an analogue technique. You can add a resistor to each of the keys to a common voltage, adding the current through them. As you have to identify multiple keys, the values have to be logarithmic which limits this approach to less than 10 keys
1MOhm - 470k - 220k- 100k - 47k - 22k - 10k - 4k7 - 2k2 - 1k
You can use 6 ADC lines to have 60 keys.....
Critically viewed the 10 bit resolution of the ADCs will not really suffice to cover that range reliably...
--- Second thought: It is easy to expand the ADC to more lines, as the 6 provided lines are multiplexed anyhow. This needs a quite popular chip as 74HC4051 (1to8-analogue multiplexer). So by using 5 of them to 5 Arduino analogue ports you have 40 lines, each connected to a resistor network of 8 (from 470k to 2k2) giving you 320 inputs.
I have not yet calculated what time the decoding will take. Most likely not so much, as most of the time most keys will be open which can be easily detected....
|
|
|
|
« Last Edit: August 13, 2010, 10:44:20 am by mpeuser »
|
Logged
|
|
|
|
|
0
Online
Tesla Member
Karma: 50
Posts: 6546
Arduino rocks
|
 |
« Reply #12 on: August 13, 2010, 11:02:27 am » |
Search the board for "multiplex" for ideas for inputting a large number of inputs. You can read the switches this way, but only one at a time.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #13 on: August 13, 2010, 11:08:05 am » |
Parallel In Serial Out (PISO) shift registers take 8 inputs and shift them serially out from one pin. You can hook as many as you like together, so in your case you would connect 28 of them in a line, pulse one of the Arduino pins 28*8 times while reading another pin and saving a byte every 8 pulses.
At the end of this you have 28 bytes in RAM that represent the state of 224 inputs.
It's easy to do and will only need 3 pins, but presumably you will be playing music so the only problem is that as a C function it might be too slow if you are expecting an instant response. Thanks for the detailed explanation. Too bad it doesn't fit my needs though. Second thought: It is easy to expand the ADC to more lines, as the 6 provided lines are multiplexed anyhow. This needs a quite popular chip as 74HC4051 (1to8-analogue multiplexer). So by using 5 of them to 5 Arduino analogue ports you have 40 lines, each connected to a resistor network of 8 (from 470k to 2k2) giving you 320 inputs.
I have not yet calculated what time the decoding will take. Most likely not so much, as most of the time most keys will be open which can be easily detected.... Wow! Seems the way to go... I even found something similar using this method: http://blog.makezine.com/archive/2008/05/build_the_arduino_pocket.htmlHowever, as a beginner, I would like to study some tutorial-style documentation about this, so, if anyone can point me some good ones (i'm interested about the "piso" also) i'll be very gateful. Thank you very much guys!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #14 on: August 13, 2010, 11:55:56 am » |
Does it really take 150us to clock in a single bit from a shift register? That's an awful long time, and of the order of the same sort of time between analogue readings.
|
|
|
|
« Last Edit: August 13, 2010, 11:58:26 am by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
|