View Full Version : Labview Joystick Buttons...
Hi can someone give me a printscreen of the diagrams in labview to make the joystick buttons work with....lets say a relay. I have a good start but I need some reference to complete what i've started
Thanks
Team 877
Well, I'm on a mac right now but I can give you an explanation.
if I recall correctly, you need to use joystick->get raw data
It gives you an array, if you unbundle by name I think you can access the proper buttons. The unbundle functions can be found under the array section, if you do a right click. Hope you can figure it out from that.
If someone is in their dev environment, please post an image or feel free to correct me.
TotalChaos
17-01-2009, 17:18
As a start you can check out my post in THIS THREAD (http://www.chiefdelphi.com/forums/showthread.php?t=72126).
It's not a full reference, but its a bit. I'll see if I can get a better screenshot for you.
- Austin
i have all that, but some of the concepts i don't understand are which axis does what??? and how do i know that button 1 on my unbundle program is actually working there are too many things i don't understand at this point. also do you have a layout of which button 1-12 goes with what button on the controller?
TotalChaos
17-01-2009, 17:35
I don't have a picture handy or know for certain if all of the buttons match up off the top of my head.
However, while I look for one there is a way you can find out for yourself.
Instead of sending the data to the unbundle function (or I guess you could just have a second wire), right click on the data output of the "Get" VI and select: Create > Indicator. This should put an indicator with labels on you front panel that shows all of the outputs of the joystick. You cam just press the button and see which one lights up on the front panel.
In the meantime I'll keep looking for a full example of what you're looking for.
Hope that helps!
- Austin
Mikesername
17-01-2009, 17:35
i have all that, but some of the concepts i don't understand are which axis does what??? and how do i know that button 1 on my unbundle program is actually working there are too many things i don't understand at this point. also do you have a layout of which button 1-12 goes with what button on the controller?
Yea this is where I'm confused also.
edit: oops... posted while austin was :P
I'll try austin's and reply...
edit2: I tried austin's technique and I got the buttons in the front panel, but apparently I can't wire out of the buttons indicator...
yeah i can now get a relay to work off my axis....but not off a button. It's as if I can't wire a button anywhere to send the signal to the robot saying engage relay with button 1
The Megan 2207
17-01-2009, 17:58
i have all that, but some of the concepts i don't understand are which axis does what??? and how do i know that button 1 on my unbundle program is actually working there are too many things i don't understand at this point. also do you have a layout of which button 1-12 goes with what button on the controller?
I was working with this today and I found out that (on the joysticks that came with the KoP) axis 1 is the x-axis, axis 2 is the y-axis, and axis 3 is the throttle (the dial at the base of the joystick). As for the buttions, I know they're numbered but I'm not sure if those numbers match the button numbers in Labview. I do know that button 1 is the trigger, though. I hope that helps!
Mikesername
17-01-2009, 18:02
I was working with this today and I found out that (on the joysticks that came with the KoP) axis 1 is the x-axis, axis 2 is the y-axis, and axis 3 is the throttle (the dial at the base of the joystick). As for the buttions, I know they're numbered but I'm not sure if those numbers match the button numbers in Labview. I do know that button 1 is the trigger, though. I hope that helps!
That did help as the trigger is wxactly what I was looking for.. don't know about OP tho...
However, I still can't figure out how to wire the button out to say, a motor, so that when that button is pressed it activates that motor... well wait.. with what I had before (where the buttons are put in the front panel) it wouldn't let me wire out... but when I do the actual buttons it does... I'm not making sense, am I.
I'm having the same problem....
TotalChaos
17-01-2009, 18:09
I know it's a little late, but here's my crudely done diagram:
http://img72.imageshack.us/img72/276/diagram1go4.jpg
(Sorry, I did it in paint without a mouse :p )
Give me about 15 minutes or so and I'll get a picture of some way to hook a motor to a button. (It might not be the best way, but I do know a way)
- Austin
The Megan 2207
17-01-2009, 18:12
I had it wired to a servo, but I'm sure it wouldn't be too much different to wire it to a motor. I don't remember exactly how I did it right now, but I can figure it out once I install Labview onto this computer. It might take half an hour or so...
Mikesername
17-01-2009, 18:18
I'm having the same problem....
The diagram helped... but let's say we want the trigger to link to the "drive close" vi... wiring that gives an error that you can't wire boolean into that.
i'm waiting for that button diagram haha
TotalChaos
17-01-2009, 18:59
Ok, here we go.
I have two examples.
One is of the standard code altered so that pressing Button 1 would simulate moving the joystick to one side of the x-axis:
http://img401.imageshack.us/img401/7192/example2lb7.png
This next example get rid of the standard drive code completely and replaces it with a system in which Button 4 and Button 5 contol a left and right motors (respectively) to either on or off. (So like on our practice base, Button 4 would turn one side when pressed, Button 5 the other):
http://img228.imageshack.us/img228/3041/example1gs3.gif
Ok, so as you've probably noticed, the key is this little guy:
http://img102.imageshack.us/img102/359/boolttonumlw4.png
This function converts a boolean value to a numerical value, 0 or 1 (0 false, true 1) It can be found by opening the functions palette and going to: Programming > Boolean and selecting "Boolean To (0,1)".
I think that's what you guys are looking for. If you have any more question just ask!
Good Luck!
- Austin
[EDIT] - And sorry it took me so long, I was needed elsewhere to help with cutting some stuff :P )
Mikesername
17-01-2009, 19:11
I can't wire it from the boolean to 0,1 to the close. I have drive close on the outside of my main loop, and it's wired to the drivedevref global variable, but when I try to wire to it the wire goes dotted. When I try to make another drive close inside the loop and wire to it I get the same problem
Edit: Or is it not possible to set it to drive close? I just wanted to do that so I could test the button input at our next meeting...
TotalChaos
17-01-2009, 19:18
The only thing that needs to be sent to the Close VI is the DevRef wire, which is the pink wire that comes out of the "Open Jaguar" or "Open 2 Motor", etc, VI.
http://img102.imageshack.us/img102/7506/example12un4.gif
- Austin
i can get the relay to turn off but not able to engage it...so when I press the button the relay shuts off
TotalChaos
17-01-2009, 19:46
So you want to press a button to turn the relay on, release the button and do whatever else you need then be able to hit the same button to turn it off?
Or maybe I'm still misunderstanding you?
- Austin
Mikesername
17-01-2009, 21:29
What about pressing a button to turn on the compressor?
Then pressing another one to turn it off?
Sorry if I'm derailing the thread, but I figured it was still somewhat related so instead of starting [another] thread on joystick buttons...
I don't want to turn the relay on and off. I want it always on. But i want it to either have a forward polarity or a reverse polarity. (indicated by green for forward and red for reverse on the spike itself) Can you explain to me how to do this?
TotalChaos
18-01-2009, 14:47
Oh, ok, I think I'm getting a better understanding.. Are you trying to make one button that toggles between forward and reverse, or are you trying to do one button for forward and another for reverse?
- Austin
EDIT - Or forward when held down, reversed when unpressed?
I would like to know how to do both!!! haha
I would like to know how to do both!!! haha
You could use a case structure attached to the button, or one of those boolean selectors with the question mark.
For the case structure, you would just put the relay function in the C/S, then wire a constant to the input.
The boolean selector would be similar but smaller and simpler, and if you know what Im talking about, I'd use it.
Go here for how to use the relay function (as well as any other first function):http://decibel.ni.com/content/docs/DOC-2631
If you right click on the input node and select create->constant it will put an enum there with forward and reverse settings. Because it is an enum, the three states will be 0, 1, 2 for forward, reverse and off, I think (in no particular order, check the enum for the real values).
Hope that helps get you on your way. That should be enough to do both of those scenarios.
A picture of this would be much appreciated :)
Can anyone just make one of these programs and make a printscreen.
I'm desperate to figure this out and so far i've been unsuccessful.
I need to use a joystick button to engage a relay forward, and reverse, and off....Please help!
ShotgunNinja
18-01-2009, 16:38
Hey all, a bit late, but I have made a simple VI for retrieving a single button's boolean state based on it's enumerated value. It hooks up just like the Get Axis sub-VI, but with an Unsigned Byte (8-bit) input hook for a button enumerator control.
Here's a screenshot:
http://lakeviewlegends.us///2009/01/joystick-get-axis-example.PNG
Here's a copy of the VI:
TotalChaos
18-01-2009, 17:14
Can anyone just make one of these programs and make a printscreen.
I'm desperate to figure this out and so far i've been unsuccessful.
I need to use a joystick button to engage a relay forward, and reverse, and off....Please help!
Ok, I whipped up something as an example. I haven't had a chance to test this code on our base so there's no guarantees, but as far as the general idea goes I think its a good example.
Usually I would just post a screenshot and explain in the post, but since there's cases inside of cases I wouldn't be able to show you everything without a screenshot for every possible combination, so Instead you can just download the code. (I'll attatch it to this post) I have comments in the code that explain everything I did and why. I don't know that this is the best or most efficient way to do what you are trying to do, but it is one solution. If you have and questions about the code feel free to ask! And if you find any errors please let me know!
- Austin
this is what i have so far if anyone can build from this that would be absolutely amazing
TotalChaos
18-01-2009, 19:04
EDIT 2 - I just went back and checked out a previous post which led me to the programming manual. (Which I havent read :p ... I'm more of a learn through experiance person) Anyways, using -1 and 1 may not work. But seeing as I don't have a way to test it I added on more to the bottom explaining how to do it so that it's at least in-line with the manual.
Ok, maybe I jumped ahead and went a little too fast with my last example.
Lets build on what you have and start with something simple. First off, I think it would be a good idea to clean up your code. When I'm testing things out I find it easier to test for one thing at a time to avoid clutter. I took your picture and marked some of the things I think you should take out in red. (The box with the question mark you could keep, I wasn't really sure what you were doing with it so I would just say delete it unless its important to you.) The blue box signifies what I want you to change.
EDIT - And don't forget, for EVERY Open function you need a matching Close function.
http://img179.imageshack.us/img179/853/buttonhelp12ga9.jpg
As a first step we'll set this up to go one way when the button is pressed and another way when then button is released (unpressed).
In the blue box go ahead and get rid of the "boolean to num" function and instead add a case statement. To get that open up your palette and go to: Programming > Structures and select "Case Structure".
In the True case of the case structure and a numerical constant (Function palette > Mathematics > Numeric and select "Numeric Constant") and enter in 1 as its value. Then click one of the little arrows next to where it says "True" on the case structure to switch it to the false case. In the false case add a numerical constant and enter in -1 as its value. Wire up both of the numeric constants to the right wall of the case structure and then wire the new tunnel output to the Set Relay function. Here's what it look like:
(True case shown)
http://img104.imageshack.us/img104/2679/buttonhelp2fk5.gif
(False case shown)
http://img261.imageshack.us/img261/6657/buttonhelp3ip6.gif
Let me know how this works and then we can work from there.
EDIT 2:
In the blue box go ahead and get rid of the "boolean to num" function and instead add a case statement. To get that open up your palette and go to: Programming > Structures and select "Case Structure".
In the True case of the case structure and a enum constant (Function palette > Mathematics > Numeric and select "Enum Constant") and enter in "Forward" as its value. Then click one of the little arrows next to where it says "True" on the case structure to switch it to the false case. In the false case add a enum constant and enter in "Reverse" as its value. Wire up both of the numeric constants to the right wall of the case structure and then wire the new tunnel output to the Set Relay function. Here's what it look like:
(True case shown)
http://img261.imageshack.us/img261/9075/buttonhelp5if7.gif
(False case shown)
http://img504.imageshack.us/img504/881/buttonhelp4kk1.gif
(^^^ There's a max amount of images per post, so I linked these instead)
- Austin
Greg McKaskle
19-01-2009, 08:33
If the case with two constants works for you, then may I suggest looking at the ternary assignment -- a fancy name for the ? : operator in C. It is actually called the Select operator. LV puts it in the Comparison palette, and it is handy for selecting one of two values without the space and hidden constant of the case structure.
Of course this is just for readability, it is equivalent at runtime.
Greg McKaskle
domoarigato
20-01-2009, 17:25
...Yeah.... okay... Trying to program the joysticks' buttons... More specifically, trying to get a spike/relay to be able to be controlled by a button. (Forward/Reverse would be nice for one, Forward/Neutral/Reverse for the other) so I've looked at just about every tutorial/help guide thing that I could find... At the moment, we have two spikes on our electrical board, one of which, when attached to any of the DIO things it will stay a constant red (reverse) which does run a motor, albeit all the time and only in reverse. Code-wise, here's what I have so far (In attachments). [In the inner-most case structure, the false case is set to a constant of 'Reverse' as I believe you have said to do. Also tried 1 and -1, but to no avail.] Any help or advice would be greatly appreciated. Thank you~
IceStorm
28-01-2009, 23:04
Were trying to do something very similar but with out the relay.
We want to have a button that on one press it turns on our traction control code, and when you press the button again it turns off our traction control code and turns on our manual speed control code. we have our two pieces of code in a case structure where true is traction control and false is manual speed control. we then wired this to a joystick button and it works other than you have to continue to hold the button down to get it to stay engaged.
is there an easy way to make the joystick buttons into on/off buttons rather than momentary buttons.
TotalChaos
28-01-2009, 23:18
is there an easy way to make the joystick buttons into on/off buttons rather than momentary buttons.
So it sounds like you're trying to turn it into a button that toggles from on to off (and the other way around) when you press it? If so you can check out the VI posted in THIS THREAD (http://www.chiefdelphi.com/forums/showthread.php?t=73008). (I know you said you don't want to use relays, but it will give a a general direction as far as how to set up the case structures)
- Austin
IceStorm
29-01-2009, 10:08
TotalChaos,
Yup. That is exactly what we are trying to do. we want to take the momentary button and make it a toggle. i opened that vi and it looks like what i need i just need to pull out the extra items for the buttons 2 and 3.
Thanks.
chinckley
17-02-2009, 19:23
I know it's a little late, but here's my crudely done diagram:
http://img72.imageshack.us/img72/276/diagram1go4.jpg
(Sorry, I did it in paint without a mouse :p )
Give me about 15 minutes or so and I'll get a picture of some way to hook a motor to a button. (It might not be the best way, but I do know a way)
- Austin
Thanks Austin. That answers a very large question for us!!!!!!!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.