Offline
Gorinchem, The Netherlands

I recently picked up a personal project where I'm trying to build a keyboard for LSDJ, but wanted to do away with the PC keyboard interface and form factor. Instead, I wanted to use an actual piano keyboard, so I demolished a toy one and will later be adding some additional buttons to accomodate for non-note commands. (Changing instruments/octaves, channel mute etc.)


On the electronic side of things, this means emulating the PS2 protocol. I'm going with software emulation with Arduino. I modified a library from 2009 to do the trick. It didn't work in the beginning, but Johan gave me some great information on how LSDJ handles the clock and scan codes that PC keyboards send. Right now this is the level where the emulation is at:



Right now, what's bogging me down is the occasional misinterpreted data (represented in this video as surprise high notes where it's supposed to cycle through notes C4 through B4 over and over). Reason I'm posting it here in this early stage is because I'm at the stage where I might need to bring in an oscilloscope - but I was hoping that maybe some of you had any additional advice or experience on the subject, and could help me with ideas to perfect the transmission routines. I also thought this place better than a general electronics forum because the purpose and tuning of the emulator is rather specific to LSDJ.

Some further information:
- clock is high and low for 34 microseconds each. This value has been determined experimentally to have the most effective transmissions. Any other value will lead in lots of failed and incorrect data transmissions, which mystifies me. The PS/2 protocol should work with clock cycles of 30-50 microseconds, whereas I can only send semi-successfully to LSDJ at the rate described above.
- both the clock and data line are pulled up by 10k resistors
- since LSDJ never tries to send data back, the emulator has full control over the lines and only need concern itself with sending
- Johan mentioned that not all bits of an 11bit keyboard message are interpreted by LSDJ. The last two (parity and stop) are supposedly ignored through a 1ms hardcoded delay.

If anything else is unclear, do ask!

Oh, and in case it needs to be said: this project is mostly done because I enjoy tinkering and it helps me to care and learn about elements of programming that otherwise fail to interest me. Please don't tell me to stop modding and start composing - this is what I like to do and the end result(code/circuit/etc) might end up helping others.

That said, I'd love to hear some troubleshooting suggestions, criticism, general feedback and other ideas! Thank you in advance. smile