Converting Analog Joystick to Digital Joystick Signals

The following picture shows how a good analog-joystick-to-digital-joystick conversion should be done, with a circular deadzone in the center, and eight symmetric angular zones for the eight possible directions:

1 

Sadly, most software uses a far inferior solution, where each axis is checked separately and compared to the deadzone by itself. This results in the following, terrible, result:

2

If the deadzone, which is now square, is small, as in the picture above, then the diagonal zones are much too big. The user will constantly hit the diagonals by accident.

In contrast, if the deadzone is large, then the diagonal zones become way too small. The user will have a hard time hitting the diagonals at all:

3

Using the angular zones from the first picture avoids all these problems. It also leads to slightly more complicated code. Both axes have to be analyzed together to find the result. Here is some example code snippet:

(...)
float slope = 0.414214f; // tangent of 22.5 degrees
// circular deadzone check
if (joyX * joyX + joyY * joyY >= deadZoneSquared) {
   if (joyX > 0 && joyY > 0) {
      // upper right quadrant
      if (joyY > slope * joyX)
         up = true;
      if (joyX > slope * joyY)
         right = true;
   } else if (...) // code for other three quadrants
(...)

Here, joyX and joyY are the analog readouts as floats, deadZoneSquared holds the squared value of the radius of the circular deadZone in the center, and up, down, left, and right are booleans that are set to true to indicate the resulting digital directions.

XPadder for PC does this correctly. Joy2key does not.

Personally, I prefer to use the DPAD for digital controls anyways. But many people like to use the analog stick. If the conversion is not done correctly, the experience can be quite frustrating for them.

Finally, to perform a truly analog control readout such as for a flight simulator, there are also many pitfalls. Basically, to do it right one has to use a radial, scaled deadzone, as detailed in the following great article from third-helix:

http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html

Until next time,
rsn8887

Advertisements

Pelican Real Arcade Universal Stick – spinner mod

Recently, I went back into the guts of my Pelican Real Arcade Universal controller (previously modded with IL and HAPP arcade parts). I added a TurboTwist 2 Spinner controller for use with games such as Arkanoid or Tempest. Here is a picture of the finished mod. The new spinner can be seen to the left of the two white buttons towards the rear of the case:

SpinnerFoto-medium

I played a few hours of Arkanoid 1 and 2 with it on the Xbox using CoinOPS. It was really fun, but quite hard to play because I am so used to playing these games with a mouse.

The mod was very easy. I had an unused button in the case anyways. I just took it out and put in the spinner instead. The spinner functions as a usb mouse (only the horizontal axis is actuated of course). I guided a usb extension cord out of the back of the controller case together with the original Playstation 1 controller cable from my previous mod. In order to hook it up to the Xbox, I used a USB-to-Xbox adapter cable.

The analog sensitivity in MAME has to be adjusted on a per game basis, and depends on the counts per revolution of the original game, as well as the counts per revolution ratio of your spinner controller. The TurboTwist 2 has 1200 counts per turn – enough resolution to simulate any spinner-based arcade game. A list of counts per revolution values for some arcade games can be found here. For example, Arkanoid 2 has 972 counts per revolution. So the analog sensitivity in MAME should be set to 972/1200=81%. I am assuming any kind of mouse acceleration is turned off.

Until next time,
rsn8887

Pelican Real Arcade Universal Stick – IL Parts Mod

A few years ago, I finished my first arcade controller mod, replacing the knockoff stick and buttons in a Pelican Real Arcade Universal Stick with arcade-authentic parts from HAPP and IL. The Pelican has a nice large and sturdy case made from thick particle board. Here are pictures of my modded controller. Note the additional DB9 connector for the connection of an old Amiga/Atari style joystick:

4 PelicanHapp_Front

3 PelicanHapp_Bottom_Detail

2 PelicanHapp_Bottom

1 PelicanHapp_Top

I replaced all the Buttons with concave buttons from HAPP, and the stick with an IL eurostick.

The pictures show my initial mod where I used a HAPP stick. I later went back and replaced that with an IL stick. The IL sticks are used in European arcades and are of much better quality than the current generation of similar looking HAPP sticks. HAPP used to simply re-brand the high-quality IL sticks from Europe. But, a few years ago, HAPP apparently decided to  manufacture their own sticks in China instead. These Chinese-made HAPP sticks feel wobbly and imprecise when playing games. The good IL sticks can be distinguished from the new HAPP knockoffs by looking at the square actuator at the bottom of the joystick shaft. For sticks from IL the actuator is white, while the knockoff HAPP sticks have a black actuator.

I used the concave style buttons because I remember those from the arcades when I was young. Most professional gamers seem to prefer the convex shape, since it allows your fingers to move more quickly between buttons.

In addition to replacing the stick and buttons, I also replaced the Pelican PCB with the PCB from a Playstation 1 controller (non-dualshock).

Finally, I added a 9-pin male serial port for connection of an Amiga or Atari style joystick for emulation purposes.

I had to solder a few wires: 10 Buttons, ground on every microswitch, and then the four joystick directions. I realize now that I should have just bought Quickconnect crimp connectors for all the wires. That would have made it much easier than soldering directly to all the microswitches. 

When soldering the wires to the test points on the Playstation 1 controller, two of the testpoints completely detached. I think this was due to the heavy wires I used. The wires pulled on the testpoints with quite a bit of force. I managed to scrape the resin off some of the copper traces on the PCB and solder the detached wires to those. This turned out to be quite unstable, too, and the traces looked like they might lift off the PCB far too easily. So I decided to secure all the solder joints and attached wire segments to the PCB with blobs of 5 min. epoxy. Now it is all rock solid, nothing moves anymore and the wires are kept from pulling directly on the solder joints. I can only recommend epoxy to secure such fragile spots. The electrical contacts have to be good to begin with though. Once the epoxy is on there, it becomes really hard to go back and change anything.

On the Playstation controller PCB, I then de-soldered the white 7-pin molex style connector that joins the controller cable to the PCB. I did this hoping that I would be able to fit the cable with the white connector through the hole in the back panel of the Pelican case. It didn’t quite fit. So I detached the white connector from the cable, guided it through the hole, and then soldered the 7 tiny wires directly onto the Playstation controller PCB. That was quite wobbly and fragile (while soldering, two of the wires ripped off immediately). In the end, I finally got the seven solder joints to be somewhat stable without one of them ripping off. I then encased the joints and wire segments in epoxy to secure them.

Now everything was very nice: the Playstation controller cable fit into the strain relief of the Pelican, the Playstation controller PCB could be fastened to the Pelican case in the same place where the original PCB used to be. By the way, the original PCB was not very good. For example, it was not even recognized as a Playstation controller by the Total Control 2 Plus PS1-to-Dreamcast adapters.

The IL stick and buttons fit into the existing holes in the case. The screw holes to hold the joystick in place also fit the new stick. Maybe the Pelican was originally designed to house HAPP/IL parts, and then, at some later point, it was decided to put in knockoff parts instead to save some money?

Other notes:

– Since I didn’t have the crimp style Quickconnects, I directly soldered to the microswitches. Next time, I will use the correct 0.187″ Quickconnects. That way, it will be much easier to replace a broken microswitch in the future.

– The wiring in the box is quite cluttered. I secured it all with zip ties, so it shouldn’t be a problem in daily use, but it still looks messy.

– I used 22 American Wire Gauge wiring. The original wires in the Pelican controller were much smaller. I realized that soldering a thin wire is much easier than a thick wire. Next time, I will probably use thinner wiring. On the other hand, with this thick wire,  the chances of breaking a wire when servicing the controller are much slimmer. And I anticipate some of these microswitches to eventually go bad.

– I daisy-chained all grounding wires. In the original Pelican design, each switch had its own dedicated ground wire, e.g. grounding was done in a star pattern. The star pattern is the correct way to ground things in general. However, with such a simple application as this joystick, we do not very about Voltages at the microvolt level and ground loops should not be an issue here.

Until next time,
rsn8887

Mayflash Arcade Stick – Sanwa Mod

Some time ago, I modded my Mayflash arcade stick with authentic Sanwa parts that are used in the arcades, as well as a PCB taken from an old Playstation 1 (non-dualshock) controller. The Mayflash has a slightly small but otherwise quite sturdy plastic case.

Here are the pictures of my modded stick:

MayflashSanwa_Top

MayflashSanwa_Bottom

As parts, I again used all Sanwa components:

JLF-TP-8YT-SK Stick
LB-35 balltop in black,
GTY octagonal restrictor plate,
and OBSF-30 buttons in many different colors.

At first, I tried to use a green balltop, but that looked horrible. I think the black balltop looks much nicer on this case.

The Mayflash controller must be the cheapest arcade stick money can buy. I paid $25 for a brand new one! The case is the only good thing about this stick though. The PCB, the stick, and the buttons are of pretty bad quality and feel wobbly. It is worth buying just for the case, though.

Although the PCB works with PC/PS2 and PS3, it is no good in everyday use. Contrary to other arcade sticks, the directions are mapped onto the left analog stick with 100% actuation and not to the digital gamepad directions. This mapping makes the stick out-of-the-box useless for example for Soul Calibur and Tekken. In those games, you will run constantly, dashing with double-tap doesn’t work either, and there are probably a myriad of other complications.

In addition, the PCB does not utilize a common ground for joystick directions. This is extremely annoying. At first, I tried to make use of this PCB. I had to make my Sanwa stick compatible by cutting its common ground connections and directly solder onto its microswitches. In the end, this was unneccessary, since I decided to replace the PCB with one from a Playstation 1 controller, which uses common ground. I kept the Mayflash PCB in the case, but only use it  because it provides me easy access to the contacts of the start and select buttons (see picture).

The buttons in the Mayflash controller are cheap parts that press directly onto charcoal contacts on a large secondary PCB. That is quite bad, because everytime you hit the button, you are pressing directly on a PCB, just like in a gigantic directional pad. Who thought of this? *shiver*

I drilled four holes into the top wall of the case, and attached the new Sanwa joystick via its large metal mounting plate to those holes with four screws and nuts. Before doing that, I used a dremel tool on the inside of the case to file away any plastic pieces that happened to be in the way of the Sanwa stick. There are quite a few plastic extrusions and mounting pieces on the inside of the case that are in the way. But they can be filed off very easily.

Luckily, the hole for the stick in the Mayflash case is big enough for the Sanwa stick with its black joystick cover. The stick does not touch the hole, even when actuating diagonals.

The holes for the buttons also required quite a bit of dremel work. The diameter of the holes is just 1.5 mm too small to allow for the Sanwa buttons. Luckily, the plastic can easily be filed away with the dremel to enlargen the button holes to the correct diameter. From my own experience, it doesn’t seem to matter whether the holes are not perfectly circular, as long as they are not too small. If the holes are too small, they will squeeze the buttons too much, making them feel stiff. This is easily noticed when pressing the buttons.

I mounted the Playstation 1 controller PCB  on one of the remaining tapped holes inside the case using one small screw and a cable tie.

I am pretty happy with the result. This was the cheapest arcade stick I have modded so far.

Until next time,
rsn8887

Hori Tekken Tenth Anniversary Stick – Sanwa Mod

A while ago, I modded my Tekken Tenth Anniversary stick with Sanwa parts. The original stick contains knockoff parts. I wanted the original parts as found in the arcades. The Tekken stick has a pretty awesome case made out of thick plastic with metal plates on the top and bottom.

Here are the pictures of the modded stick:

Image

Image

As parts I used:

– original Sanwa JLF-TP-8YT-SK Stick
– Sanwa octagonal restrictor Plate GTY
– red ball Sanwa LB-35
– red Sanwa 30 mm snap-in buttons OBSF-30
– Start and select: yellow Sanwa 24 mm snap-in buttons OBSF-24

Plus several screws, crimp-style quickconnects and other small parts.

The buttons in the Hori are directly soldered to the PCB, without any wires! This design strikes me as extremely bad, but it is probably the cheapest solution. On the other hand, the case of the controller struck me as very nice and sturdy.

I desoldered the PCB from the buttons using solder wick, and re-attached it at a different place using an angle-bracket screwed directly into the plastic case. This way, I gained enough room to guide wires from the new buttons to the PCB. I tried to find a way to attach the PCB directly to the bottom of the case, but there was no room for screws there. It turns out that there is no space between the plastic bottom inside the case and the outer aluminum piece.

The solder joints on the PCB are easy to access and rather big. This made it easy to solder the new wires to them. The PCB functions perfectly as a Playstation 1 controller and works with adapters of all kinds to connect this controller to other devices.

The way the original stick is mounted to the case was quite nicely done by Hori. The stick is attached to the metal cover by four screws that screw into tapped holes on four metal angle brackets that are welded directly to the underside of the metal top cover.

In order to mount the new Sanwa stick, I first detached its rectangular metal mounting plate and looked for other holes to use. After detaching the microswitches, I found four holes in the Sanwa main body that almost aligned with the mounting holes in the Hori case.

Sadly, the holes in the Sanwa body do not perfectly align with the tapped holes on the metal brackets on the case. To fit the new stick, I first enlarged the holes in the Hori case using a power tool. This destroyed the tap, and I decided to use nuts and washers instead. I then used a dremel to file the four holes in the Sanwa body to make room for screw heads between the body and the microswitches. To mount the Sanwa stick, I then simply used four small screws with nuts and washers.

The button holes in the Hori case already have the correct diameter needed for the new Sanwa buttons. However, there are small metal tongues sticking out. The tongues are used to keep the Hori buttons from rotating, but are in the way of the new Sanwa buttons. I used the dremel to file all of them off.

At the end, I have a discovery to share: the hole for the joystick in the Hori case is too small to house a Sanwa stick with stick cover. The stick cover is a black, slightly conical, plastic piece that goes around the bare metal stick shaft. If that cover is on, the stick collides with the hole when using a diagonal direction. This is undesirable, because the stick throw should only be limited by the restrictorplate, and not the hole in the case. Otherwise the stick throw will feel like a mixture of circular and octagonal. The solution is to simply leave the joystick cover off. The Sanwa dustplate will not fit anymore, but that is not a problem since the old Hori one will fit the new coverless stick perfectly.

Until next time,
rsn8887