Uploaded by Leonardo Silva

PlayStation 2 DualShock 2 Controller. Ryan O Keefe, Kabir Singh and Adrian Padin

advertisement
PlayStation 2
DualShock 2 Controller
Ryan O’Keefe, Kabir Singh and Adrian Padin
1
PlayStation 2 Controller - Overview
I. Previous Methods
○
NES Controller, N64
II. DualShock 2: Input Types
○
○
○
Twelve analog buttons
Five digital buttons
Analog directional sticks
https://upload.wikimedia.
org/wikipedia/commons/f/f9/PSX-Original-Controller.jpg
III. DualShock 2: Communication Interface
○
○
SPI Communication
Transfer up to 21 bytes of data
2
Previous Methods - NES Controller
● Remember Lab 7 from EECS 270?
● Four Digital Buttons and the Directional Joypad
○
Only 1 bit precision for each button
● Communicates with console using shift registers
● Console initiates by sending a pulse on the latch wire
● Controller sends 8 pulses and the status of each button
http://www.eecs.umich.edu/courses/eecs270/270lab/270_docs/lab7.html
https://upload.wikimedia.
org/wikipedia/commons/8/83/NEScontroller.jpg
3
Previous Methods - N64 Controller
● Fourteen Digital Buttons and the
“Analog” Joystick
● N64 was first controller to have a
motor for vibration feedback
● Had “Analog” joystick which was
essentially a digital counter
● What makes PS2 different?
http://static.giantbomb.
com/uploads/original/0/7465/968375n64_controller.jpg
4
PlayStation 2 - DualShock 2 Features
Increase number of buttons and other options:
● Twelve analog buttons
○
8 bits of precision for each button
● Five digital buttons
● Full analog directional sticks
○
2 Bytes of precision, 8 bits for X position
and 8 bits for each Y position
● Variable Force-feedback
http://s.hswstatic.com/gif/ps2-controller.jpg
○
Weighted motors cause controller to vibrate
5
DualShock 2 - Force Feedback
● DualShock - Two vibration motors
○
One of the first controllers with feature
● Left motor provides stronger feedback
than right
● Variable feedback for better game
immersion
http://images.dailytech.
com/nimage/4096_ps2b240.jpg
6
DualShock 2 - Analog Sticks
● Two perpendicular potentiometers per stick
● Two byte precision
○
One byte each for X and Y axis
● Completely analog signal
○
Variable resistance changes voltage levels
http://i.ebayimg.
com/images/g/8pAAAOxygPtS-PX~/s-l500.jpg
http://i.ebayimg.
com/images/g/8pAAAOxygPtS-PX~/s-l500.jpg
7
DualShock 2 - Analog Buttons
● All buttons except ‘Start’, ‘Select’, ‘L3’,
‘R3’, and ‘Analog’ are analog
● Each button has 8 bit encoding
○
Harder press => higher value (0-255)
● Achieved through variable parallel
resistance
http://i.ebayimg.com/images/g/CmkAAOSwDk5T-U9b/s-l1600.jpg
Resistor
https://d3nevzfk7ii3be.cloudfront.net/igi/6IKeCIbrpwrVqm6q.huge
8
Communicating with the PlayStation 2
Basic premise is SPI (Serial Peripheral Interface):
●
●
●
●
One master (PS2 console) and many slaves (controllers)
All devices use the same bus (open collector scheme)
Master and slave communicate at the same time using shift registers
As the master sends data, it receives incoming data from the slave
http://operationrainfall.com/
http://ecx.images-amazon.com/
9
Controller Interface - SPI Overview
Four wires to remember:
1.
2.
3.
4.
MOSI (Master Out Slave In) - data from the console to the controller
MISO (Master In Slave Out) - data from the controller to the console
Clock - both units must be timed to the same clock
Select - pick which device to read from
Clock
Master
(PS2 Console)
Shift Register
Select (Attention)
MOSI
Slave
(Controller)
Shift Register
MISO
10
DualShock 2 - Communication Hardware
●
●
http://store.curiousinventor.com/guides/PS2
Brown (controller->console) - Data sent to
console (buttons, analog sticks)
Orange (console->controller) - Data sent to
controller (vibration)
●
●
●
Red (power) - 3.3 V
Grey (motor power) - usually 7.4 V
Black (ground)
●
●
●
Yellow (attention) - slave select
Blue (clock) - generated by master
Green (acknowledge) - controller must
respond within 100 µs
11
DualShock 2 - Sample Transaction
http://store.curiousinventor.com/guides/PS2
12
DualShock 2 - Sample Transaction
1. Console pulls clock down to
initiate transaction
http://store.curiousinventor.com/guides/PS2
13
DualShock 2 - Sample Transaction
1. Console pulls clock down to
initiate transaction
2. Controller changes data line to
reflect status
http://store.curiousinventor.com/guides/PS2
14
DualShock 2 - Sample Transaction
1. Console pulls clock down to
initiate transaction
2. Controller changes data line to
reflect status
3. On each rising edge the data is
shifted from controller into
console
http://store.curiousinventor.com/guides/PS2
15
DualShock 2 - Sample Transaction
1. Console pulls clock down to
initiate transaction
2. Controller changes data line to
reflect status
3. On each rising edge the data is
shifted from controller into
console
4. After eight rising edges, clock
remains high to signal end of
transaction. A single byte has
now been transferred
http://store.curiousinventor.com/guides/PS2
16
DualShock 2 - Transfer Protocol
Start with 3-byte Header
1st Byte: Initiate the transaction
*This is the same every time.
Byte Number Master Controller
Information Type
1
0x01
0xFF
Initiate
2
0x42
0x79
Controller Mode
3
0x00
0x5A
Handshake
2nd Byte: The console specifies which mode it wants:
0x41 = digital mode (no analog stick or analog button data)
0x42 = analog mode (full 21 bytes of data)
3rd Byte: Handshake to indicate that the controller is ready to transmit data
17
DualShock 2 - Transfer Protocol
Bytes 4 and 5 are the digital states
of every button (similar to NES
controller):
● 0 - the button is pressed
● 1 - the button is not pressed
Byte Number Master Controller
Information Type
1
0x01
0xFF
Initiate
2
0x42
0x79
Controller Mode
3
0x00
0x5A
Handshake
4
0xLL
0xNN
Digital Buttons
5
0xRR
0xNN
Digital Buttons
4th byte: 0xNN is state of buttons select, L3, R3, start, up, right, down, and left.
0xLL is vibration data for left motor
5th byte: 0xNN is state of buttons L2, R2, L1, R1, triangle, circle, X, square
0xRR is vibration data for right motor
18
Byte
DualShock 2
If Analog Mode is specified
(0x42), the controller sends
another 16 bytes of data
● X and Y position of the
left and right analog sticks
● Analog position of every
button except start and
select
● Each button has 8 bits of
precision (256 possible
states)
Master
Controller Information Type
1 0x01
0xFF
Header (initiate transaction)
2 0x42
0x79
Header (transaction mode)
3 0x00
0x5A
Header (sort of handshake)
4 0xLL
0xNN
Digital (select, L3, R3, start, up, right, down, left)
5 0xRR
0xNN
Digital (L2, R2, L1, R1, triangle, circle, X, square)
6 0x00
0xNN
Right Analog Stick X
7 0x00
0xNN
Right Analog Stick Y
8 0x00
0xNN
Left Analog Stick X
9 0x00
0xNN
Left Analog Stick Y
10 0x00
0xNN
Right Button Analog
11 0x00
0xNN
Left Button Analog
12 0x00
0xNN
Up Button Analog
13 0x00
0xNN
Down Button Analog
14 0x00
0xNN
Triangle Button Analog
15 0x00
0xNN
Circle Button Analog
16 0x00
0xNN
X Button Analog
17 0x00
0xNN
Square Button Analog
18 0x00
0xNN
L1 Button Analog
19 0x00
0xNN
R1 Button Analog
20 0x00
0xNN
L2 Button Analog
21 0x00
0xNN
R2 Button Analog
19
Demonstration
Interfacing a PS2 Controller with an Arduino
20
PlayStation 2 Controller - Summary
● Improvements from Previous Methods
○
○
Adds versatility to control system
Reduces lag because it is not being constantly polled
● Analog Sticks and Buttons
○
○
○
12 buttons each with 8 bits of precision
2 analog sticks with 16 bits of precision
5 digital buttons
● Communication and Transfer Protocol
○
○
○
Modified form of SPI
Sends 8 bits at once on open-collector bus
Digital mode is 5 bytes, Analog mode is 21 bytes
21
Bibliography
NES Controller Background:
http://www.eecs.umich.edu/courses/eecs270/270lab/270_docs/lab7.html
N64 Controller Background:
https://www.eecs.umich.edu/courses/eecs373/Lec/W16_talks/The%20N64%20Controller.pdf
Transfer Protocol:
http://www.gamesx.com/wiki/doku.php?do=&id=controls%3Aplaystation2_controller
Interfacing to a PS2 Controller (this site was the most helpful):
http://store.curiousinventor.com/guides/PS2
Using a PS2 controller with an Arduino:
http://www.billporter.info/2010/06/05/playstation-2-controller-arduino-library-v1-0/
22
Download