Go to Post Surely any group of rational human beings (which FIRST seems to attract) can work this out. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2011, 11:48
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 04-02-2011 at 11:52.
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2011, 12:23
bladetech932's Avatar
bladetech932 bladetech932 is offline
Programmer of awesome
AKA: Jon
FRC #0932 (Circuit Chargers)
Team Role: College Student
 
Join Date: May 2009
Rookie Year: 2009
Location: Tulsa
Posts: 242
bladetech932 is on a distinguished road
Re: Buttons

Quote:
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.
Good Idea just make sure to set the control value as the default (right click set as default) before you run the code without the computer or it will use the original value
__________________
Expect the best, Prepare for the worst
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2011, 12:55
cilginbilgin cilginbilgin is offline
Registered User
FRC #2905
 
Join Date: Jan 2010
Location: Istanbul,Turkey
Posts: 188
cilginbilgin is a jewel in the roughcilginbilgin is a jewel in the roughcilginbilgin is a jewel in the roughcilginbilgin is a jewel in the rough
Re: Buttons

Mark can you please tell me basically what your code does? Because just copy-pasting will not help me.


Thanks...
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2011, 13:18
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 04-02-2011 at 13:37.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-02-2011, 13:31
cilginbilgin cilginbilgin is offline
Registered User
FRC #2905
 
Join Date: Jan 2010
Location: Istanbul,Turkey
Posts: 188
cilginbilgin is a jewel in the roughcilginbilgin is a jewel in the roughcilginbilgin is a jewel in the roughcilginbilgin is a jewel in the rough
Re: Buttons

Thank you Mark!
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2011, 10:43
Durham86 Durham86 is offline
Registered User
FRC #2883
 
Join Date: Dec 2009
Location: warroad,MN
Posts: 8
Durham86 is an unknown quantity at this point
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2011, 10:49
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Buttons

Quote:
Originally Posted by Durham86 View Post
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.
LabVIEW Examples look for the one named Button Toggle Action.
It's about halfway down the page.
I think that's what you want.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2011, 11:21
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,280
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Buttons

Quote:
Originally Posted by Mark McLeod View Post
LabVIEW Examples look for the one named Button Toggle Action.
It's about halfway down the page.
I think that's what you want.
There is also a VI for this provided in the examples NI wrote. Check out

Program Files >> National Instruments >> LabVIEW 8.6 >> examples >> FRC >> Driver Station Inputs >> Joystick Button Latching >> Joystick Button Latching.vi
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2011, 16:55
cilginbilgin cilginbilgin is offline
Registered User
FRC #2905
 
Join Date: Jan 2010
Location: Istanbul,Turkey
Posts: 188
cilginbilgin is a jewel in the roughcilginbilgin is a jewel in the roughcilginbilgin is a jewel in the roughcilginbilgin is a jewel in the rough
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!!
Reply With Quote
  #10   Spotlight this post!  
Unread 07-02-2011, 19:00
Durham86 Durham86 is offline
Registered User
FRC #2883
 
Join Date: Dec 2009
Location: warroad,MN
Posts: 8
Durham86 is an unknown quantity at this point
Re: Buttons

https://picasaweb.google.com/lh/phot...t=d irectlink

What does this symbol mean and where can I find it?
Reply With Quote
  #11   Spotlight this post!  
Unread 07-02-2011, 19:53
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Buttons

Quote:
Originally Posted by Durham86 View Post
[What does this symbol mean and where can I find it?
That is a Feedback Node.
You'll find it on the Programming->Structures palette
The icon on the palette is just the arrow, but the whole thing shows up when you paste it onto the block diagram.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #12   Spotlight this post!  
Unread 08-02-2011, 16:36
Durham86 Durham86 is offline
Registered User
FRC #2883
 
Join Date: Dec 2009
Location: warroad,MN
Posts: 8
Durham86 is an unknown quantity at this point
Re: Buttons

So now if I wanted to use that button toggle action example on a solenoid how would I set that up? or if you know an example.vi that would be great.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:14.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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