Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

31
Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1

Transcript of Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

Page 1: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

Playstation 2 ControllerKYLE YAN

AKSHAY MOORTHY

YIPING KANG

1

Page 2: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

Outline

◦ PS2 Controller Components

◦ Hardware Interface

◦ Bytes and Packets Transfer Mechanism

◦ Packet Structure

◦ Frequently Used Commands

◦ Example

2

http://www.walmart.com/ip/Sony-DualShock-2-PS2-Controller-Black-PlayStation-2/907869

Page 3: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

3

Controller Components• 2x Analog Sticks

• 16x Digital Buttons

• Two Vibration Motors

http://game-tips-etc.blogspot.com/2010/06/humble-ps2-controller.html

Page 4: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

4

Buttons, Joysticks and Vibration• Buttons

◦ A tiny curved conduction strip attached to the bottom◦ More pressure -> More conductivity

• Joysticks◦ Two potentiometers below each joystick◦ Different angle -> Different resistance

• Vibration◦ Two spinning motors (one big, one small)◦ Controlled separately

http://www.dansdata.com/tmsticks.htm

Page 5: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

5

Wiring• Brown - Data: MISO

• Orange - Command: MOSI

• Grey - Vibration motor power: 6-9 V

• Red - Power: 5 V. PS1 would work at 3.3V

• Yellow - Attention: Must be pulled low before each group of bytes is sent/received and set high afterwards

• Blue - Clock: Ranges from 100kHz to 500kHz, normally 500.

• Green - Ack: Normally high and drops low for 12 us after each byte for half a clock cycle. Open collector output.

Page 6: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

6

Brown: data Master-in-slave-out

2008 CuriousInverter.com

Page 7: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

7

Orange: command Master-out-slave-in

2008 CuriousInverter.com

Page 8: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

8

Grey - Vibration motor power

2008 CuriousInverter.com

Page 9: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

92008 CuriousInverter.com

Page 10: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

10

Red - Power: 5 V.

PS1 would work at 3.3V

2008 CuriousInverter.com

Page 11: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

11

Yellow - Attention:

Must be pulled low before each group of bytes is sent/received and set high afterwards

2008 CuriousInverter.com

Page 12: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

12

Blue - Clock:

Ranges from 100kHz to 500kHz, normally 500.

2008 CuriousInverter.com

Page 13: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

132008 CuriousInverter.com

Page 14: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

14

Green - Acknowledge

Normally high and drops low for 12 us after each byte for half a clock cycle. Open collector output.

acknowledge

2008 CuriousInverter.com

Page 15: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

15

How Bytes and Packets Are Transferred• Playstation sends command at the same time it receives one data through serial communication

• Clock is held high until a byte is about to be send. Then it drops low to start a 8 cycles where command and data is simultaneously send and received.

• Reads occurs on rising edge of the clock.

• LSB is transferred first.

Page 16: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

16

Sample Transaction

2008 CuriousInverter.com

Page 17: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

17

Sample Transaction with Ack

2008 CuriousInverter.com

Page 18: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

18

Sample Transaction with Attention

2008 CuriousInverter.com

Page 19: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

19

Packet Structure Header is always first 3 bytes

• Most Common Commands• 0x42 - Polling buttons• 0x43 – Enter/Exit Config Mode

Byte # 1 2 3Command 01 Main Command 00

Data FF Device Mode 5A

• Device Modes• 0x4X – Digital Mode• 0x7X – Analog Mode• 0xFX – Config Mode

Page 20: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

20

Main Polling Command (0x42)

• Get digital responses from buttons,

• also control the vibration motors.

Motors Control & Button Digital Output

2008 CuriousInverter.com

Page 21: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

21

Button Mapping• Byte 4 and 5 – Command/Mode dependent data

• Buttons are mapped to bytes 4 and 5 (active low)

2008 CuriousInverter.com

Page 22: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

22

Main Polling Command (0x42)• Get analog response from the joysticks and buttons

Analog Joystick Output (optional)

Button Analog Output (optional)

2008 CuriousInverter.com

Page 23: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

23

Enter/Exit Config Command (0x43)• Config mode allows you to change multiple settings

• Command.4• 0x01 Enter Config• 0x00 Exit Config

2008 CuriousInverter.com

Page 24: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

24

Switching Between Modes (0x44)• Command = 0x44

• Command.4 determines mode• 0x00 – Analog Mode• 0x01 – Digital Mode

2008 CuriousInverter.com

Page 25: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

25

Other Config Commands• Adding/Removing responses

• Vibration control

• Get more status info

Page 26: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

26

Walkthrough Example

1. Enter config mode

2. Map motors to byte 4 and 5

3. Config the controller to return all values

4. Exit config mode

5. Main polling !

Page 27: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

27

Walkthrough Example

1. Enter config mode

2. Map motors to byte 4 and 5

3. Config the controller to return all values

4. Exit config mode

5. Main polling !

0x00 – small motor0x01 – big motor

Map byte 4 to big motor byte 5 to small motor

Page 28: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

28

Walkthrough Example

1. Enter config mode

2. Map motors to byte 4 and 5

3. Config the controller to return all values

4. Exit config mode

5. Main polling !

• Byte 4 , byte 5 and the two LSB of byte 6 = 18 bits

• Corresponding to 18 bytes in data under main polling command

• ‘1’ indicates the response to be present in the data

Page 29: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

29

Walkthrough Example

1. Enter config mode

2. Map motors to byte 4 and 5

3. Config the controller to return all values

4. Exit config mode

5. Main polling !

Page 30: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

30

Walkthrough Example

1. Enter config mode

2. Map motors to byte 4 and 5

3. Config the controller to return all values

4. Exit config mode

5. Main polling !

Digital Analog Stick Button Pressure (Right fully pressed here)

Motor Control

Page 31: Playstation 2 Controller KYLE YAN AKSHAY MOORTHY YIPING KANG 1.

31

Reference Spinning Motor

http://www.dansdata.com/tmsticks.htm

Interfacing with a PS2 controller

http://store.curiousinventor.com/guides/PS2/

http://www.lynxmotion.com/images/files/ps2cmd01.txt

How buttons and joystick works

http://www.howstuffworks.com/ps23.htm