Main > Main Forum
Control to interpret speed as axis/button? (pedal to play!)
vputz:
Okay, I'm trying to find a way to physically justify all my computer gaming, so I'd like a way to interface a stationary bike or treadmill into a game control (lol--hey, it's not a bad idea).
I'd actually be using this more on the computer than on the MAME box, but the challenge is similar and this board was so helpful when I built my CP that I thought folks might have ideas...
I'm thinking that starting with a rotational encoder would be a good start, but then I hit a wall, because of course I don't want the output sent as mickeys or a position going around and around--I want to encode the speed as an axis measurement. It could be that some sort of PIC is what I need -- but the problem gets worse, because I want to have the output not just as an axis/throttle measurement, but also have the option to set ranges to button presses or keyboard outputs (if speed > X then press "walk", but if > Y then press "shift+walk"; you get the idea). I can find "arbitrary switch or potentiometer to HID device" circuits, but I'm a little flummoxed as to how to encode the speed or write the logic to drive the output (or, I know of at least one board which could do the logic if I wrote an on-computer program to get the signals, but I don't know from there how to insert keystrokes into the input chain or make a "virtual device" which could then serve those inputs...
Any suggestions on this ridiculous idea? I'm SURE it's possible for me to do this--I just need the big steps (grin)
MonMotha:
Certainly not rediculous, though I know of no ready-made solution to do it. I could probably whip up the code required for a USB HID AVR or similar to do it given a little time if you can't find anything at all that's premade. There are devices with multi-channel ADC inputs and of course plenty of IO for buttons and such, so I wouldn't put it past somebody to have already cooked up a solution, though you may have to look more at devices designed for instrumentation.
The biggest issue is to know what kind of outputs you need and how to get them. From the sound of it, a rotary encoder could do just fine - a uC could interpret the incoming pulses however required and back out speed or similar from them. No ADCs needed, then. If you have incoming voltage or current levels that vary in an analog nature, then you'd need ADCs. That's fairly easy to deal with, as well (argubaly easier to just map to joystick axes and throw some thresholds on for keypresses).
I'm guessing you can find something that would suit your needs if you look hard enough, but if not, I could do something for you.
tkuper05:
Hook up two bikes and interface the controls with Track and Field lol.
Kremmit:
Didja ever stick playing cards in your bike's spokes so it sounded like a motorcycle? Just stick a leafswitch in there instead. :laugh2:
vputz:
--- Quote from: MonMotha on April 28, 2006, 12:36:45 am ---Certainly not rediculous, though I know of no ready-made solution to do it. I could probably whip up the code required for a USB HID AVR or similar to do it given a little time if you can't find anything at all that's premade.
--- End quote ---
Heh--thanks; I may take you up on that yet, but I'd like to flail around a while and see what I can create.
--- Quote ---The biggest issue is to know what kind of outputs you need and how to get them. From the sound of it, a rotary encoder could do just fine - a uC could interpret the incoming pulses however required and back out speed or similar from them.
--- End quote ---
That's my current thought, at least, and that's where I'm going to start, maybe encoding things and reading them with a programmable board like an Arduino (www.arduino.cc) or some such device just to get the basic idea down ("Can I read the spinner?")--and then use that device to control a HID controller. Having two bits of electronics drives the cost up, but it's not like I'm going to be making a bunch of these or anything.
The irritating thing about this is the programmability, because particularly in computer games you never know if games are going to accept keypresses or game devices--or even rarer, if games will accept multiple devices (for example, I may want to play a racing game, steering with the gamepad but taking throttle input from the pedals--well, they're not part of the same controller, so the game goes wonky).
I've even thought about making a generic HID device driver which accepts input from user-space programs, but last time I wrote a device driver I wound up doing a LOT of hard drive recovery (imagine that). Hey, it got my SpaceOrb working under XP; I can't complain--but I'd rather avoid it if possible.
I'll keep poking around. Thanks for the suggestions! ("leaf switch in the spokes" indeed, lol!)