dubstructor Posted August 26, 2009 Report Share Posted August 26, 2009 Hi midiboxers,let me explain this mysterious title.Having recently found a disassembled yamaha pss-595 in a trash bin (!) I couldn't decently leave to rats, I brought it back home to see what I could do with. Most of all I was interested by the idea of playing on a real keyboard, instead of the bunch of switches I'm using. (My computer keyboard does this too, though a bit non-intuitive). I first tried with the electronic board (with built-in midi ports), which was seemingly complete and in a rather good state, and I actually got midi note messages sent to the computer. Only, it behaves too strangely to be playable .... sometimes it works, sometimes not, sending random notes, forgetting some note-offs, and it rapidely comes to crashdown until I switch it back on. Plus, I tried it as standalone, but integrating it in my midibox would involve the use of a merger, and I'd rather keep the building of a merger for more serious needs.... So I studied the working scheme of the keyboard itself, to connect it directly on my DIN module. That's where I need some ideas, because I miss so imagination here....So this is a 49 keys keyboard, of course I could replace the circuitry with 49 contacts then connect it directly to the DIN, only this would involve ordering some more 165's and I'm pretty sure there is a way to "cheat". The keyboard output is a 15-pin port, and here's the way it works :- the first 9 pins each correspond to 6 contiguous keys (one semi-octave)- the last 6 pins are for which key in a given semi-octave is pressed.That means, when you hit the lowest key (C0) for instance, a connection occurs between pin 1 (lowest semi-octave) and pin 10 (first key of lower semi-octave). When you hit C#0, these are pins 1 and 11 that are connected ; when you hit F#0 (the sixth lowest key), these are pins 2 and 10 (first key of the second lowest semi-octave), and so on (please let me know if those explanations are not clear, I'll try to make a drawing). Not to simplify things, these are not simple connections : the impedance is infinite when the corresponding key is not pressed, but around 850 kohm when it's pressed.Is there any way to turn this working scheme into one interpretable by the DIN ? (I thought of using transistors .... or replacing the contacts, which are made through a sort of conducting high-resistive foam). I only ask this question because I find this "matricial" aspect very interesting, it could spare me many DIN circuitry, that's a matter of space (I would deal later with the programmation aspect, especially in the polyphony handling when playing chords). If nobody can show me the way, I surrender and go for new SR and a re-conception of my DIN module. I'm not looking for complete solution, just clues, ideas, or suggestions are welcomed....Thanks by advance. Dubs Quote Link to comment Share on other sites More sharing options...
clem! Posted August 26, 2009 Report Share Posted August 26, 2009 Hi dubs,there are some people who have done this. If you search for "scan-matrix" you will find some information about it but you will have to adapt the code. AFAIK the pss-595 is velocity sensitive so you should search also for "qbas" in the forum. Best regardsclem! Quote Link to comment Share on other sites More sharing options...
dubstructor Posted August 26, 2009 Author Report Share Posted August 26, 2009 Hi clem, thanks for your answer.Meanwhile I've found something interesting, the midibox KB. Actually a kind of "scan-matrix". Adapting the code will be no problem but the main issue is rather hardware : this keyboard doesn't really behave like a scan-matrix, like two pins switching on when you hit a key (one for the semi-octave = the line, and one for the note inside this semi-octave = the column), but those two pins go connected to each other ! Rather exotic. I think I go screwing some lines in the keyboard inner circuitry, and replace the contacts with two-poles switches, in order to have a good ol' well-known scan-matrix. The pss-595 is not velocity sensitive (sigh ! but I would have been even more disappointed to have a velocity keyboard I cannot use) but anyways I'm going straight to look for qbas, maybe eventually it will serve.Last detail : it is said on the notice that up to 29 keys polyphony can be achieved. I don't understand at all how the pss main board deals with it, but all that I can say is that the keyboard is directly connected on two AN90b22 which are basically arrays of commuting transistors. And that's it (multiple-faced circuit >:( ).(BTW did someone already use those ICs in a matrix-type kb ?)Thanks again clem. PeaceDubs Quote Link to comment Share on other sites More sharing options...
jimhenry Posted August 27, 2009 Report Share Posted August 27, 2009 this keyboard doesn't really behave like a scan-matrix, like two pins switching on when you hit a key (one for the semi-octave = the line, and one for the note inside this semi-octave = the column), but those two pins go connected to each other ! Rather exotic. Actually, not at all exotic. This is exactly how the keys have to be wired for a scan matrix. It takes a little bit of study to get your head around how scan matrix inputs work. The basic idea is that you have one side of the matrix, the columns, as inputs to a DIN. The other side, the lines, are connected to OUTPUTS from a DOUT. The outputs are connected to ground one at a time to read, in your case, the 6 notes for the line that is grounded. That is why you see the lines and columns being connected as keys are pressed. There are diodes in the matrix for reasons I won't go into. You need to verify that they allow the flow of current from a plus voltage on the columns to ground on the lines. If not, then you have to columns to the DOUT and the lines to the DIN. Quote Link to comment Share on other sites More sharing options...
dubstructor Posted August 27, 2009 Author Report Share Posted August 27, 2009 Hi jimhenry !Should have come to this as I saw both 74hc165 and 595 ics on the 'midibox kb' schematics :-[There are actually diodes on each line whose anodes point in the direction of semi-octave pins, so those are to be seen as lines, right ? OK, sounds normal.Just one more question : does it matter if the contacts are not 0 ohms ones, but ca. 850 kohms ( :o ) ? As I said, kind of a conducting rubber.... if yes, is there another way to get rid of that than replacing them with metallic surfaces ?OK, thanks a lot for opening my eyes.Peace. Dubs Quote Link to comment Share on other sites More sharing options...
jimhenry Posted August 27, 2009 Report Share Posted August 27, 2009 850 kOhms sounds like it could be a problem. Connect +5V through a resistor to one column, try 10K to start, and ground one row. Connect a voltmeter between the column connection and ground. You should have +5V with no key pressed. Then press the key at the connected column and row. You want to see the voltage go down, ideally somewhere under 1V. If you really do have 850K resistance between the column and the line, then it won't go down that far. Try larger resistances between +5V and the column and see if you can find something within reason that will give you +5V when not pressed and <1V when pressed.Search the net for information about resistor voltage dividers or resistor networks if you need help understanding what is going on here and how to calculate what sorts of resistor values are needed.While you can make this work even with a large resistance between the column connection and ground, at some point the high resistances will start to make the arrangement "delicate" such that it doesn't work reliably. Where that might be is a bit beyond my off the top of the head knowledge. It may be that the conducting surface on the rubber has worn away or glazed over due to dirt. That may be why it is unreliable now and was sent to the dump. You could try cleaning the contact surfaces with alcohol on a cotton swab and see if that helps. At some point, it will get more expensive to salvage this keyboard than to buy a new one. Figure out what the keyboard would cost to replace with new and keep an eye on your expenses so you don't go "upside down" on the keyboard value. Quote Link to comment Share on other sites More sharing options...
dubstructor Posted August 27, 2009 Author Report Share Posted August 27, 2009 Hi jimhenry !Know, i'll surely give up before having to buy the whole yamaha factory ;)Actually I think these are the normal impedance since the rubber on every contacts of both keyboard and motherboard is highly resistive. Plus, when I plug the keyboard on its original board and the board via midi to my pc, I do have midi note messages - before one asks, yes, I have the half-working original synth board, but I tried all possible ways to fix it, successless. According to its strange behaviour, my guess is it's been thrown down because of built-in µcontrollers problem.I actually know a little bit on resistor bridges theory, so I guess that the pull-up resistors have to be at least five times as resistive as those 850 kohm ones ? Ie, round 4 or 5 Mohm .... but like you I think this would limitate the current to hardly for the registers to work well .... Well, anyways I've got to check it out. And if that doesn't work, I'll try my contacts replacing workaround.Thanks for all that help !Peace. Dubs Quote Link to comment Share on other sites More sharing options...
dubstructor Posted August 28, 2009 Author Report Share Posted August 28, 2009 Errrrr.... Finally made this basic test, and .... I don't know how neither why but the voltage drops to ca. 0,7 V when a key is pressed .... with 10k pull-ups :o :o :o :o :oOK, I'm now dealing with the SR connecting. Quote Link to comment Share on other sites More sharing options...
dubstructor Posted August 31, 2009 Author Report Share Posted August 31, 2009 Hi back fellows .....Finally made it after the midibox kb schematics, adapted the code a little bit and ....THIS KEYBOARD STUFF WORKS PERFECTLY 8) !!!!Still a few questions though (only for those who are into scan-matrixes and asm programming) :Where do I have to specify the DOUT/DIN pins which are dedicated to either sm or "normal" use ? Cuz' for now, I can't use keyboard + normal buttons .Is it possible to add some debouncing in the code ? I mean, regarding the 18f452 abilities ? (I didn't actually understand that much how the sm drivers work since their guts are out of some asm stuff and for now only C talks to me :-[ )Well .... that's pretty much of it I guess.Thanks to everyone that made it possible ;)Thanks to everyone that'll help me bring it to perfection Thanks to my mother :DPeace. Dubs Quote Link to comment Share on other sites More sharing options...
jimhenry Posted September 1, 2009 Report Share Posted September 1, 2009 It may not be possible to mix sm and normal pins. I'm not saying it is not possible, just that from what I understand of how sm works I would not be surprised if sm prevented any other use of the pins.You should be able to add debouncing so that once there is a change of state, further changes are ignored for some time. It might even be there already. However, if you speak only C, debouncing may be difficult to deal with. For whatever reason, it doesn't seem like very many people are involved with sm. You are probably going to be pretty much on your own as far as any tweaks are concerned. Quote Link to comment Share on other sites More sharing options...
lucem Posted September 1, 2009 Report Share Posted September 1, 2009 Voltage drops to 0.7V because there is a diode in the wiring, which prevents ghost keypresses -this is perfectly normal :) Quote Link to comment Share on other sites More sharing options...
dubstructor Posted September 1, 2009 Author Report Share Posted September 1, 2009 It may not be possible to mix sm and normal pins. I'm not saying it is not possible, just that from what I understand of how sm works I would not be surprised if sm prevented any other use of the pins.Awwwww too bad.... Nevertheless, I may be wrong but it seemed to me that the SID V2 (whose I actually haven't got into yet because I eventually plan on building a V1 on a 452) combines both sm and classic buttons? OK, time for me to REALLY get into asm to see how that works and look for possible workarounds...On debouncing, I think there's some code already, but I'd like to improve it since lazy fingers walking on the keyboard sometimes trigger a note even with a very weak touch. Well, I think I just have to decrease the sensitivity. Looking for it though, I found something very interesting and complete on the matter, might eventually be of someone's interest :http://www.ganssle.com/debouncing.pdfFor whatever reason, it doesn't seem like very many people are involved with sm. You noticed it too ?Voltage drops to 0.7V because there is a diode in the wiring' date=' which prevents ghost keypresses -this is perfectly normal :)5V ------ 10k pullup ----- measuring point ------- diode ------ 850 kohm contacter -------- ground .Errrr ..... Unless there's been recently some change in Ohm's law I haven't heard of yet, shouldn't the voltage at the measuring point be 5V*(850k)/(850k+10k) - diode drop (measured to 0,77 V each) = 0,988*5V - 0,77V = 4,17 V ?Well, anyways they know better than me what they have to do and this time I won't complain ;)Geekingly yours. Dubs Quote Link to comment Share on other sites More sharing options...
lucem Posted September 1, 2009 Report Share Posted September 1, 2009 Voltage upon _key press_ naturally will drop to diode cross voltage plus minus a bit if additional resistors are involved. Quote Link to comment Share on other sites More sharing options...
nebula Posted September 1, 2009 Report Share Posted September 1, 2009 I found something very interesting and complete on the matter, might eventually be of someone's interest :http://www.ganssle.com/debouncing.pdfThat's an excellent article ... maybe too useful to allow it to slip through the sands of internet time.debouncing.pdfdebouncing.pdf Quote Link to comment Share on other sites More sharing options...
dubstructor Posted September 2, 2009 Author Report Share Posted September 2, 2009 Wow :D::emoted::lucem : thx for the explanations.In fact, there is a debouncing routine in here, quite transparent since, even with my close-to-zero asm skills, I successfully adapted it to my buttons behaviour. My bad, I've looked at things a bit too rapidly. Sorry for the programmer who sweated on things I didn't even notice.First time ever I write some asm code. Well, "it isn't that difficult after all", I thought. But I tried with all my goodwill to understand how the driver scans the io pins, and even if I understand the basis, I'm totally unable to solve this problem :how can I use both sm and normal pins ?Well, time for me to finally set myself in asm mode. So I've begun reading bigonoff's lessons. Won't hurt.Anyways I would still greatly appreciate if someone could point me in the right direction.Maybe I eventually move this to the mios programming section.Scanmatrixly yours. Dubs Quote Link to comment Share on other sites More sharing options...
jimhenry Posted September 3, 2009 Report Share Posted September 3, 2009 If you are going to plunge into assembly language programming, cut your teeth on something other than the heart of the scan matrix code. I am not a great assembly programmer but I do have more than a passing acquaintance with it. The scan matrix inner loops are not easy to understand even if you are reasonably comfortable with assembly code.When you are ready to tackle the scan matrix, start with TK's example rather than QBAS's extension. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.