I've had a Sony MXD-D5C 5-CD Changer / Minidisc deck - quite similar to your MXD-D40 in many respects - for over ten years, and have always been frustrated by the lack of digital audio output on this unit. Although I don't listen to a lot of MD's anymore, this deck is my primary CD Player in my aging home audio rack. I'm gearing up for a home theater upgrade (I will be retaining this deck, I love the 5-CD changer), and am attempting to add a TOSLINK optical output myself. Having read the "hacking" pages of Minidisc.org many years ago, I know there still are how-to articles online for adding TOSLINK outputs to Minidisc decks which have none:
http://www.meyer-piening.ch/robert/je330/
http://minidisc.org/sony_mdsje440_optical_out_mod.html
http://frank.mtsu.edu/~hhw2b/470mod.html
I've ordered a Toslink Connector TOTX173 Fiber Optic Transmitter Module from ebay, approx. US$5.00, which arrived yesterday. Today I finally opened up my MXD-D5C deck to see if the modification would be as easy as the links above have described. Unfortunately, my unit does not have a "T" ("Transmit") SPDIF digital out socket on the audio board. I have had my nose buried in the schematics of the service manual, but have yet to identify an easy-to-tap SPDIF contact on the audio board. Ideally, I would like to tap into one SPDIF output that will carry both the CD and MD SPDIF signal, rather than have two separate optical outputs.
I am very eager to see your progress on this project, and to find out if the audio board on your unit is similar to mine.
Thanks!