Sunday, December 4, 2016

PSX DenshaDeGo Loconet controller

In my last trip to Japan I found an old PSX "Densha De Go" Japanese controller. This is a controller simulating a train cab and used with that train simulator game, very popular in Japan.


I don't remember if I found it in a BookOff second hand store or in Mr Potato, Last one is a very famous retro gaming shop in the heart of Akihabara district in Tokyo.

My idea was to use the controller to move trains in my layout, and to accomplish that I would use an Arduino acting as interface between the PSX controller and my Loconet network.

Let's check the hardware needed:

1 x Arduino UNO. (Another Arduino version is also possible)
1 x Loconet shield. As always that you want to interface Arduino and Loconet, you need a Loconet shield. You can build it your own, or buy it directly to the Rocrail guys. The item code is GCA185 and here you have all the information about it and the electrical schemes if you want to build it by your own: http://wiki.rocrail.net/doku.php?id=gca185-en
1 x Sensor Shield v5. This is not strictly needed, but makes it easier to connect wires and build the prototype before soldering everything in place. You can have it from ebay for 2$
You will need also some Dupont female to female jumper wires for easy connecting and testing of the prototype.

Connections:

Plug the Loconet shield GCA185 on top of Arduino UNO, and Sensor shield on top of GCA185. Then you have to connect the pins of the PSX joystic to the following Arduino pins if you want to use directly the Arduino sketch I'm providing later on in this post:

PSX pin 1 (DATA) to Arduino PIN 12
PSX pin 2 (COMMAND) to Arduino PIN 11
PSX pin 4 (GND) to Arduino GND pin
PSX pin 5 (VCC) to Arduino +5V pin
PSX pin 6 (ATT) to Arduino PIN 10
PSX pin 7 (CLOCK) to Arduino PIN 13

You can check in this page all information about PSX controller, also how to identify which is the pin number 1 of the connector: http://www.gamesx.com/controldata/psxcont/psxcont.htm


Here you have an image of my temporary connections of the PSX connector and the Arduino Sensor shield for further clarification:



Software:

Finally, you need to compile and upload the following sketch into the Arduino board:

https://github.com/ClubNCaldes/ArduinoDeGo

To be able to compile the sketch you need to add two libraries to the Arduino environment:

MRRWA Loconet library: http://mrrwa.org/download/
PSX library: http://playground.arduino.cc/Main/PSXLibrary

The first one is the library in charge of Loconet communications. You have many examples included in the library. I used of them, Loconet Throttle, as basis for making the current sketch. The example turns the Arduino in a Loconet Throttle receiving the commands through the serial monitor. You only need to change it a little bit to use any device connected to Arduino. In my case I changed it to use a PSX controller, but you can connect a potentiometer, a LCD display and a keypad or anything you imagine to build your personalized throttle.

The second one is a library written by Kevin Ahrendt and based on the PSX communication protocol analysis from Andrew J McCubbin. I also had to do some reverse engineering as this controller is not like the normal ones. And I found the brake throttle is not working properly, some times it is sending strange values. That's why you will find in the sketch some weird code to skip strange values that my controller sends some times. But if it works with my broken controller, I guess it will also work properly with a good one.



If you have any question just comment under the post or open an issue in the GitHub repository. If it works well and you try it, you can also comment.  :P