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 peripheral device for virtual pinball cabinets. It appears as a USB joystick to the host computer, so it's plug-and-play with Visual Pinball on Windows - the built-in Windows HID driver recognizes the joystick configuration, so no driver software is needed on the PC. Visual Pinball is set up to take plunger and nudge input from a joystick natively, so the only configuration required is to turn on joystick input in the VP keyboard preferences.

Hardware build guide (PDF)

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.

- 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 32 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