PlayStation 2 controllerx

advertisement
Playstation 2 Controller
David Domanico
Justin Kaput
1
Buttons (Dual Shock 2)
•
•
2 analog sticks
12 pressure sensitive
buttons
o
•
Square, triangle, circle, x,
directional pad, L1, L2, R1, R2
5 digital buttons
o
Start, select, “analog”, L3, R3
http://en.wikipedia.org/wiki/DualShock
2
How Buttons Work
•
http://www.gamesx.com/controldata/p
s2pad.htm
•
Pressure Sensitive
o Button pad has a lower resistance than the
conductor in the controller
o The more the button is pressed, the more
current passes through, which is measured
Analog Sticks
o Two perpendicular potentiometers to control
current
o Current is measured to provide X and Y values
http://electronics.howstuffworks.com/p
laystation3.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
http://www.scribd.com/doc/86204752/Decoding-PS2-Wired-and-Wireless-Controller-for-Interfacing-With-PIC-Micro-Controller
Acknowledge - slave acknowledge
3
Communication Protocol
•
•
Similar to SPI
o
Shared CLK, MOSI, MISO
o
Attention Line is similar to Slave Select in SPI
o
Additional ACK wire instead of ACK bit
Sequence of events for data transfer:
o
CLK is held high until data transfer
o
Attention must be pulled low for the data packet
transfer and set high after
o
Once clock starts (8 cycles) 8 bits sent and
received on the data and command lines LSB
first
o
ACK pulled low for 12 microseconds after each
byte
http://store.curiousinventor.com/guides/PS2/
4
Clk
Command
(MOSI)
Attention
(Slave Select)
Acknowledge
Data
(MISO)
http://nearfuturelaboratory.com/2008/06/19/play
station2-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
o
o
o
First byte

Command:
0x01 (indicates new packet)

Data:
0xFF
Second byte

Command:

Data:
Device mode
• Upper 4 bits: mode(4 = digital, 7 = analog, F = config)
• Lower 4 bits: how many 16 bit words follow the header
Main command (poll or configure controller)
Third Byte

Command:
0x00

Data:
0x5A
7
Clk
Command
Attention
(Slave Select)
Acknowledge
Data
FF
79
5A
http://nearfuturelaboratory.com/2008/06/19/play
station2-logic-analysis/
8
Communication Protocol
•
Following bytes dependent on command/mode
o
2 to 18 more bytes, depending on mode
 Digital - 2 more bytes
•

Analog - 18 more bytes
•
•

Each button given a bit
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
Byte #
1
2
3
4
5
6-21
(only in analog mode)
Command
0x01
0x42
0x00
W
Y
0x00
Data
0xFF
Mode
Dependent
0x5A
Digital bits
o
Data Byte #2
o
o
o
Analog Bytes
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
Byte #
1
2
3
4
5
6-21
(only in analog mode)
Command
0x01
0x42
0x00
W
Y
0x00
Data
0xFF
Mode
0x5A
Digital bits
http://nearfuturelaboratory.com/2008/06/19/play
station2-logic-analysis/
Analog Bytes
12
Button Mapping On Polls
•
Digital Mode
Data Byte 4 Button
Data Byte 5 Button
Buttons Active Low
o
o
•
Bit
o
0
1
2
3
4
5
6
7
Select
L3
R3
Start
Up
Right
Down
Left
L2
R2
L1
R1
Triangle
O
X
Square
Analog Mode
o
Data bytes 4 and 5 are the same
o
Analog Sticks range 0xFF -0x00, 0x7F is at rest
o
Pressure buttons range 0x00 - 0xFF, 0xFF is fully pressed
Byte
6
7
Button
RX
RY
8
LX
9
LY
10
Right
11
12
Left
Up
13
Down
14
15
16
O
X
17
18
L1
19
R1
20
L2
21
R2
13
Enter/Exit Config 0x43
Byte #
1
2
3
4
5
6-21
(only in analog
mode)
Command
0x01
0x43
0x00
Enter/Exit
0x00
0x00
Data
0xFF
Mode
dependent
0x5A
Digital bits
Analog Bytes
Command Byte #4
0x00 - exit config mode
0x01 - enter config mode
•
•
14
Switching Modes (digital/analog) 0x 44
Byte #
1
2
3
4
5
6-9
Command
0x01
0x44
0x00
D/A
Lock?
0x00
Data
0xFF
0xF3
0x5A
Config
•
•
•
Config
Config Mode only
Command Byte #4
o 0x00 = set digital mode
o 0x01 = set analog mode
Command Byte #5
o 0x03 = mode is locked
o Otherwise analog button on the controller can toggle
15
Mapping Motor Command Bytes 0x4D
Byte #
1
2
3
4
5
6-9
Command
0x01
0x4D
0x00
0x00
0x01
0xFF
Data
0xFF
0xF3
0x5A
Current Mapping
•
•
•
•
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-PICMicro-Controller
18
Download