Author Topic: ¿How to connect PS2 Dual Shock 2 controllers to the PSP using serial port?  (Read 22699 times)

Offline EliteGamer83

  • Millennium Poster
  • *
  • Posts: 1233
  • Post quality +0/-0
  • Gender: Male
  • Trusted Seller! Slim Modder! Graphics Artist!
Yeah Ghost and Alien, What is TXD and RXD?

Alien, I mean I am not sure how to wire most of it only the ground and + LOL.

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
thats wat im trying to figure out what those mean

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline GhoSt

  • Creating Null
  • Around the block
  • *
  • Posts: 2552
  • Post quality +19/-0
  • Gender: Male
  • Null Pointer Exception
I have little knowledge on this. But I belive TXD is a form of transmitting the data, and RXD a state of reciving it.
|Variegation - GhoSt's Final Controller|

|Nothing is deterministic.|

Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
I think you are misunderstanding this entirely. You cannot just connect the command and data pins from the dualshock to the TX and RX of the serial port - especially not to use with Jean's pikey driver. Firstly you have to use a step-up dc boost circuit such as this one (the same I am using - and I think BLizzrad)



Then you have to include a microcontroller between the dualshock, and the psp Serial port. The microcontroller is initializing the dualshock, and reading it's digital button data in the 4th and 5th byte - and analog pressure values and joystick values in bytes 6 to 21 depending on which mode it has been initiated into (this is all done via SPI). It is then acting on these commands, and communicating via usart to the psp's SIO port, where it is sending ASCII characters which are interpreted by the driver and pikey and computed into button pressed.

Now I could go into more detail about the commands which have to sent and received to make that all happen, but that would just mean I am copying the commands from someone elses guide.
For the ps2 side of communication read here as well:

http://www.gamesx.com/controldata/psxcont/psxcont.htm

Also, for the record I don't consider myself to be anything close to a modding legend, even if I do act as if those are my feelings.  I am usually very stressed out when I am posting on acidmods, so that is why my posts aren't usually the kindest replies they could be - although if you catch me in a nice mood I am always happy to help :) (such as today). In the grand scheme of things my knowledge about anything electronics related is actually next to nothing, especially compared to some people on this site - Jube, Gr8npwrfl, Blizzrad, 802Chives etc.
« Last Edit: April 20, 2009, 11:12:00 AM by Alien_X »

Sigs by Alien_X
www.ax-elec.com

Offline GhoSt

  • Creating Null
  • Around the block
  • *
  • Posts: 2552
  • Post quality +19/-0
  • Gender: Male
  • Null Pointer Exception
I understand that, I am unclear on is what the microcontroller is processing the signal from the controller into? What signal the psp will read through the serial port.

Btw alein don't be modest, you are much more knowledged on electronics than most of us will ever be. Although we are all still learning, including you I guess. Never talk to alein while he is busy or with ultra nubish questions which annoy him, you will find yourself blocked... :winker:
|Variegation - GhoSt's Final Controller|

|Nothing is deterministic.|

Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
Hehe, "ulta nubish" questions being ones where you haven't even bothered to do any research yourself, yeah.

Sigs by Alien_X
www.ax-elec.com

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
its not easy finding stuff like this idk i have hard time trying to find things compared to this

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
What is it you are having trouble with? I am sure we could find some relevant links for you, or help to answer your questions.

Sigs by Alien_X
www.ax-elec.com

Offline Blizzrad

  • Chaos Lover
  • *
  • Posts: 267
  • Post quality +0/-0
Basically, the microcontroller is acting as a translator between two incompatible serial protocols. There are many different serial communication protocols that devices use for sending and receiving data, which are not directly compatible with other protocols.

Imagine two people who are trying to talk to each other, but each is following totally different rules of sentence structure. They will not be able to communicate properly because they have not agreed on what should be the proper format for structuring their ideas. In the case of the PSP and Ps2 controller, the PSP serial port uses the R232 protocol and the Ps2 controller uses a protocol called SPI (although sony has given the pins their own funny names).

RS232 has been around a long time, and is the same protocol that is used by the serial ports on the back of older PCs (these are quickly being phased out now on new machines). The PSP SIO port can be directly linked to a PC using one of these ports without any need to translate the data, though a voltage level shifter is needed because the PSP and PC serial ports operate at different voltages (+12v and -12v for PC, +2.5v and 0v for PSP). As Ghost_Death stated, the RX and TX lines stand for transmit and receive, and are used for what their names imply. Though this never fails to confuse me when making connections because TX must be connected with RX of the device on the other end, and I always mix up which ones are relative to which.   

The Ps2 controller uses another common protocol called SPI which is used to link many devices together on a shared data bus, this means fewer wires need to be used but adds a little more complexity to the protocol. SPI is synchronous, which means there is also a clock line that allows each device to know when data should be read on the data lines, since RS232 is an asynchronous protocol (no clock line), it cant be used to interface SPI devices without some type of translating device inbetween.

This is where the microcontroller comes in, fortunately many microcontrollers have built in hardware support for both RS232 and SPI, which makes things a lot simpler. The Ps2 controllers also have their own protocol on top of SPI that dictates when and where certain commands should be placed into each packet to initialize the controller and get it to return certain data. This is the bulk of what is happening in the code I linked earlier; getting the controller set up, and then continually polling it at roughly 60 times per second. The data returned from the controller can then be restructured and rearranged into whatever format is required by the second device, and sent on it's way.

The correct format for sending data to the PSP SIO port all depends on the software you are using and what it is supposed to do, unless the software assigns some significance to the bytes it receives then it is just useless data. In my video, I used a driver written by Jean for the open keyboard project which can remap buttons based on bytes received at the SIO port. In this case the driver looks for ASCII characters (numbers which have an assigned alphabet/character value according to the ASCII table). In the test app I wrote, it was easier to use an interrupt driven protocol that tells the microcontroller when it should send data, and then the microcontroller just sends along the relevant bytes without modifications. In this case the software was written to already know which bits in each byte correspond to the individual buttons on the Ps2 controller, and then display the status of each button on the screen. If this sounds a bit complicated, it's because I am not good at explaining stuff like this, but everything I have done here is actually pretty simple.

If you really want to get a better understanding of this stuff, I think the best way is to get into microcontroller programming. Once you start writing code to push bits and bytes around and make all of this craziness happen, it starts making a lot more sense. Contrary to what many people believe, you don't have to be smart or know a lot about math to learn to write code, you mostly just need patience and a few good books on the subject.
« Last Edit: April 20, 2009, 01:05:28 PM by Blizzrad »

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
yea i think im gonna do that i wonder if some of these college have classes that explain microcontrollers

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
If you know which brand of 8 bit microcontrollers you want to learn with, and what language you would like to program for them in, then pretty much all the information you need to know is on the internet and in the datasheets.


Sigs by Alien_X
www.ax-elec.com

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
oo kinda lie this i found this like not long ago
http://www.mikroe.com/en/books/picbasicbook/00.htm

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
Okay, that is a good way to start with microcontrollers.
If you live in the UK, there is a book recently published by EPE called "electronics teach in 2". It is an almost comprehensive guide to everything PIC related - how to interface pretty much anything, description of various communication protocols etc. It focuses mainly on coding in ASM (MPASM to be precise) which I would recommend as being the best language to code for PICs in - however if you don't have knowledge of embedded electronics basics then it would be pretty confusing at first.

I would also suggest that you research AVRs and other programming languages for PICs as well before diving in and spending your money on a compiler.

Sigs by Alien_X
www.ax-elec.com

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
Yea ok cuz im gonna start reading through that and ill look up the AVRs u mentioned.
Yea i dnt have a lot fo money at the moment so i gotta be wise on what i get.

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline rceckspurt13

  • Acid Modder
  • *
  • Posts: 637
  • Post quality +2/-0
  • Gender: Male
hey drazzer, have you ever thought of making a product like the one in your video, available for people to purchase? I'm sure there would be a lot of intrest in a way to use a ps2 controller on a PSP without mods.
Any Questions? Please Contact Me: rceckspurt13@gmail.com

Offline menwhar12

  • Fart Sniffer
  • *
  • Posts: 42
  • Post quality +0/-0
  • Gender: Male
  • psp phat- 5.00-6 m33
so how exactly do you change the program on the controller. what i mean is how do you hook it up to the computer
« Last Edit: April 20, 2009, 07:54:15 PM by menwhar12 »

Offline GhoSt

  • Creating Null
  • Around the block
  • *
  • Posts: 2552
  • Post quality +19/-0
  • Gender: Male
  • Null Pointer Exception
so how exactly do you change the program on the controller. what i mean is how do you hook it up to the computer

Read the whole thread please. You don't program the controller, you program a EXTERNAL pic microcontroller with a PIC PROGRAMER through a computer. Plus serveral other components probably need to be added to create the clock ect.

Don't mean to be harsh, it just annoys me when people don't read the hole thing.
|Variegation - GhoSt's Final Controller|

|Nothing is deterministic.|

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
yea they dnt want to explain it all over again..

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline EliteGamer83

  • Millennium Poster
  • *
  • Posts: 1233
  • Post quality +0/-0
  • Gender: Male
  • Trusted Seller! Slim Modder! Graphics Artist!
Yeah,

The PIC code that Blizz gave in his link would work but I talked to him and he said he just left out the PSP part of the code so.. we will need a programmer in here to finish the code.


Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
Not to be too pedantic, but it is AVR code!

As i understand it, his published code is to provide the building blocks for working with a ps2 controller in various projects, not as complete code for any given task.

Sigs by Alien_X
www.ax-elec.com

Offline EliteGamer83

  • Millennium Poster
  • *
  • Posts: 1233
  • Post quality +0/-0
  • Gender: Male
  • Trusted Seller! Slim Modder! Graphics Artist!
Well... I take it you know how to write code? not trying to imply that I want you to but I'm just curious are you going to finish it? if not I'm sure I can learn how to but just wondering if ya are.

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
just read up on it elite that what im trying to do

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline menwhar12

  • Fart Sniffer
  • *
  • Posts: 42
  • Post quality +0/-0
  • Gender: Male
  • psp phat- 5.00-6 m33
sry for the noobish question. i'm new to hearing about this microcontroler stuff. so just to clarifie the micro controller is the translator (the thing you plug the ps2 controller into) for the ps2 controller and psp. plz correct me if im wrong

Offline bustinthejustin

  • Registered BST
  • E = MC² Mad Scientist
  • *
  • Posts: 2326
  • Post quality +1/-0
  • Gender: Male
Well for this yeah, I think... It translates the signals from the PS2 controller to something the PSP can use, but I think it's more complicated than that.

Sig by Kenshinffx - Thanks!

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
for most ppl yea but from what alien said if you read up on it youll get the idea of it.

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline EliteGamer83

  • Millennium Poster
  • *
  • Posts: 1233
  • Post quality +0/-0
  • Gender: Male
  • Trusted Seller! Slim Modder! Graphics Artist!
Yea when you put it like that it doesn't sound hard but when you actually sit down and try to figure out what goes where it's actually pretty difficult.

Offline menwhar12

  • Fart Sniffer
  • *
  • Posts: 42
  • Post quality +0/-0
  • Gender: Male
  • psp phat- 5.00-6 m33
if i wanted to try and learn this were might i learn online and were might i get the program if there is one.

Offline Blazinkaos

  • Technology Revolution
  • Art & Theme Team
  • E = MC² Mad Scientist
  • *
  • Posts: 2259
  • Post quality +12/-0
  • Gender: Male
  • Time Passes Will You
    • ROOKIE BUILDERS DISCORD
well look into pic programming there is a link i posted in one of my posts below that is free and has a section taht explain some what but read what alien wrote what you should look into and reading those i believe well also tell what programs as well that will give an idea what to get.

*Thanks Modders/Friends:Ghost_Death, gr8npwrfl, Blizzrad, Kenshinffx.
*Thanks 802Chives for the Art position!

Offline Blizzrad

  • Chaos Lover
  • *
  • Posts: 267
  • Post quality +0/-0
Well for this yeah, I think... It translates the signals from the PS2 controller to something the PSP can use, but I think it's more complicated than that.

Apart from a brief routine to initialize the controller, this is pretty much all that is going on in the code. As programs go, this one is really simple, and doesn't even occupy 1/16 of the full program memory on the chip.

sry for the noobish question. i'm new to hearing about this microcontroler stuff. so just to clarifie the micro controller is the translator (the thing you plug the ps2 controller into) for the ps2 controller and psp. plz correct me if im wrong

A microcontroller is an integrated circuit that can store and execute code from it's own built in memory, it has all of the basic components of a computer built into a single tiny chip. Microcontrollers are used in everything from advanced robots to simple consumer products and toys, they are also quite cheap (around $4 for one with good features) and a lot of fun to play around with.

I think the best way to learn about this stuff is through doing it, so for anyone without much programming experience wanting to get started with microcontrollers, the Arduino platform is a good way to go. The Arduino is a very popular microcontroller development board based around AVR microcontrollers and a simplified software development environment. This slightly obnoxious video does a decent job of explaining the basics of how it works.

<http://www.youtube.com/watch?v=PeScmRwzQho> (copy/paste link without angle brackets)

Also, just to elaborate a bit more on what Alien pointed out above, PIC is only the name given to one particular family of microcontrollers made by Microchip, it is not a synonym for microcontroller. Using it this way is kind of like calling every brand of soda Coke, or every game console a Nintendo. There are many different manufacturers and families of microcontrollers, though PICs and AVRs are the most popular among hobbyists. AVRs are a family of microcontrollers made by Atmel. Code compiled for an AVR cannot be flashed to a PIC, and vice versa.
« Last Edit: April 28, 2009, 09:36:28 AM by Blizzrad »

Offline Alien_X

  • Club AM VIP
  • Millennium Poster
  • *
  • Posts: 1010
  • Post quality +3/-0
  • Gender: Male
As you pointed out, arduino is probably the best way to start with microcontrollers - and ladyada has published a very informative set of tutorials on the arduino.
However, if you really want to get into microcontrollers beyond the very basics you may find the arduino a bit too limiting - both in physical size and features, so programming with avr libc and an isp programmer, or a PIC with mpasm may be a better choice.
The arduino is essentially hiding both the underlying hardware, and software through its IDE and dev board - and since it is useing a bootloader to program itself this takes up both memory space and program execution upon power-up time.

If you want to learn about programming these microcontrollers, then you really have to familiarize yourself with google in order to learn about them online - we cannot answer every single question which you may have.

Sigs by Alien_X
www.ax-elec.com

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal