Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 28, 2024, 05:16:17 17:16


Login with username, password and session length


Pages: [1]
Print
Author Topic: Playstation 2 gamepad controller  (Read 3112 times)
0 Members and 1 Guest are viewing this topic.
coldfire
Guest
« on: September 09, 2007, 05:58:37 17:58 »

Hi All,

Anyone know how to interface Playstation 2 gamepad to PIC16 to robotic control? Thank you.

Regards
Logged
hankhill
Junior Member
**
Offline Offline

Posts: 44

Thank You
-Given: 30
-Receive: 1


« Reply #1 on: November 30, 2007, 11:43:06 11:43 »

Have a peep  at these:


h**p://sophiateam.undrgnd.free.fr/psx/index.html

and

h**p://users.ece.gatech.edu/~hamblen/489X/f04proj/USB_PSX/psx_protocol.html

and I haven't tested this

Code:
' This program reads the Sony Play Station 2 game controller data.
'Omer Yildiz Dec. 05; [email protected]


@ DEVICE intrc_osc, MCLR_OFF,WDT_OFF,PROTECT_OFF

TRISB = %01000111
TRISA = %00100000

DEFINE LCD_EREG PORTA   ' Set LCD Enable port
DEFINE LCD_EBIT 7       ' Set LCD Enable bit

dat var portb.6 ' Play Station game controller connections.
cmd var portb.7
att var portb.5
clk var portb.4

psxdata VAR Byte[7] ' Variable definitions.

start:
' The first shiftin gets the mode. (73)
' The next 2 shiftins gets the pushbutton data.
' The next 4 shiftins gets the analog joystick data.

    LOW att
    SHIFTOUT CMD,CLK,0,[$1\8,$42\8] ' Initiate request for data from PSX controller.
    SHIFTIN DAT,CLK,3,[psxdata[0]\8,psxdata[1]\8,psxdata[2]\8,psxdata[3]\8,psxdata[4]\8,psxdata[5]\8,psxdata[6]\8] ' This is the Mode value, it will be dumped.
    HIGH att

        LCDOUT $fe, 1,   #psxdata[3],",",#psxdata[5],",",#psxdata[1]      'see what is changing...
        LCDOUT $fe, $c0, #psxdata[4],",",#psxdata[6],",",#psxdata[2]

    pause 10

goto start

 
Logged

I don't have an anger problem. I have an IDIOT problem!
EDSONCT
Junior Member
**
Offline Offline

Posts: 36

Thank You
-Given: 72
-Receive: 5


WWW
« Reply #2 on: November 30, 2007, 01:23:56 13:23 »

This example is incomplete.

I made a pad with Freescale GT16 using DS2 dual Schock protocol.

Edson
Logged
frasenci
Translator
Active Member
***
Offline Offline

Posts: 171

Thank You
-Given: 142
-Receive: 84


« Reply #3 on: November 30, 2007, 02:50:27 14:50 »

This example is incomplete.

I made a pad with Freescale GT16 using DS2 dual Schock protocol.

Edson
And are you willing to help us indicating what is wrong with it ?
At first glance , I understand the BASIC code given is reading only the first value. Is it so ?
Greetings

Logged
EDSONCT
Junior Member
**
Offline Offline

Posts: 36

Thank You
-Given: 72
-Receive: 5


WWW
« Reply #4 on: November 30, 2007, 06:21:00 18:21 »

OK
The pad of the PS2 has some of 16 frames of command to adjust mode of operation.
Each frame has 8 bytes around with the method of configuration.
What is the site shows only the frame after programming the pad.
This is a first frame for Need for Speed Underground
NEED FOR SPEEDY UNDERGROUND JOY->PS2

FF 82 5A FF
FF 82 5A FF
FF CF 5A C0 40 00 40 80
FF CF 5A 00 00 80 40 00
FF CF 5A 00 00 80 80 80
FF CF 5A 00 00 40 00 80
FF CF 5A 00 00 00 20 00
FF CF 5A 00 00 00 E0 00
FF CF 5A FF FF FF FF FF
FF CF 5A 00 00 00 00 00
FF CF 5A 00 00 00 00 00
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF 82 5A FF
FF CF 5A 00 00 00 00 00
FF CF 5A 00 00 00 00 00
FF CE 5A FF
FF CE 5A FF
FF CE 5A FF FF 7E 7E FE
FF CF 5A C0 40 80 40 80
FF CF 5A 00 00 80 40 00
FF CF 5A 00 00 80 80 80
FF CF 5A 00 00 40 00 80
FF CF 5A 00 00 00 20 00
FF CF 5A 00 00 00 E0 00
FF CF 5A FF FF FF FF FF
FF CF 5A FF FF C0 00 00
FF CF 5A 00 00 00 00 00



Posted on: November 30, 2007, 05:49:30 17:49 - Automerged

PAD low-level specs by [RO]man / (v1.0, 2004, Florin Sasu)
----------------------------------------------------------

DEVICE MODES
0 5    3+2*1 01      UNUSED
1 7    3+2*2 12      MOUSE
4 5    3+2*1 41      STANDARD(DIGITAL)
7 9,21 3+2*3 73/79   ANALOG
2 9    3+2*3 23      NEGI-CON(NEGICON/NASKA/VOLUME)
5 9    3+2*3 53      JOY STICK(ANALOGJOYSTICK)
3 5    3+2*1 31      KONAMI-GUN
6 9    3+2*3 63      NAMCO-GUN
E 9,13 3+2*3 E3/E5   JOGCON
F 9    3+2*3 F3      CONFIG
8            80         MULTITAP
| |        | |          +------------ name
| |        | +----------------------- modeId
| |        +------------------------- lo-nibble of modeId
| +---------------------------------- size of command
+------------------------------------ hi-nibble of modeId

COMMANDS

Notes:
 1. 0x5A in send commands clears the corresponding positions in recv buffer
      as they will be filled with requested data (see cmd=0x43)
================================================================================
@ 0x40  // SET_VREF_PARAM
                 +------------------- ith                (0->11)
                 |  +---------------- vref[ith]          (2 or vrefBuffer[idx])
        01,40,00,02,02,xx,xx,xx,xx                       (xx=00)
        FF,F3,5A,00,00,02,00,00,5A
================================================================================
A 0x41  // QUERY_BUTTON_MASK
   0  1  2  3  4  5  6  7  8
   01,41,00,5A,5A,5A,5A,5A,5A
        FF,F3,5A,FF,FF,03,00,xx,5A                       (xx=00)
                 |  |  |  |     +---- (must be pressent here!!!)
                 |  |  |  +---------- bmask3
                 |  |  +------------- bmask2
                 |  +---------------- bmask1
                 +------------------- bmask0
================================================================================
B 0x42  // READ_DATA

 01 42 00 xx xx
 FF 41 5A FF FF --------------------- 04/digital
          +--+----------------------- buttons status (1released/0pushed)
 01 42 00 xx xx
 FF 41 5A FF FF --------------------- 04/digital
          +--+----------------------- buttons status
================================================================================
C 0x43  // ENTER/EXIT_CONFIG_MODE; i.e. exit device mode and enter config mode
          +-------------------------- 00 - exit config / 01 enter config
 01 43 00 00 5A 5A 5A 5A 5A
 FF F3 5A 00 00 00 00 00 00 --------- new data (6 bytes)
 01 43 00 01 00
 FF 41 5A FF FF --------------------- old data (2 bytes)
 01 43 00 01 00 00 00 00 00
 FF 73 5A FF FF 69 78 77 84 --------- old data (6 bytes)
 01 43 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 FF 79 5A FF FF 69 78 77 84 00 00 00 00 00 00 00 00 00 00 00 00 old data (18 bytes)
================================================================================
D 0x44   // SET_MAIN_MODE; i.e. set mode and lock
                 +------------------- mode
                 |  +---------------- lock
   01,44,00,MM,LL,xx,xx,xx,xx                       (xx=00)
   FF,F3,5A,00,00,00,00,00,00
================================================================================
E 0x45   // QUERY_MODEL; i.e. query model and mode
   01,45,00,5A,5A,5A,5A,5A,5A
        FF,F3,5A,01,02,00,02,01,00
                 |  |  |  |  |  +---- Huh
                 |  |  |  |  +------- noOfComb: 01
                 |  |  |  +---------- noOfAct: 02 - DUALSHOCK / 01 - JOYSTICK
                 |  |  +------------- modeCurOffs: 00 - digital / 01 - analog/joystickmode
                 |  +---------------- noOfmodes: 02
                 +------------------- model: 01 - dualshock / 03 - dualshock2
================================================================================
F 0x46  // QUERY_ACT
                 +------------------- idx of act
        01,46,00,00,5A,5A,5A,5A,5A
   FF,F3,5A,00,xx,01,02,00,0A DUALSHOCK small motor (100mA, xx=00)
        FF,F3,5A,00,xx,04,03,01,1E JOYSTICK              (300mA, xx=00)
   01,46,00,01,5A,5A,5A,5A,5A
   FF,F3,5A,00,xx,01,01,01,14 DUALSHOCK big motor   (200mA, xx=00)
                    |  |  |  |  +---- curr (10mA units)
                    |  |  |  +------- length (0: 1 bit (on/off only),
                    |  |  |                   1 or more: number of bytes)
                    |  |  +---------- subfunction (1: low-speed rotation,
                    |  |                           2: high-speed rotation)
                    |  +------------- function (1: continuous rotation vibration)
================================================================================
G 0x47  // QUERY_COMB
                 +------------------- idx of comb
        01,47,00,00,5A,5A,5A,5A,5A
   FF,F3,5A,00,xx,02,00,01,xx DUALSHOCK             (xx=00)
        FF,F3,5A,00,xx,01,00,xx,xx JOYSTICK              (xx=00)
                    |  |  |  |  +---- act2 in comb
                    |  |  |  +------- act1 in comb
                    |  |  +---------- act0 in comb
                    |  +------------- noOfAct in comb
================================================================================
L 0x4C  // QUERY_MODE
                 +------------------- idx of mode
        01,4C,00,00,5A,5A,5A,5A,5A
   FF,F3,5A,00,xx,00,04,xx,xx DIGITAL DUALSHOCK     (mode=0x0004, xx=00)
   FF,F3,5A,00,xx,00,04,xx,xx DIGITAL JOYSTICK      (mode=0x0004, xx=00)
   01,4C,00,01,5A,5A,5A,5A,5A
   FF,F3,5A,00,xx,00,07,xx,xx ANALOG DUALSHOCK      (mode=0x0007, xx=00)
   FF,F3,5A,00,xx,03,00,xx,xx ANALOG JOYSTICK       (mode=0x0300, xx=00)
                    |  |  +---------- lo of mode         (mode is u_short)
                    |  +------------- hi of mode
================================================================================
M 0x4D  // SET_ACT_ALIGN; i.e. vibration enable
                 +--+--+--+--+--+---- act align buffer of 6 bytes
        01,4D,00,00,01,FF,FF,FF,FF
   FF,F3,5A,FF,FF,FF,FF,FF,FF
================================================================================
O 0x4F  // SET_BUTTON_INFO
                 +--+--+--+---------- button info buffer of 4 bytes
        01,4F,00,FF,0F,00,00,00,00 mask for 12 buttons (w/o SELECT/START/L3/R3)
   FF,F3,5A,00,00,00,00,00,5A
================================================================================
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC