An input/output controller for virtual pinball machines, with plunger position tracking, accelerometer-based nudge sensing, button input encoding, and feedback device control.

Dependencies:   USBDevice mbed FastAnalogIn FastIO FastPWM SimpleDMA

You are viewing an older revision! See the latest version

Homepage

This project turns a KL25Z into a USB input/output controller for virtual pinball cabinets. It provides a number of special I/O features unique to pinball cabinets: analog plunger position input, nudge sensing, cabinet button input, and force feedback actuation.

The device appears as a USB joystick on the PC, so it's plug-and-play with both Windows and Visual Pinball. As far as Windows is concerned, it's just an ordinary joystick, so no special drivers are needed - it works with the built-in Windows HID driver. Visual Pinball is set up to take plunger and nudge input from a joystick natively, so you only have to set some configuration options to tell VP how your joystick is set up.

Downloads

Hardware build guide (PDF): detailed instructions on how to build a Pinscape Controller for your own virtual pinball cabinet..

Config tool for Windows (.exe and C# source): this is a Windows program that lets you trigger plunger calibration mode and configure some software options on the controller (change LedWiz unit number, enable/disable the plunger sensor).

Custom VP builds: I created a modified version of Visual Pinball that you might want to use in combination with this controller. If you're using the plunger, you really should use this modified VP, because it has some special handling for plunger calibration specific to the Pinscape Controller. If you're not using the plunger, you might still want it for the enhancements to nudge handling. The modified version also works with any other input controller, so you can get the enhanced nudging effects even if you're using a different plunger/nudge kit. The big change in the modified version is a "filter" for accelerometer input that's designed to make the response to cabinet nudges more realistic. It also makes the response more subdued than in the standard VP, so it's probably not to everyone's taste. The changes have already been merged into the VP main code base, but (as of August 2014) they aren't in any of the officially released builds yet. In the meantime, you can use my custom builds of the 9.9 and Physmod5 versions of VP. Source code for the changes is also included, of course.

Output circuit parts: This is a saved shopping cart at mouser.com with the parts needed for each output driver, if you want to use the LedWiz emulator feature. Note that quantities in the cart are for one output channel, so multiply everything by the number of channels you plan to use, *except* that you only need one of the ULN2803 transistor array chips for each *eight* output circuits.

Features

- Plunger position sensing, using a TAOS TSL 1410R CCD linear array sensor. This sensor is a 1280 x 1 pixel array at 400 dpi, which makes it about 3" long - almost exactly the travel distance of a standard pinball plunger. The idea is that you install the sensor just above (within a few mm of) the shooter rod on the inside of the cabinet, with the CCD window facing down, aligned with and centered on the long axis of the shooter rod, and positioned so that the rest position of the tip is about 1/2" from one end of the window. As you pull back the plunger, the tip will travel down the length of the window, and the maximum retraction point will put the tip just about at the far end of the window. Put a light source below, facing the sensor - I'm using two typical 20 mA blue LEDs about 8" away (near the floor of the cabinet) with good results. The principle of operation is that the shooter rod casts a shadow on the CCD, so pixels behind the rod will register lower brightness than pixels that aren't in the shadow. We scan down the length of the sensor for the edge between darker and brighter, and this tells us how far back the rod has been pulled. We can read the CCD at about 25-30 ms intervals, so we can get rapid updates. We pass the readings reports to VP via our USB joystick reports.

The hardware build guide includes schematics showing how to wire the CCD to the KL25Z. It's pretty straightforward - five wires between the two devices, no external components needed. I use two GPIO ports for digital outs to send signals to the device and one as an ADC in to read the pixel voltage levels (== brightness). The config tool has a feature that lets you display the raw pixel readings across the array, so you can test that the CCD is working and adjust the light source to get the right exposure level.

- Nudge sensing via the KL25Z's on-board accelerometer. Mounting the board in your cabinet makes it feel the same accelerations the cabinet experiences when you nudge it. Visual Pinball already knows how to interpret accelerometer input as nudging, so we simply feed the acceleration readings to VP via the joystick interface.

- Cabinet button wiring. Up to 24 pushbuttons and switches can be wired to the controller for input controls (for example, flipper buttons, the Start button, the tilt bob, coin slot switches, and service door buttons). These appear to Windows as joystick buttons. VP can map joystick buttons to pinball inputs via its keyboard preferences dialog. (You can raise the 24-button limit by editing the source code, but since all of the GPIO pins are allocated, you'll have to reassign pins currently used for other functions.) (Note: this feature is still experimental; it hasn't been thoroughly tested yet.)

- LedWiz emulation (limited). In addition to emulating a joystick, we emulate the LedWiz USB interface, so controllers on the PC side such as DirectOutput Framework can recognize it and send it commands to control lights, solenoids, and other feedback devices. We assign 22 of the KL25Z's GPIO ports for this purpose. This part is still experimental, and it has some limitations, particularly that the KL25Z hardware only has 10 PWM channels - so it can't be used to control a full bank of 5 RGB flashers, for example. The software also doesn't support any of the LedWiz flashing modes. To use this feature to control physical devices, external power driver circuitry is required, because of the paltry 4mA output capacity of the KL25Z GPIO ports. The build guide includes a relatively simple and robust output driver circuit design as a reference.


All wikipages