hacking a controller.
JohnGay
Posts: 57
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.
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.
Comments
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.
OBC
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.
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.
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
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.
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.