Você está na página 1de 19

Playstation 2 Controller

David Domanico
Justin Kaput

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

How Buttons Work

http://www.gamesx.com/controldata/ps
2pad.htm

http://electronics.howstuffworks.com/pl
aystation3.htm

Pressure Sensitive

Analog Sticks

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
o Two perpendicular potentiometers to control
current
o Current is measured to provide X and Y values
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

Communication Protocol

Similar to SPI
o

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:


o

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
http://store.curiousinventor.com/guides/PS2/

Clk

Command
(MOSI)
Attention
(Slave Select)

Acknowledge
Data
(MISO)

http://nearfuturelaboratory.com/2008/06/19/plays
tation2-logic-analysis/

Communication Protocol
First three bytes Header
Following bytes Mode Dependent

Digital 2 bytes
Analog 18 bytes
Config - # bytes varies

Communication Protocol

First three bytes always a header


o

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

Clk

Command
Attention
(Slave Select)

Acknowledge
Data
FF

79

5A

http://nearfuturelaboratory.com/2008/06/19/plays
tation2-logic-analysis/

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

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 #

6-21
(only in analog mode)

Command

0x01

0x42

0x00

0x00

Data

0xFF

Mode
Dependent

0x5A

Digital bits

Data Byte #2
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 #

6-21
(only in analog mode)

Command

0x01

0x42

0x00

0x00

Data

0xFF

Mode

0x5A

Digital bits

http://nearfuturelaboratory.com/2008/06/19/plays
tation2-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

Select

L3

R3

Start

Up

Right

Down

Left

L2

R2

L1

R1

Triangle

Square

Analog Mode
o

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

Byte

Button

RX

RY

8
LX

9
LY

10
Right

11

12

Left

Up

13
Down

14

15

16

17

18
L1

19
R1

20
L2

21
R2

13

Enter/Exit Config 0x43


Byte #

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 #

6-9

Command

0x01

0x44

0x00

D/A

Lock?

0x00

Data

0xFF

0xF3

0x5A

Config

Config Mode only


Command Byte #4

Command Byte #5

Config

o 0x00 = set digital mode


o 0x01 = set analog mode
o 0x03 = mode is locked
o Otherwise analog button on the controller can toggle

15

Mapping Motor Command Bytes 0x4D


Byte #

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-PIC-Micr
o-Controller

18