SukkoPera / PsxNewLib

Playstation controller interface library for Arduino
GNU General Public License v3.0
133 stars 29 forks source link

Wireless Controller keeps disconneting #17

Closed LAKY911 closed 2 years ago

LAKY911 commented 2 years ago

Hi, thank you for this library. I am using it for a car controller in my bachelor thesis. I have used Dualshock 2 wired controller but I would like to switch to wireless controller. I have bought a chinese clone from Aliexpress but sadly I can't get it working neither via bitbang nor HW SPI. Bitbang doesn't work at all. HW SPI works, but the controller keeps disconnecting every 3-5 seconds. Do you please have any clue what might be wrong?

Thank you very much Best Regards

LAKY911 commented 2 years ago

Maybe to add - the controller disconnets for 1 second and then connects again for the 3-5 seconds. During this connected time it works flawlessly. And it is being recognised as Dual Shock.

SukkoPera commented 2 years ago

First of all make sure that the wiring is solid. Then please try some of the suggestions from this post and thread.

LAKY911 commented 2 years ago

Hi, thank you for your help. I can confirm that the wiring is solid and correct. Although my controller works good with the Psx library as in the post you mentioned, I wasn't able to get it working via editing the parameters as you described.

So it still remains the same: HW SPI disconnects every 3-5 seconds, recognised as dualshock. Bitbang nothing, the controller isn't recognised at all. I noticed one thing, on the receiver there are two LEDs, one is PWR LED, this one is simply on. And a second one is RX, this one usually blinks 1 second on, 1 second off - when disconnected from the controller, turned on when connected. But when I upload the bitbang sketch, it somehow blinks completely randomly.

I will try adding the external pullups 1k Ohm resistors on the CMD and DATA lines as you suggested and will let you know.

Thanks for your help.

SukkoPera commented 2 years ago

Are you using 1k pull-ups?

LAKY911 commented 2 years ago

Hi! Yes, I am using 1k pull up resistors on the DATA and ATT line. Is that correct? I just tried the bitbang example with DUMP_COMMS. You can see that the controller (probably) gets detected, but cannot enter config mode.

--> FF FF FF 
<-- 01 42 00 
--> FF 03 5A 
<-- 5A 5A 5A 5A 5A 5A 
--> FF FF FF FF FF FF 
Controller found!
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF 83 B4 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
<-- 01 43 00 
--> FF FF FF 
Cannot enter config mode
<-- 01 42 00 
--> FF FF FF 
Controller lost :(
<-- 01 42 00 
--> FF FF FF 

And HW SPI example code gives this:

--> FF 41 5A 
<-- 5A 5A 
--> FF FF 
Controller found!
<-- 01 43 00 
--> FF 41 5A 
<-- 01 
--> FF 
<-- 5A 
--> FF 
<-- 01 43 00 
--> FF F3 5A 
<-- 01 
--> 00 
<-- 5A 5A 5A 5A 5A 
--> 00 00 00 00 00 
<-- 01 45 00 
--> FF F3 5A 
<-- 5A 5A 5A 5A 5A 5A 
--> 03 02 00 02 01 00 
Controller Type is: Dual Shock
<-- 01 44 00 
--> FF F3 5A 
<-- 01 00 
--> 00 00 
<-- 5A 5A 5A 5A 
--> 00 00 00 00 
<-- 01 44 00 
--> FF F3 5A 
<-- 01 00 
--> 00 00 
<-- 5A 5A 5A 5A 
--> 00 00 00 00 
<-- 01 44 00 
--> FF F3 5A 
<-- 01 00 
--> 00 00 
<-- 5A 5A 5A 5A 
--> 00 00 00 00 
<-- 01 4F 00 
--> FF F3 5A 
<-- FF FF 03 00 00 00 
--> 00 00 00 00 00 5A 
<-- 01 4F 00 
--> FF F3 5A 
<-- FF FF 03 00 00 00 
--> 00 00 00 00 FF FF 
<-- 01 4F 00 
--> FF F3 5A 
<-- FF FF 03 00 00 00 
--> 00 00 00 00 00 5A 
<-- 01 43 00 
--> FF F3 5A 
<-- 00 
--> 00 
<-- 5A 5A 5A 5A 5A 
--> 00 00 00 00 00 
<-- 01 43 00 
--> FF 79 5A 
<-- 00 
--> FF 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
Left analog: x = 128, y = 128
Right analog: x = 128, y = 128
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 FF FF FF FF FF FF FF FF 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 FF FF FF FF FF FF FF FF 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 
<-- 01 42 00 
--> FF 79 5A 
<-- 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 
--> FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Left analog: x = 255, y = 255
Right analog: x = 255, y = 255
<-- 01 42 00 
--> FF FF FF 
Controller lost :(
<-- 01 42 00 
--> FF FF FF 
<-- 01 42 00 
--> FF FF FF 
<-- 01 42 00 
--> FF FF FF 
<-- 01 42 00

Again, thank you for your help!

SukkoPera commented 2 years ago

I don't think the pull-up on ATT is necessary, but it won't hurt anyway. I'd also add one on CMD. In any case, this also all depends on how you did the 5V <-> 3.3V level-shifting.

LAKY911 commented 2 years ago

Hi, thanks for your help. Seems like the problem was low voltage. In the manual I got was recommended voltage 3.3V which was not working. I have changed the voltage to 5V now and everything works fine. It looks like I have a new desing of the receiver so maybe they changed the circuit desing to 5V now? I don't know. Anyway, thank you so much for this library. Best wishes, L

SukkoPera commented 2 years ago

That doesn't make much sense, actually. Controllers were designed to work at 3.6V and 3.3V is usually fine. I don't recommend powering them at 5V, despite what maaaaaany crappy tutorials out there say.