Wireless Joypad to Serial Board

MurrayJ

Senior Member
Just wondering if I can get some help with this board I just received, it is a wireless ps2/ps3 controller serial receiver board. I thought it would be a simple as a serin command and then debug (in a loop) to work out what button spits out what value, but instead it just stops at the serin command and doesn't receive anything. A lack of any sort of pdf or txt file to show what is what doesn't help. This is the board in question:

www.icstation.com/wireless-joypad-serial-port-pinboard-adapter-board-p-11477.html

The controller seems to be connected correctly, there is a led that blinks when the controller is not connected, then is steady on when connected.

Any sort of advise you can give would be great.

Murray
 

hippy

Technical Support
Staff member
You use a scope, logic analyser, perhaps a LED+R or a PICAXE program, to determine if there is any data put on the serial receive line.

First step would be to determine which of TXD and RXD is data in to the board and which is data out.

Unless you can find a datasheet or example of use it could either just work or be very difficult to use.
 

MurrayJ

Senior Member
Thanks Hippy, as I Dont have a scope (or know how to use one) I will just have to try something else for my project.
 

inglewoodpete

Senior Member
Thanks Hippy, as I Dont have a scope (or know how to use one) I will just have to try something else for my project.
Not many people have a scope, especially ones who are playing with playstation gear!

One step at a time. How about the other options, like an LED with series resistor (Eg between 330ohms and 1kohm)? That's what I would start with. At least that will tell you if there is serial data chattering out of the device. Then you could use your PICAXE to read the length of the first data pulse (PulsIn command), which may help you determine the data speed (baud rate).
 

MurrayJ

Senior Member
Tried the LED with resistor. The LED is lit all the time it has power, no blinks, or I suppose the pulses are so rapid it looks like its not blinking.
 

hippy

Technical Support
Staff member
If the LED is on most of the time, that would suggest it requires a Txxxx baud rate.

Try connecting the LED+R between V+ and the serial data. That may show any data better; it is easier to see a LED flashing briefly on rather than briefly off.
 

MurrayJ

Senior Member
Tried what you suggested Hippy, and the LED is now blinking rapidly, and when I press buttons on the controller the flashing changes slightly, so getting a little closer. Tried another simple serin command, this time with a timeout and was able to get it to vary when buttons were pressed.
 

hippy

Technical Support
Staff member
Might be worth trying with an X2 using background receive, or building a simple logic gate / transistor inverter and feeding it to a PC's RS323 port or an AXE027 and using a Terminal program to see what it is sending.
 

MurrayJ

Senior Member
Thanks Hippy, but that is probably beyond my skill level. I have emailed ICStation to see if they have a document for the board or any other info. I will see if they get back to me.
 

AllyCat

Senior Member
Hi,

Tried another simple serin command, this time with a timeout and was able to get it to vary when buttons were pressed.
The link from #1 says the data is "idle high" (TTL) at 9600 baud (we can assume it's not 115 kbaud as you probably wouldn't see anything at all), so you will need to run the PICaxe at an elevated clock frequency (at least SETFREQ m16 and T9600_16). Even so, you may have problems creating a sufficiently "fast" program, if it's transmitting multiple ASCII characters (strings).

I don't think you've said which PICaxe you're using but HSERIN may make reception/decoding easier (or at least possible). HSERIN is normally available only on one pin, is it available on the PICaxe you're using?

Cheers, Alan.
 

MurrayJ

Senior Member
Sorry, I meant to include my setup in my first post, but somehow I forgot. I am using a Picaxe 28X2 on an AXE401 board with a Sensor shield to make connecting to it easier.
 

AllyCat

Senior Member
Hi,

So HSERIN should be on pin c.7 (or Leg 18); can you feed the serial data in on that pin (sorry I don't know about the sensor shield) ?

You can still start with SERIN commands, but if they don't work (properly), then we can help you progress through HSERSETUP / HSERIN and maybe background receive, if they prove necessary.

Cheers, Alan.
 

hippy

Technical Support
Staff member
Google (https://translate.google.com) does a good job of translating Chinese to English. You might have to copy and paste a paragraph at a time but one can pull out what looks to be relevant sections and start with those.

For example, on page 6; "Switch board baud rate setting: The default baud rate of this adapter board is 115200. If the user wants to replace the baud rate, first disconnect the power supply, and then shorten the AT pin of the adapter board, and then power on, this time has switched to 9600, Data bit 8, stop bit 1, parity bit 0, flow bit 0. Disconnect the solder joint and return to 115200".

It's not going to be perfect, "shorten" likely means "short", and that would make sense given there are two "AT" pads to be shorted.

It shouldn't take too long to work through the entire datasheet. Save the translated text as a file, then you can create and publish an English language version which will save everyone else from having to do the same.
 

MurrayJ

Senior Member
Got it to partially work, the buttons do at least. I solder bridged the AT pins and tried this -

main:
serin S.0, T9600_8, B1
Debug
goto main

The serin program outputs the letters corresponding with the button presses in the pdf, although I still cant quite get the thumbsticks to output anything yet. The google translation that I got was very confusing as to what I should do.
 

MurrayJ

Senior Member
The thumbsticks have a button built in when you press them down and it changes the serin data. Normally serin waits for a button before outputting, but when the thumbstick button is pressed it outputs continuously, obviously to get a reading for the stick, but the reading does not correspond to the stick, should be 0 - 180 but with horizontal and vertical that is 2 values.

This is the relevant area below.

Use description:
The following picture for the wireless handle button press the corresponding serial port to send the byte.
The left side of the four directions as long as the button to send data, the other button when pressed to send the characters once, after the release of the hand, after a press, once again, the rocker down can also be used as a switch Press once to send the character once.

Press the button on the picture to send the corresponding characters, rocker data to see the following picture.
We are marked by the color lines, red vertical bar on behalf of the left and right joystick up and down, pink bar on behalf of the left side of the rocker, purple on behalf of the right side of the rocker up and down, green on behalf of the right side of the joystick. When you press the left joystick down, the left joystick is activated and the data is sent, and the data is stopped by pressing once.

(0-180), 0 is the bottom, 180 is the top, (for example: W180) and then send the value of the left and right of the P joystick (0-180), then send the upper and lower values ??of the current joystick ), 0 is the left, 180 is the right (for example: P180) P data will be sent to wrap. When you press the right joystick down, start the right joystick and send the data, press once to stop sending data, (0-180), 0 is the lowest, 180 is the top, (for example: Q180) and then send the S rocker left and right values ??(0-180), 0 is the value of the current joystick Left, 180 is the right (for example: S180) S data will be sent to wrap.
 

hippy

Technical Support
Staff member
The thumbsticks have a button built in when you press them down and it changes the serin data. Normally serin waits for a button before outputting, but when the thumbstick button is pressed it outputs continuously, obviously to get a reading for the stick, but the reading does not correspond to the stick, should be 0 - 180 but with horizontal and vertical that is 2 values.
If it is sending something rather than not sending anything, it is probably that the SERIN:DEBUG is causing data to be missed, is busy in DEBUG and missing the rest of the data sent.

I would try this ...

Code:
main:
  serin S.0, T9600_8,[b] ("P"),[/b] B1
  Debug
  goto main
Then activate the joysticks and see if you can get one of them to show up some data. And then maybe change to 'serin S.0, T9600_8, ("P"), #B1' to see if that does better.
 

MurrayJ

Senior Member
The program doesn't seem to help, although I appreciate all the help you have given me to get this far. I think I have worked out what it is trying to send, although you are right, debug is causing some data to be missed.

This is I think what should happen -

The left thumbstick, vertical position is represented by the letter W and horizontal is P, so the proper serial stream would look like - W, 80, P, 50, W, 80, P, 50 and then when you move the stick the numbers will change although it is throwing out some unusual readings. The right stick is the same except the letters are Q and S.
 

hippy

Technical Support
Staff member
This is where inverting the serial data and reading it on a PC terminal really helps because it allows exactly whatever is being sent to be seen and then the PICAXE command to read it can be crafted to suit.

That said, 'serin S.0, T9600_8, ("P"), #B1' should read a 'W, 80, P, 50, W, 80' sequence, extract the 50 into 'b1'.

It could be the data is sent too quickly for the PICAXE to keep up with. If that's the case then running with a higher SETFREQ and adjusting the T9600_X baud rate might help.

Alternatively reading it with background serial receive or a HSERIN with a qualifier may be needed.

I would personally drop DEBUG and use SERTXD ...

Code:
Do
  serin S.0, T9600_8, ("P"), #B1
  sertxd( #B1, CR, LF )
Loop
 

AllyCat

Senior Member
Hi MurrayJ,

It looks as if the joystick might send strings of characters such as "S 1 8 0", so your program is way too slow.

First replace the DEBUG with a SERTXD(#B1," "). Then increase the clock to perhaps SETFREQ m32 , use SERIN S.0, T9600_32,B1 and set the #TERMINAL to 38400 (?) baud .

That still might not be fast enough, in which case you might use @BPTRINC (instead of B1) in a tight loop to receive the data, with a SERIN timeout to jump to display the received data. Or of course, use HSERIN and/or background receive with an X2.

Cheers, Alan.
 

MurrayJ

Senior Member
Really don't know what I am doing Alan and so don't know how to interpret what is being sent. It is transmitting 227 152 repeating if I dont move the stick and the button presses which should output a letter (or decimal equivalent) now output 254 no matter what button I am pressing. More confused than ever.
 

AllyCat

Senior Member
Hi,

What you are trying to do is not easy, particularly if you don't have much, or any, test equipment. An oscilloscope would be "nice" but do you even have a multimeter? To make progress you will need to work slowly and methodically from first principles, or will just get yourself (and us) more confused.

First, I would attach (the cathode of) a LED to your serial input, with its anode via a resistor of around 1 kohm to the supply rail. As the input is "idle high", the LED should flash (maybe only quite dimly) each time the joypad transmits any data. That should give (us) some idea how much and how quickly it's transmitting data.

Next, you must get it running at 9600 baud (not 115k). From hippy's post on the previous page it seems that two "AT" pads need to be linked, but I'm not clear if that is permanently or just when power is (first) applied.

Then, DON'T use the DEBUG facility, but put a SERTXD command in your program loop. That should display characters or a number on the "Terminal" screen, hopefully at much the same time as the LED flashes. Ask us if you need help with the SERTXD command or getting the Terminal Emulator to work.

That's enough for now. If you can get "repeatable" and "expected" results on the terminal screen, then we can look at increasing the clock speed and/or receiving multiple characters, which are (probably) being transmitted very close together.

Cheers, Alan.
 

MurrayJ

Senior Member
Thanks for all your help Alan and Hippy. I think I have taken this as far as I am able to and will have to use some other control method for my project.

I have sent for a Bluetooth board (HC-06) and have started with App Inventor. I have a simple LED on/off starter program for both the Picaxe and App Inventor written and hopefully will go more smoothly. Actually the Picaxe/Bluetooth/App Inventor/Android Phone would seem to be even better for what I want than the Joypad Controller since I can have virtually unlimited controls. I just wish I had seen and new about it earlier and I wouldn't have had to bother you so much, although I enjoyed every minute of trying to figure it out.
 
Top