View Full Version : hacking a controller.

03-25-2012, 07:18 PM
I just found a controller someone threw out. It's got 4 'A,B,C,D' buttons, two shoulder buttons, a start button, a d-pad and an analog joystick. Unfortunately, being a NetJet controller, even though It's got an USB connector, It's not an USB device.
I was hoping I could hack it into a simple controller for my QuickStart board.
I'd prefer to use cat5 cable for the connection, since I've got lots of this at work, so how to multiplex these on 8 lines?
The joystick will probably take the most wires, but I should be able to multiplex the rest on the remaining lines. Any pointers for this would be appreciated.

Oldbitcollector (Jeff)
03-25-2012, 07:29 PM

A few thoughts..

You could use the same chip which is in the NES controller to handle your buttons, the 4021. There is excellent documentation both in the Hydra book (available in hard copy and free digital copy at Parallax.com, also Google "NES schematic") This would reduce the buttons down to an easily reasonable number of Propeller I/O pins. Have you determined the resistance of the joystick? You might be able to use "Sigma-Delta" to read the resistance levels.

If you decide the entire process is too much, there are also ready-to-go objects in OBEX for NES, SNES, N64, and Wii controllers. I'm personally fond of N64 and Wii controllers as they take 1 and 2 I/O pins in exchange for a lot of buttons and controls.


03-25-2012, 10:30 PM
Just did quick measure. The joystick has 4 pins.
1 - 4 const. 4.75k
2 Up/down from 5k to 800 ohm.
3 Left/right from 5k to 1.5k or 300 ohms. Depending on pin 1 or 4.

The d-pad and A,B,C,D buttons each have 5 pins.
I was hoping to keep it simple, but there is a board that needs to come out. It holds all the circuits that are not needed.
I saw someone had a simple circuit example for connecting a joystick.

03-25-2012, 11:25 PM
JohnGay: Not to put a dampener on using recycled devices, but a Wii Classic Controller has an I2C interface and is cheap on eBay. Its a nice controller with buttons and joysticks, all decoded and working. And IIRC there is an object in Obex already.

If however, you want to hack it for the learning and using exercise, then you could use a prop internally to interface directly to the pins and pots, and send out the info serially. Yes the prop is overkill (from a micro perspective), but you can then get this running and just send the data serially over a single wire to another prop (3 wires 5V or 3V3, GND and 1 serial pin).

Otherwise, just bring out the wires as you suggested, one for each button/resistance and 1 for common (GND). You will need to build an ADC circuit (see the app note) to convert the up/down and left/right pots (variable resistor) to digital using sigma-delta. Cat5 cable would be fine. You will need to look at debouncing your switches.

03-26-2012, 12:03 PM
According to this: http://sites.google.com/site/parallaxinretailstores/home/2-axis-joystickI only need two I/O and a ground for the joystick, which leaves 5 wires left over in a CAT5 cable.Now to figure out how to get the most use from those. The D-Pad can probably be multiplexed, they can only do one connection at a time, right? The other 7 buttons can be pressed simultaniously, but I probably don't need all of them.Basically, I want to hack this cause it was free, I like doing things old-school and I want to flex my aging electronics education.

03-26-2012, 02:25 PM
unfortunately the link is broken

03-26-2012, 03:29 PM
Sorry: http://sites.google.com/site/parallaxinretailstores/home/2-axis-joystick

03-26-2012, 09:49 PM
If you separate the switches from ground, you can use a matrix to read the 7 switches using 6 wires, so still 1 short.

Provided you only permitted 1 switch active at a time (well only detect 1 in a priority) you could use a ladder resistor network and read in the analog using 1 pin ADC like you calculate the joystick. This would use 2 wires, 1 being +3V3

+3v3 ---- 1K --*-- 1K --*-- 1K --*-- 1K --*-- 1K --*-- 1K --*-- 1K --*-- 1K --- GND

where * is the connection of one switch each. The other end of the switch is common and goes to connects to the prop pin using the ADC circuit (sigma delta). Connect this common pin via 100K to gnd. Now you have 8 x 1K resistors dividing the 3v3 into 8 steps giving 0V with no switches active. 3v3 / 8 = 0.4125v steps. So, no switches gives 0V, with the switch closest to gnd pushed, you get 0.4125v, next switch 2 * 0.4125v = 0.825v, etc. If more than 1 switch is pressed, the lowest to gnd will override.

Now, in ADC

03-27-2012, 03:10 AM
How about using one or two '165's to shift the button data out serially?

03-27-2012, 06:05 PM
I was just checking and we have lots of DVI cables going spare here at work. And they have upto 29 wires. Not an elegant solution, but cheap and easy. Certainly more than enough wires, just a bit of a waste of I/O pins though.

The joystick needs 2 I/O pins and a ground.
The D-Pad has 5 exclusive states, which needs another 3 I/O but will take logic to encode.
The remaining 7 buttons can potentially be pressed simultaniously.

From this count, I need 12 I/O pins, VCC and GRD.
Or 13 I/O and GND if I don't encode the D-Pad.
Either way I count 14 wires unless I go with a shift register solution.

04-03-2012, 11:46 AM
Just cut the end off a Digital DVI cable. I found 4 individually shielded pairs, 5 seperate wires and an outer shield.
I'm hoping I can get away with using 1 shielded pair for the joystick, 1 shielded pair for the D-Pad and that leaves me 9 wires for the remaining 7 buttons.