jpdrolet Posted May 13, 2008 Report Share Posted May 13, 2008 Last week I had to interface an application with a game controller. The funny part is that it uses the joystick buttons to select a target region with the cursors of a graph, Up/Down arrows to select the power and the buttons to trigger a real laser. The goal of the "game" is to flatten those nasty bumps in the transmission curve of a fiber grating by selectively laser heating offensive regions. The need arose from the fact that the application required a lot of mouse clicks (place cursors on target, set power, shoot; many tens of time) and there was a shortage of valid wrists to operate. I did already provided few keyboard shortcuts but it was not enough. The integration of the game controller was relatively easy. I plug the USB device and the Joystick VIs worked immediatly. I wrote a Joystick monitor to poll it and generate value change user events for buttons and controls. These were catched in the user event loop of the application to programmatically move cursors or signaling actual FP controls. While the joystick provides integer values ±32000 for the position, I noticed that it didn't always come back to the same idle position, with errrors up to 3000 counts in position. Is that a common behavior for game controllers of are come controllers are better than others? Quote Link to comment
crelf Posted May 13, 2008 Report Share Posted May 13, 2008 QUOTE (jpdrolet @ May 12 2008, 01:56 PM) ...it uses the joystick buttons to select a target region with the cursors of a graph, Up/Down arrows to select the power and the buttons to trigger a real laser. The goal of the "game" is to flatten those nasty bumps in the transmission curve of a fiber grating by selectively laser heating offensive regions. Cool! I worked on a similar application years ago, except the control was closed loop feedback from a spectral analyzer through a series of mirrors on piezo-electric stages... QUOTE (jpdrolet @ May 12 2008, 01:56 PM) While the joystick provides integer values ±32000 for the position, I noticed that it didn't always come back to the same idle position, with errrors up to 3000 counts in position. Yeah - that's pretty standard. Joysticks are meant for gaming, and a less than 5% error in idle isn't uncommon. That said, when you get an offset, it's often pretty repeatable. In the past, I've written alogrythms that consider <5% of centre as centre. Remember, joysticks are all about change in direction, not position. Quote Link to comment
TobyD Posted May 13, 2008 Report Share Posted May 13, 2008 QUOTE (jpdrolet @ May 12 2008, 10:56 AM) Is that a common behavior for game controllers of are come controllers are better than others? :thumbup: Cool Project. Like crelf said, the offset is pretty standard. There are some controllers that have customizable software that will allow you to set a "center dead zone" so that the position counts don't change until you pass a defined threshold (sounds like what crelf did). http://lavag.org/old_files/monthly_05_2008/post-8758-1210617603.png' target="_blank"> I just purchased a Logitech gamepad that allows me to program the 10 buttons to mimic any keypress or key combitaion. The logitech program runs in the background to handle the translation and can be configured differently for different programs that are running. Could have a lot of cool applications. -Toby Quote Link to comment
crelf Posted May 13, 2008 Report Share Posted May 13, 2008 QUOTE (TobyD @ May 12 2008, 02:47 PM) There are some controllers that have customizable software that will allow you to set a "center dead zone" so that the position counts don't change until you pass a defined threshold (sounds like what crelf did). Kind-of: I just ignored anything +/- a threshold. Quote Link to comment
jpdrolet Posted May 13, 2008 Author Report Share Posted May 13, 2008 QUOTE (TobyD @ May 12 2008, 02:47 PM) :thumbup: Cool Project.Like crelf said, the offset is pretty standard. There are some controllers that have customizable software that will allow you to set a "center dead zone" so that the position counts don't change until you pass a defined threshold (sounds like what crelf did). I just purchased a Logitech gamepad that allows me to program the 10 buttons to mimic any keypress or key combitaion. The logitech program runs in the background to handle the translation and can be configured differently for different programs that are running. Could have a lot of cool applications. -Toby What I did is to map the position to 20 cursor speed levels. The mapping is non linear to allow fine pixel moves and high speed coarse moves. Quote Link to comment
PaulG. Posted May 13, 2008 Report Share Posted May 13, 2008 Yes. Some joysticks are better than others. I've seen the same errors with a $50 Logitech "gaming" joystick but not with a $300 industrial grade joystick. Industrials have extra circuitry that generates a true "0" when in neutral along with added robustness and waterproofing. It all depends on what you need it to do. If you're just gaming the Logitech is probably fine. But if you're looking at ultrasonic transducer signals with fluids getting splashed all over the place you need to spend some money. Quote Link to comment
crelf Posted May 13, 2008 Report Share Posted May 13, 2008 QUOTE (jpdrolet @ May 12 2008, 03:31 PM) What I did is to map the position to 20 cursor speed levels. The mapping is non linear to allow fine pixel moves and high speed coarse moves. Perfect - all you need to do is map the centre position to speed=0. QUOTE (PaulG. @ May 12 2008, 03:35 PM) But if you're looking at ultrasonic transducer signals with fluids getting splashed all over the place you need to spend some money. That's just down-right spooky - that's the application I used a joystick for too... Quote Link to comment
Michael Aivaliotis Posted May 13, 2008 Report Share Posted May 13, 2008 I would of used a Wii nunchuk controller. Quote Link to comment
eaolson Posted May 13, 2008 Report Share Posted May 13, 2008 QUOTE (TobyD @ May 12 2008, 01:47 PM) I just purchased a Logitech gamepad that allows me to program the 10 buttons to mimic any keypress or key combitaion. We bought a series of piezoelectric motors and an electronic control system a couple of years ago. All in all, we've probably spent $20,000. (What is that, maybe 1.50 euro these days?) Imagine my amusement when the analog controller that came with the system was labeled "Sony Playstation." Quote Link to comment
jpdrolet Posted May 13, 2008 Author Report Share Posted May 13, 2008 QUOTE (Michael_Aivaliotis @ May 12 2008, 04:13 PM) I would of used a http://www.amazon.com/Nintendo-Nunchuck-Controller-Wii-Nunchuk/dp/B000IMYKQ0' rel='nofollow' target="_blank">Wii nunchuk controller. LabVIEW is on Wii :question: Quote Link to comment
Wire Warrior Posted May 13, 2008 Report Share Posted May 13, 2008 QUOTE (jpdrolet @ May 12 2008, 03:23 PM) LabVIEW is on Wii :question: Not exactly. The Wii controllers are bluetooth interfaced. That means they can be linked to any bluetooth system with the correct drivers. It just so happens that there are LabVIEW drivers for the Wii-mote out in the world. Check the NI document http://decibel.ni.com/content/docs/DOC-1353' target="_blank">here for more details. Jason Quote Link to comment
carlover Posted May 14, 2008 Report Share Posted May 14, 2008 QUOTE (jpdrolet @ May 12 2008, 08:31 PM) What I did is to map the position to 20 cursor speed levels. The mapping is non linear to allow fine pixel moves and high speed coarse moves. we did similar thing on a multiple axis robotic platform (with stepper motors). since we used cheap usb game controller we had to define dead band, however we used velocity profile mode and mapped it to position of the 'stick', i.e. further you push it from the center faster it will go. Also, one of the spare buttons on the controller was used as a 'safety' - you had to press and hold it while controlling the robot (to avoid unintentional movement in case controller gets dropped, bumped, etc.). It's pretty fun... Quote Link to comment
robijn Posted May 15, 2008 Report Share Posted May 15, 2008 I also wanted to use the standarized joystick interface instead of expensive hardware to detect joystick and potmeter positions. I ended up with this controller: http://www.lbodnar.dsl.pipex.com/joystick/ which is very nice. You could even use it to acquire voltages between 0 and 5V as really cheap analog input device. But if you do this be warned, the inputs are not protected so this is not advisable. This one has 10 bits, sufficiently accurate for me. So far I only needed 4 of the possible 8 axes and about 15 buttons of the 32 possible. The best feature of this type of controller is that you don't need any special drivers to use it (on windows). Joris Quote Link to comment
crelf Posted May 15, 2008 Report Share Posted May 15, 2008 QUOTE (robijn @ May 14 2008, 10:29 AM) I also wanted to use the standarized joystick interface instead of expensive hardware to detect joystick and potmeter positions. I ended up with this controller: Sweet! Quote Link to comment
Thang Nguyen Posted October 16, 2008 Report Share Posted October 16, 2008 QUOTE (robijn @ May 14 2008, 09:29 AM) I also wanted to use the standarized joystick interface instead of expensive hardware to detect joystick and potmeter positions. I ended up with this controller:http://www.lbodnar.dsl.pipex.com/joystick/ which is very nice. You could even use it to acquire voltages between 0 and 5V as really cheap analog input device. But if you do this be warned, the inputs are not protected so this is not advisable. This one has 10 bits, sufficiently accurate for me. So far I only needed 4 of the possible 8 axes and about 15 buttons of the 32 possible. The best feature of this type of controller is that you don't need any special drivers to use it (on windows). Joris Hi, I did take a look in the example with the Joystick. Beside the buttons, could you please tell me how we can get the data of the potentionmeter? Best regards, Thang Nguyen Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.