280 likes | 757 Views
Playstation 2 Controller. David Domanico Justin Kaput. 1. Buttons (Dual Shock 2). 2 analog sticks 12 pressure sensitive buttons Square, triangle, circle, x, directional pad, L1, L2, R1, R2 5 digital buttons Start, select, “analog”, L3, R3. http://en.wikipedia.org/wiki/DualShock. 2.
E N D
Playstation 2 Controller David Domanico Justin Kaput 1
Buttons (Dual Shock 2) • 2 analog sticks • 12 pressure sensitive buttons • Square, triangle, circle, x, directional pad, L1, L2, R1, R2 • 5 digital buttons • Start, select, “analog”, L3, R3 http://en.wikipedia.org/wiki/DualShock 2
How Buttons Work • Pressure Sensitive • Button pad has a lower resistance than the conductor in the controller • The more the button is pressed, the more current passes through, which is measured • Analog Sticks • Two perpendicular potentiometers to control current • Current is measured to provide X and Y values http://www.gamesx.com/controldata/ps2pad.htm http://electronics.howstuffworks.com/playstation3.htm 2
Connections Data - controller to Playstation MISO Command - Playstation to controller MOSI Vibration - motors’ power line 9V Ground - (duh) Power - 3 - 5V Attention - slave select Clock - 100kHz to 500kHz White - Unused Acknowledge - slave acknowledge http://www.scribd.com/doc/86204752/Decoding-PS2-Wired-and-Wireless-Controller-for-Interfacing-With-PIC-Micro-Controller 3
Communication Protocol • Similar to SPI • Shared CLK, MOSI, MISO • Attention Line is similar to Slave Select in SPI • Additional ACK wire instead of ACK bit • Sequence of events for data transfer: • CLK is held high until data transfer • Attention must be pulled low for the data packet transfer and set high after • Once clock starts (8 cycles) 8 bits sent and received on the data and command lines LSB first • ACK pulled low for 12 microseconds after each byte 4 http://store.curiousinventor.com/guides/PS2/
Clk Command (MOSI) Attention (Slave Select) Acknowledge Data (MISO) • http://nearfuturelaboratory.com/2008/06/19/playstation2-logic-analysis/ 5
Communication Protocol • First three bytes – Header • Following bytes – Mode Dependent • Digital – 2 bytes • Analog – 18 bytes • Config - # bytes varies 6
Communication Protocol • First three bytes always a header • First byte • Command: 0x01 (indicates new packet) • Data: 0xFF • Second byte • Command: Main command (poll or configure controller) • Data: Device mode • Upper 4 bits: mode(4 = digital, 7 = analog, F = config) • Lower 4 bits: how many 16 bit words follow the header • Third Byte • Command: 0x00 • Data: 0x5A 7
Clk Command Attention (Slave Select) Acknowledge Data 79 5A FF • http://nearfuturelaboratory.com/2008/06/19/playstation2-logic-analysis/ 8
Communication Protocol • Following bytes dependent on command/mode • 2 to 18 more bytes, depending on mode • Digital - 2 more bytes • Each button given a bit • Analog - 18 more bytes • 2 bytes for digital buttons • Retrieves all analog and digital button states and pressures • Config - Depends on Command • First time entering returns either analog or digital state • Different commands while in config mode have different sets of response bytes 9
Important Commands • Polling • Get button states • Enter/Exit Config Mode • Toggle Analog/Digital (config mode only) • Map Motors (config mode only) 10
Main Polling Command 0x42 • Data Byte #2 • if digital mode = 0x41, only up to byte 5 is transmitted • if analog mode = 0x79 • W, Y – Can be used to control power sent to vibration motors if set in config mode 11
Clk Command Attention (Slave Select) Acknowledge Data • http://nearfuturelaboratory.com/2008/06/19/playstation2-logic-analysis/ 12
Button Mapping On Polls • Digital Mode • Data Byte 4 • Data Byte 5 • Buttons Active Low • Analog Mode • Data bytes 4 and 5 are the same • Analog Sticks range 0xFF -0x00, 0x7F is at rest • Pressure buttons range 0x00 - 0xFF, 0xFF is fully pressed 13
Enter/Exit Config 0x43 Command Byte #4 • 0x00 - exit config mode • 0x01 - enter config mode 14
Switching Modes (digital/analog) 0x 44 • Config Mode only • Command Byte #4 • 0x00 = set digital mode • 0x01 = set analog mode • Command Byte #5 • 0x03 = mode is locked • Otherwise analog button on the controller can toggle 15
Mapping Motor Command Bytes 0x4D • Config Mode only • 0x00 - Small motor mapping location • 0x01 - Large motor mapping location • 0xFF - not mapped 16
Questions? 17
Sources • http://store.curiousinventor.com/guides/PS2/ • http://www.gamesx.com/controldata/ps2pad.htm • http://en.wikipedia.org/wiki/DualShock • http://www.scribd.com/doc/86204752/Decoding-PS2-Wired-and-Wireless-Controller-for-Interfacing-With-PIC-Micro-Controller 18