Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Programming Specific Button Input on Controller (http://www.chiefdelphi.com/forums/showthread.php?t=72299)

Mikesername 17-01-2009 16:14

Programming Specific Button Input on Controller
 
Hey,
Searching didn't help much, mainly because I didn't know how to phrase the query...

But what I want to know is, how could I program a specific button input on the controller? i.e., programming the trigger to activate a motor when pressed...

I know I'm being a little vague but I don't really know how to phrase this question :\

Thanks,
Mike

Alexa Stott 17-01-2009 16:17

Re: Programming Specific Button Input on Controller
 
In WindRiver, you can use joystickname.GetTrigger() and joystickname.GetTop() for the trigger and the top. You can then use joystickname.GetRawButton(button number).

Replace joystickname with the name of your joystick variable. Replace button number with the number of the button (each button is labelled by number on the kit joysticks).

GetTrigger, GetTop, and GetRawButton return true or false.

Mikesername 17-01-2009 16:19

Re: Programming Specific Button Input on Controller
 
How about in LabView?

Thanks for the quick reply, btw :)

keehun 17-01-2009 16:22

Re: Programming Specific Button Input on Controller
 
Yes!

Now, you haven't mentioned if you use LabView or C, but for LabView this is what you would do:

Use the "Joystick -> Get" VI. It's under WPI libraries -> RobotDrive-> Joysticks -> Get

You first need to open a "channel" to that joystick. Then pass in the JoystickDevRef from the OPEN to GET

There are two outputs, one for axis and one for buttons. You need a "Unbundle" vi. It's in Programming->Clusters->Unbundle (you have two choices, by name or just by blocks)

Then you can select which button to read and it will give you a true or a false.

keehun

edit: wow you guys respond fast ;-) (while I was typing he mentioned that he used labview)

Alexa Stott 17-01-2009 16:22

Re: Programming Specific Button Input on Controller
 
Quote:

Originally Posted by Mikesername (Post 802569)
How about in LabView?

Thanks for the quick reply, btw :)

I have only worked for a bit in LabView, but I believe you could just use the blocks that are available in the WPILib. It has all the same functions available, but everything is a block, not actual code. You should be able to "wire" everything in LabView so that if one of the functions returns "true," it turns on the motor. If "false," it turns it off.

Sorry I cannot give more specific instructions than this. Perhaps someone who has worked more with LabView would be able to help.

Edit: keehun just posted the appropriate instructions above.

ShotgunNinja 17-01-2009 16:37

Re: Programming Specific Button Input on Controller
 
1 Attachment(s)
Also, it is possible to make a subVI that lets you select a single button output. Here's a copy of a subVI that I threw together (Sorry, haven't really tested it that much, let me know how it works!). You have to use an unsigned 16-bit int for the "index" pin, can't seem to figure out why (It says "wire enumeration conflict"). I guess speed of recursions doesn't really matter, but it's theoretically slightly faster than using the Joystick Get VI.

Mikesername 17-01-2009 17:03

Re: Programming Specific Button Input on Controller
 
Keehun, I tried what you said and I've gotten this far:



After this, I'm confused... how do I specify button from axis..?


(btw, rookie team/freshman)

EDIT: I cleaned up the wire so I'm not opening two channels for the same USB and the joystick get just comes off of the same wire now, I was just too lazy to retake the SS, so I don't need comments on how that's messed up :P

TotalChaos 17-01-2009 17:21

Re: Programming Specific Button Input on Controller
 
Mikesername,

I think I have to solution to what you are trying to do posted in another thread. Check it out HERE.

I hope it's what you're looking for.

Good luck!

- Austin

Mikesername 17-01-2009 17:34

Re: Programming Specific Button Input on Controller
 
@Austin:
Thanks! Your post with diagrams really helped!

If I have any other questions about it, (which I probably will :P) I'll ask.

Thanks guise.


All times are GMT -5. The time now is 08:47.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi