My next bit of tinkering is going to be a 3D printed rotary mod for Sanwa JLF and maybe JLW joysticks.I'm using a 12 position ALPS rotary switch.

GroovyGameGear has a program for their GPWiz that converts inputs from 3 wires (+ground) to 2 possible gamepad presses which are mapped in MAME to turn left and turn right.To get the 3 inputs, you wire the 12 tabs on the rotary switch like the attached picture.

I don't have a GPWiz. I could probably accomplish something useable with an autohotkey script, but official MAME builds don't recognize fake keyboard input. They recognize fake gamepad input, but I'd have to install fake gamepads and it's already hard enough keeping the current gamepad order straight accross multiple programs without throwing fake gamepads into the mix.

So I'm thinking maybe a hardware solution, but using something cheap like logic gates rather than a microcontroller.

The way it needs to work is:

Lets use x and y for variables (not the keys X and Y).

Last input pulled to ground = xCurrently pulled to ground = y

if x=1 & y=2, then Right (an output to the keyboard encoder pulled to ground)if x=1 & y=3, then Leftif x=2 & y=3, then Rightif x=2 & y=1, then Leftif x=3 & y=1, then Rightif x=3 & y=2, then Left

It would also be nice if the output were only sent momentarily so that MAME doesn't see a key as being pressed all the time. Pretty sure I can figure that part out.

My question for you electronics guys is does a specific component come to mind for such an application?

EDIT: ....or should I just buy a teensy board and learn how to program it?

I guess if there was a solution with a handful of simple gates, some smart person would have gone that route already.

There are lots of ways to go with this. I'll probably just go with a sub $10 arduino knock-off.I bought a full size arduino, another knock off with a ton of sensors, and book months ago.Maybe my anti-social new years weekend can be spent learning.

If you are still in want of one, I would like to offer helping with programming a small micro-controller such as an Attiny45 that could do what you need, depending on what you are interfacing it to all the discrete parts you should need would be a filter cap on the power line. I would be happy to donate the chip and time to do it. I'm excited to see how your DIY rotary works out and would be happy to be a part of it.

If you are still in want of one, I would like to offer helping with programming a small micro-controller such as an Attiny45 that could do what you need, depending on what you are interfacing it to all the discrete parts you should need would be a filter cap on the power line. I would be happy to donate the chip and time to do it. I'm excited to see how your DIY rotary works out and would be happy to be a part of it.

I appreciate the offer. I haven't ended up doing anything yet...still tinkering with the hardware maybe one evening every two weeks.The rotary sticks aren't going to fit in my own cab because the CP is too shallow.So this is more just a making it for the enjoyment of working on it thing with no real timeframe and no use for it once it's done. I just want it to exist!!!

Would using the Attiny45 get rid of the need for a custom PCB like the older microcontroller I linked to above?I guess what I'm asking is are premade dev boards available for it that would work?

Would using the Attiny45 get rid of the need for a custom PCB like the older microcontroller I linked to above?I guess what I'm asking is are premade dev boards available for it that would work?

Yes and no, essentially it would be performing the same function as the attiny2313 that they used on that board, except that it wouldn't have a board and only be for one joystick so you would have to either use piece of a prototype board or attach the wires directly to the chip or a socket. Though it also wouldn't be difficult to get a small board printed by oshpark. The programming of the chip would be done with a standard zif socket programmer. The advantage of it over a solution like you posted above is the cost per piece, an Artiny45 will set you back $1.25 or less plus a few cents for the cap. It does require more external hardware to program it, but even that is pretty cheap $2- $5 on ebay. ex http://www.ebay.com/sch/?_nkw=avr%20usbasp. If it was desired, it would be easy to create a entry at say OSHPark where you could print off 3 circuit boards for about $5. So it could be as simple as hooking it up dead bug style with wires directly to the chip or print a professional board for less than $10 for 3.

TLDR: it's a chip with a filter cap and you could attach it to the wires in any number of different ways from printing a board to direct.

It just looked like it would be a fun quick project. I don't get to play around with my electronics as much as I would like to and when I get a chance I don't know what to make...

It sounds like a good solution for how I want things to work. Lets do it! (or rather you do it and then I'll buy the parts and enjoy the results of your work...)I'll try to make more time to get the 3D printed parts closer to a final product.

Thanks Scott, I'll take a look at what he did for debouncing the rotary switch.

Though I guess I didn't state my current theoretical issue very plainly. The issue I'm thinking of (and it may not even really be an issue) is that we are designing a secondary encoder that would sit between say an ipac and a rotary switch that would take the input from the 3 wire interface and determine direction then out put it by pulling one of the L/R lines to ground. My current concern is how long to pull down the L/R lines so that the keyboard/gamepad encoder recognizes it as an input/button press, but doesn't hold it more frames/poll cycles than necessary and counts one rotation twice.

Though this may never be a great solution because of that problem and if it can't be satisfactorily solved, it may just be easier to either figure out how to get the KADE firmware working on a cheap ATMEGA32U4 board, or use a digispark to create the interface board and have it attach as a usb keyboard.

Either way, it should be fun to figure it out and get something to play with.

My current concern is how long to pull down the L/R lines so that the keyboard/gamepad encoder recognizes it as an input/button press, but doesn't hold it more frames/poll cycles than necessary and counts one rotation twice.

I could be oversimplifying, but.....as long as a key press. Browsing google results, 20 milliseconds seems to be a popular number.

I'm not sure what MAME does if you just hold down the button, but I can test in the next few days.(long time for such a simple thing, but I am a busy with work and other projects...and too lazy at the moment)

Here is the proposed board layout and schematic. Once I test them and confirm they are working I'll get the boards made and send you one along with a programmer (in case the code doesn't work as intended, I'm still waiting on these from China though... I ordered some along with some diodes I needed). Turn around to get a board made is generally 2-3 weeks, though I've had it as fast as 1 week.

If you decide not to wait and get your own programmer and such, I'd also be happy to help you get it setup and answer any questions you have.

Basic schematic, with the current code you could use an attiny25/45/85. though it's a bit tight on the attiny25.

Quick render of the board layout. It's actually quite small and less than an inch square.

Ok, everything finally arrived and I've assembled and tested the circuit. I had to make a minor modification to the code, which I've updated above. It seems to be working exactly like I hoped it would, pulsing the R line when a sequence like 12 is found and the L line when 32. So I think for the intent of this adventure it's done.

I probably won't have time to try them until this weekend, but I am looking forward to it. (Also looking forward to learning how to use the programmer you sent, as I'm sure I'll come up with other projects once I get a taste).

Wow, I'm surprised they got there so fast... I was just about to send you the tracking number...

Useful links for the programmer:

WinAVR This is the IDE I use, it's very simple and lightweight (read low features) but it gets the job done. Also, if I'm not mistaken, it includes AVRDude which does the actual programming of the chip.

I found a little time this evening to test out one of your boards and it worked flawlessly. R & L were reversed, but that would be a function of which direction I wired the 1,2,3 inputs.

I didn't get a chance to really play a long game due to quickly throwing together a temporary test setup. I thought I'd just swap the sanwa jlf wiring harness over from the joystick in my cab to the modified one bolted to the edge of my cp, but they were oriented different so the directions were all screwed up. Due to the positioning of the potentiometer and arm, I couldn't just rotate the joystick body.

The good news is that it works and the temporary joystick mount demonstrated that I can fit the rotary mods in my cab if I cut a few holes in the bottom of the CP for clearance.

When I get time. I'll post pics of the test setup in my "cheap 3D printed rotary mod" thread in project announcements.