Please check my answer with someone with more expertise before connecting things. I had to create an IKBD connection for my STacy because it does NOT have a compatible keyboard connector either. I'm guessing you may need to do something similar.
When I look at the 520ST and the MegaST schematics the Keyboard jumper (J12 on the 520 and J4 on the Mega) both are 18 pins and the descriptions appears similar.
The Cosmos Ex requires four lines:
1) keyboard transmit original ( keyb tx orig )
2) keyboard transmit from cosmos ( keyb tx )
3) keyboard receive ( keyb rx )
4) ground ( GND )
So the IKBD injector for the CE "injects the data from the CE by re-routing the "keyboard transmit original" from the ST and sends it to the CE, then "keyboard transmit cosmos" returns the signal to the ST.
I am trying to think of the the most non-permanent changes you can make and still "inject" the CE signal.
1) On my STacy, I removed the IKBD IC (6301 - which is also on the 1040ST and might be universal) from its socket, pin 11 bent outward and soldered to wire and then IC was re-socketed) = keyb tx orig (TX signal going from keyboard, which is sent to CE for processing). My hope is you have the same IC socketed on the underside of you keyboard.
2) Pin 15 of Header Socket labelled J12 is keyb tx (TX signal going from CE to ST, which contains original keyboard data + injected data) is where I believe you need to return the signal to your 520ST.
3) Pin 14 of Header Socket labelled J12 is keyb rx (RX signal going from ST back to keyboard and to CE)
4) Pin 1 of Header Socket labelled J12 is GND.
I have attached the cropped schematic from the 520ST highlighting the pins on J12. And a picture of my STacy IC 6301 with the soldered wire to pin 11.
Please check with an expert. I am a novice!!!! I hope this helps though.
You do not have the required permissions to view the files attached to this post.