Upload
aldous-stevens
View
220
Download
2
Tags:
Embed Size (px)
Citation preview
Playstation 2 ControllerKYLE 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
3
Controller Components• 2x Analog Sticks
• 16x Digital Buttons
• Two Vibration Motors
http://game-tips-etc.blogspot.com/2010/06/humble-ps2-controller.html
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
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.
6
Brown: data Master-in-slave-out
2008 CuriousInverter.com
7
Orange: command Master-out-slave-in
2008 CuriousInverter.com
8
Grey - Vibration motor power
2008 CuriousInverter.com
92008 CuriousInverter.com
10
Red - Power: 5 V.
PS1 would work at 3.3V
2008 CuriousInverter.com
11
Yellow - Attention:
Must be pulled low before each group of bytes is sent/received and set high afterwards
2008 CuriousInverter.com
12
Blue - Clock:
Ranges from 100kHz to 500kHz, normally 500.
2008 CuriousInverter.com
132008 CuriousInverter.com
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
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.
16
Sample Transaction
2008 CuriousInverter.com
17
Sample Transaction with Ack
2008 CuriousInverter.com
18
Sample Transaction with Attention
2008 CuriousInverter.com
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
20
Main Polling Command (0x42)
• Get digital responses from buttons,
• also control the vibration motors.
Motors Control & Button Digital Output
2008 CuriousInverter.com
21
Button Mapping• Byte 4 and 5 – Command/Mode dependent data
• Buttons are mapped to bytes 4 and 5 (active low)
2008 CuriousInverter.com
22
Main Polling Command (0x42)• Get analog response from the joysticks and buttons
Analog Joystick Output (optional)
Button Analog Output (optional)
2008 CuriousInverter.com
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
24
Switching Between Modes (0x44)• Command = 0x44
• Command.4 determines mode• 0x00 – Analog Mode• 0x01 – Digital Mode
2008 CuriousInverter.com
25
Other Config Commands• Adding/Removing responses
• Vibration control
• Get more status info
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 !
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
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
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 !
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
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