Ancient
Who still remembers the good ol’ days of the PlayStation One?
I certainly do. It has been the only game console (the venerable gameboy aside) that I’ve ever owned, and back in the day, I used to play on it a lot. I never got any other consoles afterward though, but that’s mostly because I’m not too much of a gamer anyway (an occasional game I enjoy, but not much more than that) and I don’t want to spend a fortune on a console, another fortune on accessories, another fortune on games, and even more fortunes if you want to be able to play said games online. Especially not if all of those fortunes are not going to be used more than once or twice a week, at best.
Anyway, on a little side project, this week I took an old PSX controller for something different. What else than play PlayStation games can one do with a PSX controller, you might ask? Well, hook it up to a microcontroller and use it to control whatever you want, of course!

The something else to control is kind of missing in this picture, but you get the idea. There’s a PlayStation controller hooked up to a PIC18F2520 (its a PIC18F2520 because I happened to have it at hand, and it’s running at 40 MHz – not because that much is needed to read a few buttons, but because all my delay routines and template configuration files are based on that and I was too lazy to adjust everything). There’s a few LEDs for testing purposes, RS232 connection which sens the state of the controller out to my PC, and my trusty USB logic analyzer (which is awesomely useful in projects like this).
Interfacing the PSX controller isn’t all that difficult. There are nine wires – two for power to the controller (red and black for +5V and GND, respectively), two for power to the vibration motors (various sources state 7-9 V, but they run on 5 V just as well), and five wires for communication (one for bits sent to the host, one for bits sent to the controller, clock, attention (like the chip select in SPI), and an acknowledge signal from the controller). The clock runs at 250 KHz (500 KHz for the newer PS2 controllers, though the protocol for those is identical). During a transmission the attention line is made low by the host, data is clocked in at the rising edge of the clock signal, and after each byte the controller pulls the acknowledge line low for a short period – in other words, fairly simple stuff. The only thing that is kind of annoying is that it is a synchronous protocol (i.e. data is sent to and received from the controller at the same time), but otherwise, it’s not hard.
The PIC asks the controller ‘how are you?’ about 50 times a second, and the controller responds with 6 bytes of useful data – 2 bytes for all of the buttons (there are exactly 16 buttons, so that’s convenient) and 2 for each of the analog sticks. The PIC compares the data to an internal buffer to detect if something has changed, and if so, the output on the serial console is updated. It poops out the status of all buttons, with some VT100 terminal control codes to clear the screen and make the output look pretty. On powerup, there is even a pretty screen with the classic “Press Start” message (in blinking text, woohoo!).
Unfortunately that is about as far as it goes right now. If I had more of these controllers and a little graphical LCD, you could do fun things with it though! (I need to keep that in mind
)
Furthermore, I am also starting to play a bit with ARM microcontrollers. Got an evaluation copy of CrossWorks for ARM (which is an awesome piece of software – expensive, but awesome!), and a bunch of LPC2103/2138 chips (LQFP packages… not a lot of fun, but quite doable with a bit of practice). These chips are an awesome platform for a lot of things, thanks to their speed and memory size, which would put any PIC or AVR to shame, and with a much more efficient instruction set as well. But more on that later.
Comments
Leave a Reply
