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)

Functions:

- 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).

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

- 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's somewhat limited. The KL25Z only has 10 PWM channels, so we can only provide 10 outputs with intensitiy control - in our default mapping, LedWiz ports 1-10 are PWM capable, and the rest are not. Intensity level settings to other ports will be ignored, but they can still be switched on and off. We also don't implement any of the LedWiz flashing modes; we only implement on/off (on all ports) plus intensity (only on the PWM ports). (I don't think the lack of flashing modes matters for DOF, because I think DOF handles all such effects itself using the on/off primitives.)

To use the LedWiz emulation to control physical devices, external hardware is obviously required. The KL25Z ports are limited to 4 mA, 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