Main > Main Forum
Anyone made a auto 4way/8way switching joystick?
<< < (14/17) > >>
terrahwk:
Well, I don't have a build video... but will see if I can describe it.

Servos and servo controller came from www.robotgear.com.au but any local hobby/robotics store should have this stuff.

I used these servos http://www.robotgear.com.au/Product.aspx/Details/421
And the Pololu 6-channel micro maestro servo controller http://www.robotgear.com.au/Product.aspx/Details/403

I fell in love with the servo controllers, they are very flexible and quite small.

This shot has the I-Pac keyboard encoder, one Pac-Drive LED controller and the servo controller. The servo controller is the really small board under the keyboard encoder.



The joysticks I used are Ultimarc Mag-Stick Plus 4/8-way switchable. The white lever on the site is part of the locking plate. There's a small lump on the joystick housing that helps keep the locking plate in the correct position - I removed it using a dremel so the servo has an easier time moving the locking plate. I could probably have left it there, the servo is surprisingly strong.

It's really just a matter of getting everything mounted and connected, and that will vary according to your control panel. Most of the stuff was just found about in the shed - the push-rods that connect the servo to the joystick for example are simply steel rod that has had a flat section ground into each end. They are connected to the joysticks with very small nuts and bolts that came off an old broken helicopter (model). The servo controller itself runs off USB power, but it needs an external 6V supply to power the servos. I'm running my servos off 5V, as that's what I had available.

The servo controller contains a small amount of flash RAM, and it comes with software and a simple programming language. With a servo, you simply tell it where you want it to "be" and it will rotate to that position and stay there. Any attempts to move it will be met with resistance, depending on how strong the servo is. The position will vary according to each build. You can use the software that comes with the servo controller to play with it until you find the right value.


You can use the software and move the slider, the servo will move in real time. Basically I wrote the following script in the above software and saved it to the servo controller. The script gets called whenever I want the servos to move.

--- Code: ---8
sub start
8 equals if
  4105 frame
else
  7373 frame
endif
0 frame
quit

sub frame
  dup
  0 servo
  1 servo
  1000 delay
  return

--- End code ---

I'm no coding guru, so all this does is set up some simple logic - If I call the script with the value "8" (or no value) then it will tell both servos to move to position 4105. If the script is called with any other value, the servos will move to position 7373. (The scripting language uses RPN-like notation, which is why it might look a little odd) These values were found by experimentation.

The batch file (I'm using Windows XP) looks like this and I call it "runmame.bat":

--- Code: ---@echo off
d:
cd d:\mame

findstr /b /r "%1$" game-stick-mapping.txt > result.txt

for /f %%A in ("result.txt") do if %%~zA NEQ 0 goto four

echo 8-way
usccmd --sub 0,8
goto end

:four
echo 4-way
usccmd --sub 0,4
:end


mame "%1"
--- End code ---

Again, I take the easy way out. I have made a hacked version of controls.xml and it simply contains the rom names of roms that are 2 or 4-way games. I did this as my XML parsing skills are non-existant, but I can write a simple batch file :)
Basically, the batch file searches for the ROM name in the file "game-stick-mapping.txt". The result is written to a temporary file. If the file size is 0 then obviously the ROM name wasn't found so the assumption is made that the game is 8-way. It then calls the servo controller and passes the parameter "8" (or "4", if the ROM was found) and then finally calls mame. The file I use is here (but all credit should go to the creators of controls.xml, any mistakes are likely to be from me) http://pastebin.com/download.php?i=twbzDgSf
The batch file is therefore called like you would mame:
runmame.bat 1942.zip

I use Hyperspin as the front-end. Hyperspin won't run batch files, so I came across a utility called "Bat-to-exe-converter" here http://www.f2ko.de/programs.php?lang=en&pid=b2e
You can feed it a batch file (like the one above) and it will "convert/compile" it into an exe. Hyperspin then accepts this exe instead of mame.exe. (although I don't pass any other parameters to mame.exe - I have it all set up in mame.ini. If you pass parameters through you might need to adjust the batch file)

I'm sure someone with a little coding knowledge could write up something that properly parses controls.xml and calls the servo controller directly. I thought about trying - I used to do a bit of C coding, but that was over 10 years ago... so it's a bit beyond me at the moment.
DaOld Man:
Very cool!
I bet you could create a mala plugin to act as the bat file does.
Very interesting work.
I may try this on my next build.
danny_galaga:

--- Quote from: DaOld Man on January 02, 2011, 09:46:44 pm ---Very cool!
I bet you could create a mala plugin to act as the bat file does.
Very interesting work.
I may try this on my next build.


--- End quote ---

Yeah, nice work (",)

I've only just discovered mala and the plug ins aspect of it looks very useful indeed...
jipp:
this is a pretty cool idea.  i just went with a dedicated 4 way stick on my cab..  but i could see this coming in handy if you do not have a lot of room.. like converting a cab to mame.. some of them cabs have small control panels..  also this would be nice in a bar top too.  will book mark this for when my skills reach the desire level needed for this. :)

rock on.
chris.
danny_galaga:

--- Quote from: jipp on January 03, 2011, 07:12:48 pm ---this is a pretty cool idea.  i just went with a dedicated 4 way stick on my cab..  but i could see this coming in handy if you do not have a lot of room.. like converting a cab to mame.. some of them cabs have small control panels..  also this would be nice in a bar top too.  will book mark this for when my skills reach the desire level needed for this. :)

rock on.
chris.

--- End quote ---

Not just that, but some CP's with a stack of joys on it look, to use an American euphemism, 'like ass'...
Navigation
Message Index
Next page
Previous page

Go to full version