add article about KSP Hack

This commit is contained in:
Valentin Boettcher 2021-08-27 21:58:34 +02:00
parent 044e7dbd90
commit 4a8abe0150
18 changed files with 198 additions and 1 deletions

View file

@ -1,3 +1,6 @@
:PROPERTIES:
:ID: 5116403f-0c79-4ccf-a33a-fdcc66f08bcc
:END:
#+hugo_base_dir: site
#+hugo_section: posts
#+STARTUP: logdone
@ -2758,6 +2761,108 @@ Butterfabrik benutzten, ehemaligen Schiffsmotor!
Und jetzt gehts schlafen. Bis nächste Woche in Deutschland.
** Hacks :@Hacks:
*** Converting a Kawai KSP-30 to pure MIDI
CLOSED: [2021-08-27 Fri 21:57]
:PROPERTIES:
:EXPORT_FILE_NAME: converting-a-kawai-ksp-30-to-pure-midi
:END:
My Kawai KSP-30 digital piano has been on its last leg for some time
now. To get it to work at all, I had to unplug the amplification
circuit whose interface on the main PCB was burnt out. Of course is
wasn't of much use by itself after that bit of crude surgery but
worked fine as a midi keyboard.
#+CAPTION: The main PCB.
#+DOWNLOADED: screenshot @ 2021-08-27 18:05:08
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-05-08_screenshot.png]]
There must have been some creeping currents because the piano got more
and more unreliable requiring hectic powercycling to boot and finally
not booting at all. Looking for spare parts on eBay didn't bring up
anything so I decided to scan the keyboard directly with a
micro-controller and do away with the rest of the innerts of my trusty
Kawai entirely.
First I had to find out how the keyboard matrix was scanned. Luckily I
had a logic analyzer lying around to test the ports on the keyboard
connector [fn::Before I remembered having a logic analyzer however, I
fried my Raspberry Pi with the 5V logic :P.]
#+CAPTION: Figuring out the keyboard matrix.
#+DOWNLOADED: screenshot @ 2021-08-27 18:15:55
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-15-55_screenshot.png]]
Furthermore, I found the service manual for the KSP on =archive.org=
and with a little trial and error was able to puzzle it together.
#+CAPTION: The keyboard connector.
#+DOWNLOADED: screenshot @ 2021-08-27 18:26:41
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-26-41_screenshot.png]]
The keyboard matrix has eight columns that can be read through =KD0=
through =KD7= [fn::Annoyingly the KDX numbers are shifted by one at
other places in the manual]. To scan all 88 keys three multiplexers
are employed that can be enabled individually by the =SA4= and =SA6=
ports (see figure above). The other three =SAX= connectors select one
of eight rows through the currently enabled multiplexer. Because the
piano is velocity sensitive, each key actually has two sensors with
one triggered shortly before the other. The time difference between
these signals can be measured to obtain the key velocity. Therefore
the =KDX= ports are split into two groups =S1= and =S2= that
correspond to the two triggers.
#+CAPTION: The two-switch mechanism.
#+DOWNLOADED: screenshot @ 2021-08-27 18:35:47
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-35-47_screenshot.png]]
Putting all this together one arrives at the following matrix.
#+DOWNLOADED: screenshot @ 2021-08-27 18:37:23
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-37-23_screenshot.png]]
In practice one just cycles through the multiplexers while running a
counter to obtain the correct note because they are consecutive.
Having ascertained all this knowledge I began the realization of the
actual project by sawing out the port for the keyboard connector from
the PCB because the connector is not compatible with the usual jumper
spacings.
#+DOWNLOADED: screenshot @ 2021-08-27 18:42:56
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-42-55_screenshot.png]]
Then I soldered jumper cables to one side of the connector (a real
hack job :P) and done was my not-too-fragile interface which I
promptly connected to an Arduino Nano clone I had to spare.
#+DOWNLOADED: screenshot @ 2021-08-27 18:47:12
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-47-12_screenshot.png]]
And finally the nasty hardware part was done and I could begin to
prototype the software on the Nano while waiting for a Pro Micro with
native USB capabilities to arrive. It suffices to say that it worked
:) with key velocity and all. After the Pro Micro arrived I even got
the sustain pedal to work :).
#+CAPTION: The final assembly.
#+DOWNLOADED: screenshot @ 2021-08-27 18:51:45
[[file:static/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-51-45_screenshot.png]]
With the Pro Micro set up I went on to calibrate the key sensitivity
which was less of a hassle than I thought and the project was
finished. Happily I went back to making music ever after.
The end.
Of course there remains some cleanup to be done (datatypes in the
source code). Most urgently I want to implement release velocity.
You can find the code and my personal documentation for the
project[fn::In the file named =project.org=]
over on [[https://github.com/vale981/KSP-30_Hack/][GitHub]].
Maybe this was of interest you. If not, then thanks for reading this
far anyways :P.
** Uncategorized :@Uncategorized:
*** Neuseeland Restauration
CLOSED: [2021-08-03 Tue 14:53]
@ -2813,7 +2918,6 @@ Ein wenig python verwandelte das Ganze in das neue Blog format.
Und damit koennt ihr nun unter [[/categories/neuseeland][Neuseeland]] die alten posts lesen.
[fn:5] =ctime=, creation time
* Local Vars
# Local Variables:
# eval: (org-hugo-auto-export-mode)

View file

@ -0,0 +1,93 @@
+++
title = "Converting a Kawai KSP-30 to pure MIDI"
author = ["Valentin Boettcher"]
date = 2021-08-27T21:57:00+02:00
categories = ["Hacks"]
draft = false
+++
My Kawai KSP-30 digital piano has been on its last leg for some time
now. To get it to work at all, I had to unplug the amplification
circuit whose interface on the main PCB was burnt out. Of course is
wasn't of much use by itself after that bit of crude surgery but
worked fine as a midi keyboard.
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-05-08_screenshot.png" >}}
There must have been some creeping currents because the piano got more
and more unreliable requiring hectic powercycling to boot and finally
not booting at all. Looking for spare parts on eBay didn't bring up
anything so I decided to scan the keyboard directly with a
micro-controller and do away with the rest of the innerts of my trusty
Kawai entirely.
First I had to find out how the keyboard matrix was scanned. Luckily I
had a logic analyzer lying around to test the ports on the keyboard
connector&nbsp;[^fn:1]
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-15-55_screenshot.png" >}}
Furthermore, I found the service manual for the KSP on `archive.org`
and with a little trial and error was able to puzzle it together.
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-26-41_screenshot.png" >}}
The keyboard matrix has eight columns that can be read through `KD0`
through `KD7`&nbsp;[^fn:2]. To scan all 88 keys three multiplexers
are employed that can be enabled individually by the `SA4` and `SA6`
ports (see figure above). The other three `SAX` connectors select one
of eight rows through the currently enabled multiplexer. Because the
piano is velocity sensitive, each key actually has two sensors with
one triggered shortly before the other. The time difference between
these signals can be measured to obtain the key velocity. Therefore
the `KDX` ports are split into two groups `S1` and `S2` that
correspond to the two triggers.
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-35-47_screenshot.png" >}}
Putting all this together one arrives at the following matrix.
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-37-23_screenshot.png" >}}
In practice one just cycles through the multiplexers while running a
counter to obtain the correct note because they are consecutive.
Having ascertained all this knowledge I began the realization of the
actual project by sawing out the port for the keyboard connector from
the PCB because the connector is not compatible with the usual jumper
spacings.
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-42-55_screenshot.png" >}}
Then I soldered jumper cables to one side of the connector (a real
hack job :P) and done was my not-too-fragile interface which I
promptly connected to an Arduino Nano clone I had to spare.
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-47-12_screenshot.png" >}}
And finally the nasty hardware part was done and I could begin to
prototype the software on the Nano while waiting for a Pro Micro with
native USB capabilities to arrive. It suffices to say that it worked
:) with key velocity and all. After the Pro Micro arrived I even got
the sustain pedal to work :).
{{< figure src="/images/Converting_a_Kawai_KSP-30_to_pure_MIDI/2021-08-27_18-51-45_screenshot.png" >}}
With the Pro Micro set up I went on to calibrate the key sensitivity
which was less of a hassle than I thought and the project was
finished. Happily I went back to making music ever after.
The end.
Of course there remains some cleanup to be done (datatypes in the
source code). Most urgently I want to implement release velocity.
You can find the code and my personal documentation for the
project[^fn:3]
over on [GitHub](https://github.com/vale981/KSP-30%5FHack/).
Maybe this was of interest you. If not, then thanks for reading this
far anyways :P.
[^fn:1]: Before I remembered having a logic analyzer however, I fried my Raspberry Pi with the 5V logic :P.
[^fn:2]: Annoyingly the KDX numbers are shifted by one at other places in the manual
[^fn:3]: In the file named `project.org`

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB