db9_gpio_rpi genesis 6 button, ghost presses, random buttons triggering
-
Pi Model or other hardware: 4b 2gb
Power Supply used: Meanwell 5A 5v power
RetroPie Version Used : 4.7.1
Built From: (Pre made SD Image on RetroPie website, https://github.com/RetroPie/RetroPie-Setup/releases/download/4.7.1/retropie-buster-4.7.1-rpi4_400.img.gz
USB Devices connected: keyboard
Controller used: Genesis 6 button db9 clone
Guide used: https://magpi.raspberrypi.com/articles/use-a-retro-db9-joystick-with-raspberry-pi-400 , also db9 documentation. Vcc is wired 3.3V not 5V.
How to replicate the problem: Let the system sit in the emulation station menus and it will (apparently randomly) do something weird. I can't isolate what the gamepad is signaling. It quickly moves a number of positions in the menu. If it happens while scrolling/moving around the menu it tends to put stuff on the Favorites lists. I did try both with the pins set to pullup and also with not following that part of the guide. Btw, you can't set the Select pin to pullup like the guide tells you, or the 6button controller won't work properly. I have left it sitting on the joystick test screen and not seen it jump, but if in emulation station it happens rather often. It also happens during gameplay. It is a very cheap knock off controller, I forget if I have a second one around. I was going to check and swap to it if so. I am using the first "port", I also thought of switching to the second port to see if it behaves differently. It does list that TTL based controllers may not work on 3.3v in thedb9 documentation, but the Genesis controllers have been referenced as CMOS based. Again knock off cheap things so maybe it is the controller?Has anyone seen that, or have any suggestions on what to look into?
-
@markeno
If you can't isolate which one is doing the ghost presses, just plug them in one by one to see which one makes it move. -
@luddo183 , I have tried the second controller. It is the same.
With further testing the issue is with the upper 3 buttons certainly the X and Y buttons. Which are mapped to "Favorite" and "Random". Considering that possibly Z although I don't know what that button does in the Retropie Menus. I am wondering if it is because they are being run at 3.3V. The buttons don't wire to the gpio, not for these controllers, the signals are getting crossed as it is normally correct as they are directional moves, but with the x y and z they are wired to the same outputs as the directional controls. It is something off in the timing.
I'll have to look into trying a level shifter and using 5V power to them when I get a chance.
-
From the distance, some possible causes:
- Noisy (in sense of electromagnetic fields) environment which introduces the ghost presses
- And/or: long cables from Controller up to GPIO Connector
Flaw by design: The pullup resistors are not very strong in a RPI. Maybe the controller itself also introduce the issue (can not tell from the distance).
The workarounds would be (in a nutshell) shield the wires, shorten the cables, supply external pullups and small capacitors closely to the GPIO ports and maybe lend a different brand of genesis controller to verify if your controllers are the cause.
But I won't go down that path, except for checking with a different controller brand because it is a PITA to implement and questionable if it really helps in your setup.
Instead: Maybe you can use a MCP23017:
- maps controller input to i2c [1]
- one for each controlller/player
- RPI can address upto 8 MCP / Players
- needs the mk_arcade_joystick_rpi kernel driver [2]
- you can find MCP PCB breakout boards online
- less tinkering than the next suggestion
or the open hardware RetroAdapter [3]:
- maps controller input to USB
- up to two players per RetroAdapter
- no kernel driver needed
- needs more tinkering than the MCP approach
HTH
PS: Button Z is neither mapped in Emulationstation nor in the runcommand menus (the ones pop up when you launch a game in default configuration or RetroPie).
[1] https://www.microchip.com/en-us/product/MCP23017
[2] https://retropie.org.uk/forum/post/263208
[3] kits discontinued but schematic and firmware can be found here (bottom of page) https://web.archive.org/web/20160310115415/http://denki.world3.net/retro_v2.html -
@lolonois , I have tried two cheapo knock off Genesis 6 button +1 controllers (missing the Mode button), and the Retrobit branded Sega licensed Genesis 6 button +2 controller. If anything the licensed contoller may be worse. With the licensed controller connected it can occasionally trigger even when not touching the controller at all. With the driver loaded and the controller disconnected it never happens, I figure that wouldn't completely rule out the unshielded wiring though.
Unless I am mistaken, it looks like the mk_arcade_joystick_rpi driver that uses a MCP23017 appears to be direct wired controls. It doesn't seem that it supports the Genesis 6 Button type controllers. Maybe I am missing something in the somewhat minimal documentation.
The RetroAdapter project looks like a potential option, short of it is quite a bit of work, and I haven't used they type of atmega, nor do I have one around.
I would look into shielding the wiring, and or doing the level shifter to get the controller running at 5V probably first as I have what I need on hand for trying either of those. That is short of documenation how the level shifter should be wired up. Again not exactly complete documenation, or I am bad at finding it.
-
@markeno bite me. I completly missed the fact that it is a 6 btn controller and the controller runs a "mini-protocol" to get all buttons mapped to the available pins. Sorry for hinting you in a false direction.
For the 6 button case my remediations would be to try some level shifters first.
If you can find some breakout-board of BSS138 for example they should do the trick. Depending how the breakout-board is manufactured you may /may not need some 10k pull ups.
Wiring is sketched here [1], although it is not for your setup, but you most likely will get the point.
The mini-protocol is documented in [2] -you may already know this- and the respective driver reflects the logic [3]. Make sure when loading the module to specify the controller type (
/etc/modprobe.d/db9_gpio_rpi.conf
to containmap=<controller-type>,...
). I assume it must be type 5 or 6, when looking at the source [4] and/or RetroPie docs [5].[1] https://mygeekyhobby.com/2018/08/12/pi1541-in-30min-with-almost-no-soldering/
[2] https://github.com/jonthysell/SegaController/wiki/How-To-Read-Sega-Controllers
[3] https://github.com/marqs85/db9_gpio_rpi/blob/a3c16921a812ec2cf24a043a184cf445813bac08/db9_gpio_rpi-1.2/db9_gpio_rpi.c#L544-L580
[4] https://github.com/marqs85/db9_gpio_rpi/blob/a3c16921a812ec2cf24a043a184cf445813bac08/db9_gpio_rpi-1.2/db9_gpio_rpi.c#L134
[5] https://retropie.org.uk/docs/GPIO-Modules/#db9_gpio_rpi -
@lolonois Thanks, it is not a problem. I will setup a level shifter and see what I get. I have the type for pi1541s. I had also ordered a couple 74LVC245s listed in the db9_gpio_rpi documenation to try when I purchased the Licensed Genesis controller incase that didn't fix it.
-
After trying different types of level shifters I found no fix for the random mistakes for the button presses. The issue looks to me the select lines are misinterpreted. It is a mistake in the input, not a random false press.
The presses not showing mistaken in jstest. There are references where gamecon_gpio_rpi lists that there are issues with Gamecube and N64 controllers due to variations in timing due to cpu frequency changes or such. I get these "incorrect" presses when in scrolling through to select games, I get them usually just a couple seconds into a game launching. They may be slightly different between controllers.
At this point, without any input on something else to look into I am unfortunately giving up on using db9_gpio_rpi for the Genesis type controllers. I would love to be able to use it, it is a very nice feature to have and my setup was design specifically to include two db9 ports.
I am going to try to see if mode 3 "Multisystem 3-button joystick" mode will work reliably. It will give me some use of the db9 ports. I do have a Multisystem 2-button joystick, but it is not registering the second button press, I makes me wonder if the logic is backward from the C64GS 2 button? That will be my next thing to look into.
For the Genesis 6 button controller I guess I will use a
DaemonBite-Retro-Controllers-USB adapter. I wanted an integrated solution though.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.