Author
Topic: Yet another Rotary Joystick project (Read 1455 times)

I just finished the first (mechanical) part of my brand new Rotary Joystick project. I decided to construct all pieces by myself in 3D and print them out using my Witbox 2 3D printer (PLA).Attached you see the pictures of the assembled stick and handle and the construction desktop of the single parts. I used a standard SANWA shaft and spring, the rest is printed stuff (even the tiny E-ring ) In theory (mechanically) it works great, let's see, what the controller part will bring...

The electrical part is a Lorlin CK1028 12pos rotary switch, later on I will connect both joysticks to an arduino micro to handle the rotary keyboard presses for MAME.

What do the detents on that rotary switch feel like?I'm using an ALPs switch that I bought off ebay and the detents feel perfect, but the switch costs $5-6 on ebay and doesn't appear to be commonly available elsewhere.

Years ago I built a rotary setup using a 16 postion optical rotary encoder from sparkfun, but you could barely feel the detents. The ALPs gives a satisfying snap to position. (but not too strong)

What do the detents on that rotary switch feel like?I'm using an ALPs switch that I bought off ebay and the detents feel perfect, but the switch costs $5-6 on ebay and doesn't appear to be commonly available elsewhere.Years ago I built a rotary setup using a 16 postion optical rotary encoder from sparkfun, but you could barely feel the detents. The ALPs gives a satisfying snap to position. (but not too strong)

Same here, the detents feel just right, not too strong but clearly noticable. I first wanted to use a real rotary sensor, but it didn't feel right, and there was a too high probability to rotate unintentionally when using the 4-way joystick.

Next step is finished ! I soldered 11 resistors (1.2k) between the twelve pins of the switch, so that the whole construction acts like a potentiometer (three wire solution). First tests using an Arduino Micro were pretty succesfull, I now will implement the final sketch. The main advantage is, that you need only one analog input for one rotary stick, so an Arduino can handle up to twelve sticks (theoretically ! Who in the world needs twelve rotary sticks ? )The Arduino Micro can act as a native HID controller, so that keyboard, joystick and mouse commands can be natively sent to the PC over USB.I already used a Arduino Leonardo using HID in my Pinball cabinet as a keyboard/joystick controller for plunger and nudging, works like a charm.

And it really works great, today I simultaneously tested with two rotary sticks, no glitches, no false moves regardless how fast I rotate the handle.For now the only thing with Arduino keyboard is, that it can only send regular ASCII characters but no special chars. I have to check MAME, which free keys I could use for the movements of both players (sticks), or I have to find a way to get another keyboard implementation.

Well, project succesfully finished ! All I have to do now is, to create a new control panel for my cab to add the two rotary sticks. As promised before, here is the sketch. Currently it is implemented for up to two sticks, but it can be easily modified for more sticks. The "If debug" parts can be removed, they are for testing only !

const int rotaryPins = 12; // number of used pins on rotary switchconst int players = 2; // for one player set to 1, for more than 2 players set to desired value, raise maxPlayers and add array values

const int maxPlayers = 2; // if more than two players are needed, raise value and add corresponding values to the arrays belowint idxLastPin[maxPlayers] = {0, 0}; // variable for storing the last pin. If adding new array values, set their value to 0int analogPort[maxPlayers] = {0, 1}; // portnumber of used analog port for the different rotary sticksString keyCw[maxPlayers] = {"]", "/"}; // sent keypress for clockwise rotation for the different rotary sticksString keyCcw[maxPlayers] = {"[", "\\"}; // sent keypress for counterclockwise rotation for the different rotary sticks