For downloads and build instructions, please visit the main project page: https://developer.mb..._Controller_V2/
I've been working on implementing what I think is a novel (and, if all goes well, really good) approach to analog plunger sensing. I don't quite have it working to my satisfaction yet, but it's looking pretty promising, so I thought I'd share an outline of the design in case anyone else is interested in setting up the same kind of thing. Be warned, it's most definitely not an off-the-shelf solution a la the VirtuaPin kit. My approach requires some soldering and some custom mechanical work. I'm going to open-source-ify the software and post the wiring diagrams once I have everything working properly, so anyone should be able to replicate it without any custom engineering work, but it most definitely won't be a plug-n-play kit.
(It's also not a way to save money. It'll run about $75 in parts if you count the plunger, so if you take into account the value of your time and the risk of breaking something in the assembly process, it's probably pricier than one of the commercial kits. So why am I bothering? Because of what I think will be superior performance.)
The key piece of equipment is something called a CCD linear sensor array. This is basically like the image sensor element in a digital camera, but rather than arranging the pixels in a rectangular grid, they're all laid out in a single file. (Well, okay, that's technically a special case of a rectangular grid. ) There's a particular sensor available, the TAOS TSL 1410R, that's so uncannily perfect for this application that I have to think it was designed especially to be a pinball plunger sensor. It's a single line of 1280 pixels at 400 dpi, which makes it 3.2 inches long - just a little bit more than the pull range of a standard pinball plunger. The sensor is packaged on a little circuit board that's about 1 cm wide and just a little longer than the sensor element. It runs about $35 and is readily available from electronics distributors on the web (e.g., mouser.com).
Here's what the sensor looks like. The thin silver line in the middle is the glass window containing the pixel array. There are 400 pixels per inch, so they're too small to see individually. The gold bits are circuit board traces. The 13 pads at the bottom are the terminals; you can see my elegantly soldered wiring already attached I'd prefer to connect to it with some kind of pluggable edge connector, but it doesn't seem designed for this. After extensive searching I couldn't find anything suitable, so I decided to just solder the wires.
For deployment, the physical arrangement is that we mount the device above 5-10 mm above the plunger, with the image sensor facing down. As close as we can get it while assuring enough clearance so there's no physical contact.
Somewhere below the plunger we put a light source, facing up, so that it illuminates the sensor.
The theory of operation is based on the idea that the plunger casts a shadow on the sensor in this arrangement. When we read the sensor, we'll see darker pixels where the plunger is casting a shadow, and brighter pixels where it's not. The position of the edge between bright and dark pixels tells us the current position of the plunger.
The thing I like about this approach is that it provides an absolute, high-resolution position reading. All of the other approaches I've seen to this problem use some kind of relative position sensor - the VirtuaPin and NanoTech plungers use IR proximity sensors, and I've seen posts about DIY designs with mechanical potentiometers and linear induction sensors. All of those give you a relative position. The problem with relative positions is that the underlying physical quantities tend to have some variability separate from the thing you're trying to sense, which makes the relative sensing drift and wander over time. The drift requires periodic recalibration, and the wandering requires degrading the resolution to reduce noise. The existing solutions thus all seem to require fairly hefty trade-offs of reduced precision for increased stability. With the linear sensor, in contrast, we're sensing an absolute position in space, because the pixels have fixed positions in space. The physical setup is thus inherently immune to calibration drift. In addition, the raw resolution of this device is so high that we should be able to get a really excellent signal/noise ratio.
How do we electrically interface the sensor to the computer? Well, it's not something we can just hook up directly to a PC. But it is perfectly suited for connecting any of the current crop of microcontrollers, such as Arduinos. The one I'm using is a Freescale FRDM-KL25Z. It's cheap ($12.99), fairly powerful, very integrated (e.g., it has on-board USB), and even has an on-board 3-axis accelerometer, which I'm going to use as an analog nudge device.
Wiring: The TAOS sensor has 13 terminals. A number of these can simply be wired together, so you end up with only 5 wires between the sensor and the microcontroller. The KL25Z has integrated digital outs and analog ins, so it doesn't require any external hardware to interface the KL25Z and the TSL 1410R - you just connect wires directly between the appropriate 5 ports. The KL25Z can also power the sensor, so there's no other wiring needed for the sensor besides these 5 connections to the KL25Z.
Interfacing to Visual Pinball: VP is set up to read an analog plunger via the joystick interface. The KL25Z has an on-board USB port that lets it act like a USB HID (human interface device), so with the proper USB configuration reports we can make it look to Windows like a joystick. Once that's in place, you just have to enable the analog inputs in the VP keyboard settings.
Software: I've written a first cut of the software, and I've just gotten to the point of installing the sensor in the cabinet to try it out under real-world conditions. I was pretty thrilled to discover that it basically works, even in this preliminary setup. Amazingly, the CCD array is so sensitive that it gets a usable signal from just the ambient light in the cabinet from the random little LEDs scattered around the interior (fans, USB devices, etc). I haven't even installed a dedicated light source yet and it can already read the position with pretty good stability. When I was in the planning stages, I figured I'd have to go to all sorts of lengths with shades and reflectors to get just the right lighting, but the sensor is so good that it looks like there'll be practically no special effort needed for lighting.
What's left to do: I'm getting pretty good position reports from the plunger, but the timing of the reports doesn't seem to work quite right with actual VP tables. I've only just started playing with it in VP, so this might take some time to figure out.
I'm also sending accelerometer reports for analog nudging, and right now that part is a bit of a disaster. It seems to be doing the right thing when I look at it in the joystick control panel, but it seems very bipolar in VP - I get either dead calm or VP thinks the cabinet is on a paint shaker, and there doesn't seem to be anything in between. Not quite the subtle English I'm aiming for. I'm hoping it's just a matter of tweaking the calibration parameters in VP.
At the moment, I think I have a pretty good proof of concept. It'll definitely take some more work to make it real, so I'm not quite ready to post the software yet. I'll certainly do that once I have it stable enough, but I'd be happy to send the working version to anyone who wants to try their own.
Edited by mjr, 09 June 2016 - 10:27 PM.