Using Serial Port

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Using Serial Port

Post by TokyoDriftPSP »

Hey,
I'm trying to connect a PS/2 mouse to the PSP - just for fun. What I did yet: connect the mouse to a ATmega8 microcontroller, writing the functions to send bytes to the mouse and get bytes from the mouse, implementing Serial Out to the app, connecting it via serial to my PC, writing an app on PC so I can controll my PC with the PS/2 mouse connected to the ATmega8, that is connected to the PC using a serial port. Okay, now I want to connect it to the PSP's serial port. I see two problems:
1. The PSP's serial port givs +2.5V, I need 5V, but I guess that can be solved using a power-boost thing (not sure what it's called in english). But what about the data? What voltage does it output when it's set on high? What voltage do i need to input? Is there anything like a MAX232 compatible to the PSPs serial port? Or does the MAX232 work?
2. The PSP outputs this only when a plug is inserted and a query is answered right. So what do I have to do what time?
thx =]
TD

EDIT:
Okay I found this stuff:
http://nil.rpc1.org/psp/remote.html
I guess that (http://nil.rpc1.org/psp/files/PSP%20Ser ... verter.pdf) would work for me. I just measured that my MAX232 outputs 9.60V, so I'd need to use a 7805 IC to get my 5V from it. That's no problem, will just make the circuit board bigger ;). But my question with the query from the PSP is still there. I'll have a look at the virtual remote app thing and hope it'll tell me.
TD

Oh, wait! If I'd use a MAX232 I'd need two! One that converts the 2.5V to serial level and one that converts the serial level to 5V. I'll need to try around if I can directly input the 2.5V into the controller, maybe it works just the same as the max232 detects the signal. Hm then i still need a step up converter to get my 5V for the controller and the mouse. Hmpf.
TD

Okay, the ATmega8 detects 2.5V signals as well. This would mean I don't need something like the MAX232 but a step up converter for the 5V used by the controller and the mouse.
TD

EDIT: there's still the problem with how to enable the power output.
TD

EDIT: I made a kernel prx with (almost) all the functions used in the SIO Sample and got it working. Well it starts at least. I forgot to input one function to the PRX, that'll be the next thing I'll do.
TD

EDIT: okay, the kernel PRX doesn't work. I made it just the same as the Open NAND Dumper 3.xx prx is made but the getChar thing only returns -2147483648, so the very lowest number a 32bit int can hold >.<
would be great if anyone of you would answer >.<
TD

EDIT: okay, i just tryed Jeans SIO Driver and it didn't work =|
i'm going to go crazy here...>.<
TD

YEAH I finally got the SIO thing working, Jean i luv u :D
but i have still the voltage problem^^
TD

Okay, when I init the SIO i can detect around 1.9V between DGND and VCC.
TD
Blizzrad
Posts: 4
Joined: Tue Apr 21, 2009 2:26 pm

Post by Blizzrad »

Wow, that's a lot of edits. Cool project, this is something I am interested in as well. I have also been playing around a little with using an AVR to communicate through the PSPs serial port, in my case using an ATmega168 to interface a Playstation2 controller.

Using PIkey with Jean's plugin, everything was able to be powered directly from the SIO port by also building a small circuit using a MAX756 step-Up DC-DC converter. This is the standard application circuit which is shown on page six of the datasheet. In my case the chip was set for 3.3v mode but it can also be set to output 5v.

As you stated, the 2.5v from the SIO port is enough to be recognized by the AVR, and a simple resistive divider can be used on the TX line from the AVR to the PSP to cut down the voltage to 2.5v. I don't have a slim so I'm not certain how well any of this would work from the lower voltage serial port, but I have also used the 756 to power low current circuits at 5v from a single 1.2v rechargeable AA battery (the datasheet lists 1.1v as the minimum start up voltage for the chip). Hopefully someone with more experience can give a more conclusive answer. I guess if all else fails, you could always use external batteries.

Are you going to be using the mouse as input for your own applications, or are you going to be doing some mapping to the standard controls? I would be very interested in seeing the code for this when you get it working (both for AVR and PSP).
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

Using PIkey with Jean's plugin, everything was able to be powered directly from the SIO port by also building a small circuit using a MAX756 step-Up DC-DC converter. This is the standard application circuit which is shown on page six of the datasheet. In my case the chip was set for 3.3v mode but it can also be set to output 5v.
hmm yeah that looks good, but the circiut looks a bit complicated to me, i need to read the whole datasheet again^^
As you stated, the 2.5v from the SIO port is enough to be recognized by the AVR, and a simple resistive divider can be used on the TX line from the AVR to the PSP to cut down the voltage to 2.5v. I don't have a slim so I'm not certain how well any of this would work from the lower voltage serial port, but I have also used the 756 to power low current circuits at 5v from a single 1.2v rechargeable AA battery (the datasheet lists 1.1v as the minimum start up voltage for the chip). Hopefully someone with more experience can give a more conclusive answer. I guess if all else fails, you could always use external batteries.
okay, the resitive divider is easy to use
well the problem doesn't seem to be the 756 (1.9V on the slim's SIO port should be enough) but the AVR
i doubt it will realize the 1.9V, so i need a level converter, don't I?
Are you going to be using the mouse as input for your own applications, or are you going to be doing some mapping to the standard controls? I would be very interested in seeing the code for this when you get it working (both for AVR and PSP).
well my aim is it to make a plugin to hook either the X /\ [] O buttons or the D-Pad or the A-Pad to use it with the mouse but i guess i'll first need to test it in my own app because i did never any hooks before

THANKS FOR THE ANSWER =]
I'll have a look at the datasheet again and look for some level converter

ahh, year i can post the code but I doubt it'll be working at all one time :D
well the AVR Part is already working but it's very bad assembler code, tell me if u want to see it and I'll post it, but I'm sure you can do the same code better^^
TD

EDIT: okay i messed around with my avr again and it does not detect 1.9V as high but as low =|, that means I need to use a level converter
TD

EDIT: okay, well, I could just use a transistor with base to the RX line (that what would go to the controller) and it may work, i'll try that
TD

EDIT: yeah sry i took the wrong resistor, the AVR reacts to 1.9V, the transistor thing's not working but it's not needed then^^
TD
Blizzrad
Posts: 4
Joined: Tue Apr 21, 2009 2:26 pm

Post by Blizzrad »

Good to see you got everything working, there is some info on simple level shifting techniques here, if it's still of any use to you.

I'm also looking to get the same thing working on the software end so that the Ps2 controller buttons can be ORed with the PSP controls. I have done a simple hardware test using the control mapping features of PIkey. It didn't really work well for this because it doesn't keep track of when buttons are released (they will repeat continuously if held down), but it was enough to test everything out. I have a video of it here. The other test app is just showing that all of the hardware communicates properly but doesn't do any actual control mapping.

I don't know what the forum rules about posting non-PSP source code are, perhaps it is better to just post links for the AVR stuff. I do all my AVR work in very bad C code, so your asm is still probably much better than anything I would come up with. This is the AVR code I wrote for reading data from a Ps2 controller (the PSP specific stuff is not in this version).

Thanks for all the updates on your progress, I for one am very interested in this project.
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

hmm I didn't use hardware SPI but made it completely on my own
there may be some debug stuff in it, delay stuff is locked to 1MHz and so on
well I just made it to test if it's working at all and it is
I need to do the stuff all again when I'm finished with the PSP stuff, but the AVR stuff is working so far pretty good and I don't see any reason to change it
http://paste.bradleygill.com/index.php?paste_id=8874
here's the code
TD

EDIT: hmm I'll need pretty many parts for the power boost thing
whatever, i guess i'll do that later when the rest works (I'm not willing to spend money if it doesn't work in the end)
I can plug in my 5V ac/dc converter so that will do the job for now
a huge prob is the serial connector, i bought one on eBay yesterday but it's from honkong and they say 7 to 21 days until it's here - they didn't even get the money yet =|
but on ebay it was 10€, in the stores it is 30€
so i guess i'll need to wait for the connector to arrive now, I don't need any parts apart from the power-stuff for now so I guess I'll just have to wait and maybe optimize the avr code and maybe test some other psp stuff (hooking and so on)
TD
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

Hmm I'm experiencing problems with Jeans SIO prx thing. I use the sioReadChar() function (not sioGetChar) and it works just perfect. But the ReadChar function freezes the PSP after 7300 to 7600 bytes
I tried the sioGetChar but this is not working at all, I just get -1 all the time
TD

Interesting: on 1.50 it works with the same code that freezes at 7300 to 7600 bytes on 3.xx / 4.xx / 5.xx
>.<
TD

here is how far I got and what i did: http://www.pspfreak.de/forum/news-ankue ... e-psp.html
whatever, the problem with the 7 to 8kb edge is still there
TD

okay i fixed the bugs. check the thread on pspfreak
TD

hmm how do I hook buttons in xmb? my patched function is called (peekBuffer) as soon as a button is pressed but it doesn't recognize my changes
TD

fuck there's a big problem...there is no voltage between pin 9 and 2...>.<
TD

there is voltage between pin 9 and 2...on 1.50
TD
Blizzrad
Posts: 4
Joined: Tue Apr 21, 2009 2:26 pm

Post by Blizzrad »

Excellent work, your project was posted on hackaday.com today too. I am very interested in seeing the source code for your plugin whenever you are ready to post it. The through hole version of the PS/2 connectors you are looking for can be ordered from here in single quantities. The PCB looks great too, a fine tip permanent marker (like a sharpie) can be useful for repairing the traces that didn't transfer well before etching.
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

thanks
well there are some strange things I need to have solved...
would be great if you'd help me

1. Strange SIO Behaviour
The SIO port is working perfectly as long as a USB (!) cable is connected to the PSP. As soon as I disconnect the USB cable I receive 0x00 all the time and if I send data via SIO i get 0xFF or 0xFE or things like that instead of nothing.

2. Strange XMB Hooking Behaviour
I hooked sceCtrlPeekBuffer and sceCtrlReadBuffer. In games this works perfectly. In XMB my function is called but the XMB doesn't notice any changes I do.

3. Strange Power Behaviour
Sometimes there's 1.9V between VCC and GND of the SIO port, sometimes there's not. I didn't realy find out on what it depends, I call the sceSysconCtrlHRPower(1); once when starting up SIO.

pls help me
thx
TD
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

TokyoDriftPSP wrote:1. Strange SIO Behaviour
The SIO port is working perfectly as long as a USB (!) cable is connected to the PSP. As soon as I disconnect the USB cable I receive 0x00 all the time and if I send data via SIO i get 0xFF or 0xFE or things like that instead of nothing.
Sounds like your ground connection from the PC serial port to the PSP serial port is bad, and it's getting grounded through the USB plug instead.
3. Strange Power Behaviour
Sometimes there's 1.9V between VCC and GND of the SIO port, sometimes there's not.
Could be the same thing.
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

I am so stupid
I put 1 wire of the psp sio to ground already but I guess it was the wrong one...put the other possible ground wire to gnd now and it works, both problems are solved
xmb hooking prob's still there
=]
TD
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

quite a while ago i found out how to hook xmb stuff
i can already tipe in things to the osk and so on
but i still have a problem
if i connect a LED to +vs and gnd of the serial port it works
if i check the voltage it says 1.9V
but as soon as i connect my max1674 the psp screen goes black and the power led of the psp turns off
the same happens when i connect +vs to gnd
well, the max1674 thing is working perfectly, if I connect a battery it outputs 5V but as soon as i connect the psp my psp turns off...>.<
pls help
TD
Blizzrad
Posts: 4
Joined: Tue Apr 21, 2009 2:26 pm

Post by Blizzrad »

I ran into this exact same problem, I guess the sudden current spike when the circuit is first attached might trigger some protection feature that shuts the PSP down in case of a short. Placing an N4001 diode in series between the V+ from the serial port and the input to my circuit solved this problem for me. If I recall correctly, I was able to draw around 40mA from the SIO port with no problems as long as the current didn't spike too abruptly. This was when using the MAX756 with a PSP1000.
TokyoDriftPSP
Posts: 17
Joined: Fri Feb 20, 2009 10:33 pm

Post by TokyoDriftPSP »

you are great man =]
just connected a diode and now it's working....let's see if it gives me enough power for the mouse and keyboard =]
TD

okay it's not enough =|
TD
Post Reply