Mike R / Mbed 2 deprecated Pinscape_Controller

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.

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.

Separately but relatedly, I created a modified version of Visual Pinball that you might want to use in combination with this controller. The modified version also works with any other input controller, but it does have some special handling for plunger calibration that's special to the Pinscape Controller. The big change in the modified version is a "filter" for nudge input that's intended to make the response to accelerometer nudging 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 are being merged into the VP main code base, but as of August 2014, they aren't in any of the officially released builds. In the meantime, you can find my modified VP builds of the 9.9 and Physmod5 versions of VP here: https://www.dropbox.com/sh/0gtnrck3yr9w9oa/AAAZpK2Nhw2HtOshcJWkIe6ha?dl=0

Downloads

Hardware build guide (PDF): read this if you want to build this project 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).

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. We operate the device in its 2g (-1g..+1g) mode at 800 Hz, and pass the acceleration readings to the PC via our USB joystick reports. The accelerometer sampling rate is much faster than our USB report rate, so we integrate readings between USB reports. This lets us report the cumulative effects of a nudge event rather than just a random subset of instantaneous samples, for more realistic effects in the simulation.

- 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). The device emulates the LedWiz USB interface, so controllers on the PC side such as DirectOutput Framework can recognize it and send it commands to turn lights, solenoids, and other feedback devices on and off. 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 can only provide PWM control to 10 outputs. The software also doesn't support any of the LedWiz flashing modes. Further, to use the LedWiz emulation to control physical devices, external driver circuitry is required. The KL25Z ports are limited to 4 mA at 3.3V, so they can't drive typical feedback devices directly. The build guide includes a reference output driver circuit design, using an optocoupler and a MOSFET to provide fast switching of high-power devices such as contactors, motors, solenoids, and LEDs.


All wikipages