DIY Pi2Jpac Jamma Adapter

chunksin

Active member
vacBacker
Feedback
21 (100%)
Credits
733CR
In the next release of the image I’ll be adding in analog support so I thought it was worth doing a quick write up on how this will be done.

The traditional option for analog inputs, driving cabs with pots, spinners, trackballs etc has been to buy an APac or Optipac board from Ultimarc. They are very similar to the IPac and have dedicated ports to take connections for up to four analog devices. They are presented via USB and appear as two separate game controllers with X and Y axis which can then be configured in mame as inputs. Dead simple but the boards are over £30 delivered, you need to use up a USB port and there isn’t really room on the nice tidy DIY Pi2JPAC board so you need to mount the APac separately. Analog inputs on the Pi are not natively supported via the digital only GPIO pins so an addon is needed to translate the signals to a digital value. A very cheap solution is a little addon board called the Analog Zero which uses an analog to digital conversion chip called the MCP3008. It comes in a build it yourself kit from RaspIO and can be purchased for around £10 from many electronics and Pi suppliers. You solder the parts together and then mount the board onto the GPIO pins on the Pi. You then have a choice of how to cable your analog inputs into the board, either using header pins and JST XH/NH style connectors or the provided Dupont breadboard style connector pins.

The board provides up to 8 channels of analog inputs, each potentiometer will take up one input so you could support up to four analog joysticks if you really needed to. Each analog input translates as a single joystick axis so a driving cab for example would need three: x axis for steering, y axis for gas and z axis for brake. To wire up your inputs you need to connect the outer pins of the potentiometer to 3.3v and ground, and the centre pin called the wiper to the analog input. Voltage is measured between the outer pins and compared to the voltage between wiper pin and ground so as the pot is turned, resistance goes up and the difference between the wiper and the reference voltage is translated to a numerical value.

The board connects to the Pi via an interface called SPI (Serial Peripheral Interface) which is kind of an updated serial port allowing for much higher clock rates. Thankfully the communication is all handled seamlessly using the system provided libraries which makes writing the code to get the inputs to work much easier! I’ve put together some python code to communicate with the board and create input devices in the operating system that can then be configured in the various versions of mame in the image. Given the various types of input available I’ve come up with a little configuration menu that can be launched via the main service menu, a similar set up to the wifi config menu. At the moment it supports three setups, a driving cab setup with three axis, a single joystick setup with two axis and a two joystick setup with two axis each. You can switch between the operating modes via the menu, change the analog input pins you want to use and adjust a couple of settings for noise and deadzone. Noise is the sensitivity setting, if the inputs seem jerky or not smooth you can increase this setting to reduce that, you might be using pots of a different value for example. The other setting is to create a deadzone for a joystick, if the inputs are not set to zero when centered on an analog stick it can cause you control issues in game so this can be increased or reduced if need be. The defaults are shown in the config menu and have been calibrated against 5k linear pots.

Configuration within the emulators is different for each one, in advance mame for example, analog inputs have to be hard coded within the config files themselves and only tweaked in the menu so they will be added based on my testing with different analog games. The other versions of mame can generally be configured via the menus, tab in mame and F1 in FBA, I can’t guarantee a 100% success rate so you please let me know of any issues you get and I’ll try to resolve them quickly.

If anyone is interested, I've posted my code up on github: https://github.com/chunksin/analogjoy

Chunksin2019-03-20 16:42:24
 

Flinnster

The Dino King
vacBacker
Feedback
29 (100%)
Credits
2,566CR
/analogjoy meaning analog hapiness and not analog joystick ofc
smiley2.gif
 

Retroman839

Senior Member
vacBacker
Feedback
12 (100%)
Credits
7,359CR
hi all, been reading this thread , and for the fist time this morning got my pi to jpac

running sweet ,, image from the good man

2hawman,

all sweet ,,

I have a fault, and it is 5v just decides to drop out , all I do is slide the mini usb out a little and ping its back on it does this 3-4 times , most times I switch on,,, any ideas … ?

It aint really a big deal for me, but just wonderd if anyone had this same thing happen.. ?

also on 2hawmans vertical image both vertions batsugun had no sound,,

cant wait to try your image next chunksin..

looking for the download link now

and then after a win7 groovy set up..

awesome work man,,,
 

JohnnyChaos

Blows own trumpet for CHQ cabs
Feedback
4 (100%)
Credits
325CR
thanks for the download on page 1.. I seem to have acquired 3 or 4 pi3 boards over the past year or so, so think I should do something with them.

I have an old JPAC.. but has anyone tried this with a JVS pac?
 

chunksin

Active member
vacBacker
Feedback
21 (100%)
Credits
733CR
I've used it with a JVS PAC, works fine, just run your video direct to your monitor and line out to rca for your cabs amp You'll obviously need a 15khz or trisync monitor too.
 

Flinnster

The Dino King
vacBacker
Feedback
29 (100%)
Credits
2,566CR
I think you'll need something extra just to drive the flashing inputs. Like a usb led-whizz board is it? And then a mamehooker type script that captures the mame output and passes it over.
 

chunksin

Active member
vacBacker
Feedback
21 (100%)
Credits
733CR
Check out RGBCommander, that works with advance mame via the scripting system, if you need a cheap alternative to a LEDWiz check out the lwcloneu2 thread in the Mame section, you can use an Arduino, mine cost £8 on Amazon :)
 

JohnnyChaos

Blows own trumpet for CHQ cabs
Feedback
4 (100%)
Credits
325CR
any way I can force this to output to 640 x 480??

it works fine in my jamma cabs, but ideally I wanted it in my jvs cab and it doesnt seem to like my upscaler
 

Flinnster

The Dino King
vacBacker
Feedback
29 (100%)
Credits
2,566CR
Yes, choose high res mode in the settings / service menu. Then take the output from the HDMI -> VGA adaptor and pop your monitor VGA cable into there, not via the JPac. No upscaler needed.
 

Flinnster

The Dino King
vacBacker
Feedback
29 (100%)
Credits
2,566CR
So are people still tinkering with their homebrew pi boards?

I certainly am.. and finally managed today to wire up a volume controllable stereo headphone socket for use when playing my cabs late at night, as well as a proper stereo to mono downmix circuit before the speaker output hits jamma.
This means I can also plug a 3.5mm jack in if I want stereo audio on a candy cab like an Astro / Blast etc..
The pi runs constantly at it's own volume and in full stereo - I don't have to touch any software settings.

Here's my current wiring setup:
jammypi_sound_plan_3.jpg

So why the red text?
Well, it's not quite there. First of all my initial run using the resistors I had laying about is waay too much for the mono downmix. It's suggested 33-100ohm is best for 'phone level' audio output. So I guess that's probably what I need for a standard 8ohm jamma cab speaker.
Right now I get nicely loud volumes on the headphones and relatively quiet cab speakers at the same volume dial setting on the amp
smiley36.gif


My only real issue with the audio set up like this is that I can hear a bit of noise / fuzz when using headphones. I have a feeling that this is because, unlike the positive channel inputs for L + R, the ground pin isn't switched - it's constantly wired between the cab speaker, headphone and both sides of the -ve audio amp output channels.

I've seen a few circuits that have a resistor 10x the value of the downmix ones, bridged across the mono output and ground, but I can't fathom out what that would really do in the case of the headphone 'ground'.
This is where my knowledge of impedences / audio circuits hits a brick wall! Should I be putting a resistor in-line on the speaker - pin from the Jpac / Jamma?


Flinnster2020-02-07 23:15:11
 

karlcdoe

Active member
vacBacker
Feedback
7 (100%)
Credits
875CR
Flinnster said:
So are people still tinkering with their homebrew pi boards?

Playing more than tinkering. However, unless I've misread your diagram are you bridging the sound channels after the power amplifier? I would have thought it'd make more sense to bridge the line levels prior to the amp. Last time I did something like that frankly I ended up copying something out of some arcade schematics of a suitable era from atari or midway as most of them have multiple sound or music chips that get summed together somewhere prior to amplification.
 

Flinnster

The Dino King
vacBacker
Feedback
29 (100%)
Credits
2,566CR
Hey Karl - long time no speak!

I am indeed, the idea was specifically to output stereo at the headphone jack.. so it can be used for stereo headphones or connecting to a candy cab with stereo speakers.

The audio amp is a stereo amp with two distinct channels (and -ve terminals).

The pi is running stereo, so it means there would be no faffing of software or hardware running MVS in stereo or games like Capcom Q-Sound stuff, Pacmania etc.. that have stereo audio - as well as the usual mono titles.

After that point it's downmixed to jamma mono, so the board still works in ye average jamma cab too.

What I've worked out so far is the humm comes down to that amp for sure. Granted it's a £2.47 Schenzen special. However, possibly linking both -ve terminals to ground might be causing a ground loop. I don't hear it at the jamma speaker however.

I isolated out the jamma speaker entirely and the humm is still there, so my resistor ponderings above are likely not the solution.

Flinnster2020-03-10 10:22:49
 

samusaran

Active member
Credits
261CR
it’s been ages since I did owt with mine.
What software do you use to put the image file onto the sd card ?

If I remember correctly you couldn’t just drag n drop it.
 
Top