|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Buttons
I want my arm to go specific positions when I push on some buttons. It seems what I ve done with case structure is complicated. Do I have any other simplier way to solve this button issue? Maybe with just one structure.
Thanks in advance!!! |
|
#2
|
|||||
|
|||||
|
Re: Buttons
Here's a simpler button selection structure.
There is an example for joystick buttons and a second example for custom controls through the Cypress I/O. It just has a case for each button on the joystick. I'd recommend making a control of each value you put inside each case, so you can adjust them all in one place on the front panel instead of digging through the cases. Last edited by Mark McLeod : 04-02-2011 at 11:52. |
|
#3
|
||||
|
||||
|
Re: Buttons
Quote:
|
|
#4
|
|||
|
|||
|
Re: Buttons
Mark can you please tell me basically what your code does? Because just copy-pasting will not help me.
Thanks... |
|
#5
|
|||||
|
|||||
|
Re: Buttons
This code at it's heart, just searches for the first True button, and tells you which one it found, if any.
The 12-possible buttons from the joystick come in as a cluster, so the code first converts that cluster into an array, so it can use one of the built-in array manipulation functions. (Note that the Cypress I/O board inputs already come as an array of values.) So we have an array of true/false values for each of the 12 possible buttons. True if the button is being pushed, False if it is not being pushed. Programming->Array has a simple function called Search 1D array that simply searches an input array for the value you specify. It returns the index into the array where it finds the first value that matches. It returns a -1 if it cannot find that value at all. The buttons in the array start with button 1 in the 0 array position. So we get an index from -1 to 11 if we search the array for the first True value. If we add 1 to that index we get out, our range is now 0-12. 0 now = no button pushed, and 1-12 is the button that is being pushed. In this case we hand it the array of buttons and ask it to tell us the first one that is True. If multiple buttons are being pushed, then it only recognizes the lowest number button and ignores any higher ones that might also be pushed at the same time. Attach a case statement to the output index and you can make cases for each of the buttons you care about. So, for instance, if you are using the trigger (button 1) elsewhere, your case statement can ignore it and only have cases for buttons 3-7. Default and no button would catch the others, or you could have cases for the extras that just do nothing with them. You could even easily write your own code to search the button cluster for true values. P.S. The joystick example shows "Button 1" only so you can see what cluster the other code is manipulating. It isn't necessary or used. Last edited by Mark McLeod : 04-02-2011 at 13:37. |
|
#6
|
|||
|
|||
|
Re: Buttons
Thank you Mark!
|
|
#7
|
|||
|
|||
|
Re: Buttons
As of right now our buttons are set up as momentary. What we want it to do is when we push a button a cylinder goes out and when we push that same button it retracts. From a programming side I guess I'm asking how exactly a person would do this.
|
|
#8
|
|||||
|
|||||
|
Re: Buttons
Quote:
It's about halfway down the page. I think that's what you want. |
|
#9
|
||||
|
||||
|
Re: Buttons
Quote:
Program Files >> National Instruments >> LabVIEW 8.6 >> examples >> FRC >> Driver Station Inputs >> Joystick Button Latching >> Joystick Button Latching.vi |
|
#10
|
|||
|
|||
|
Re: Buttons
How can I do easier for the driver by making it 2 buttons. For example making one increment and the other one decrement. Lets assume that we have 7 positions:
Position1: to take the tube from the ground Position2: 30 inches Pos3: 38 inches Pos4: 67 inches Pos5: 75 inches Pos6: 104 inches Pos7: 112 inches Let button increment be Button 2 on Joystick 2 and Let button decrement be Button 3 on Joystick. What I want is when I push button 2 if the lifting mechanism in Pos (x-1) I want it to heightened to Pos (x). And for the button 3 if the lifting mechanism in Pos (x) I want it to lowened to Pos (x-1). Those position thing is just an example and what I am asking for is how to use one button repetitively ? Thanks in advance!! |
|
#11
|
|||
|
|||
|
Re: Buttons
https://picasaweb.google.com/lh/phot...t=d irectlink
What does this symbol mean and where can I find it? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|