Go to Post What can fix anything?.... DUCT TAPE! - Mr.Twister [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 Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 25-02-2015, 03:16
Ragingenferno's Avatar
Ragingenferno Ragingenferno is offline
That one guy
AKA: Josh
FRC #3053 (Stingers)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2012
Location: NYC
Posts: 39
Ragingenferno is just really niceRagingenferno is just really niceRagingenferno is just really niceRagingenferno is just really niceRagingenferno is just really nice
Change in buttons and axes sub vi's

I programmed in labview last year using the 2013 version and am using the 2014 this year like most people also. I have a question. In the 2013 edition of labview, you declared buttons and axes much differently than you do now. I actually like 2013 version of labview more than the 2014 for this reason.

Can someone explain the difference between the two images I have uploaded and how to pick which axes and buttons to use from it?

File named axes and button is 2014 version and the other file is 2013 version.
Attached Thumbnails
Click image for larger version

Name:	axes.png
Views:	81
Size:	14.2 KB
ID:	18488  Click image for larger version

Name:	buttons.png
Views:	49
Size:	6.9 KB
ID:	18489  Click image for larger version

Name:	2013 version.png
Views:	47
Size:	16.4 KB
ID:	18490  
Reply With Quote
  #2   Spotlight this post!  
Unread 25-02-2015, 07:18
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Change in buttons and axes sub vi's

The joystick VIs were modified so that they support a wider variety of joysticks and in particular they support Xbox controllers better. One result of this was that the number of buttons, axes, and POVs were not really known, and the names given to them were not necessarily that accurate. Sure, they still had a name, but it may be a bit off.

The new Joystick Get function returns an array of each item, and they can be accessed using the index array function. If unwired, the top element defaults to returning element zero and other elements increment the previous index by one. For Example:
If you want to index elements 3, 4, and 5, you simply wire a 3 to the top and the others still increment. If you want 2, and 5, you can wire the numbers to two elements, and you can do so in any order you want.

If you do not want to use index array and prefer to have names, determine the names you want for your axes. Perhaps (run, strafe, rotate). Build a cluster of three numbers with those names. Then cast your array to your cluster. I'd do this in a new subVI that is your own joystick customization VI that you layer on top. Then you can access the elements as before, but with your robot's specific names. Note that this is even more useful for buttons, as they can be named (up and down) instead of Button 1 and Button 2.

Greg McKaskle
Reply With Quote
  #3   Spotlight this post!  
Unread 25-02-2015, 14:43
Ragingenferno's Avatar
Ragingenferno Ragingenferno is offline
That one guy
AKA: Josh
FRC #3053 (Stingers)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2012
Location: NYC
Posts: 39
Ragingenferno is just really niceRagingenferno is just really niceRagingenferno is just really niceRagingenferno is just really niceRagingenferno is just really nice
Re: Change in buttons and axes sub vi's

Quote:
Originally Posted by Greg McKaskle View Post
The joystick VIs were modified so that they support a wider variety of joysticks and in particular they support Xbox controllers better. One result of this was that the number of buttons, axes, and POVs were not really known, and the names given to them were not necessarily that accurate. Sure, they still had a name, but it may be a bit off.

The new Joystick Get function returns an array of each item, and they can be accessed using the index array function. If unwired, the top element defaults to returning element zero and other elements increment the previous index by one. For Example:
If you want to index elements 3, 4, and 5, you simply wire a 3 to the top and the others still increment. If you want 2, and 5, you can wire the numbers to two elements, and you can do so in any order you want.

If you do not want to use index array and prefer to have names, determine the names you want for your axes. Perhaps (run, strafe, rotate). Build a cluster of three numbers with those names. Then cast your array to your cluster. I'd do this in a new subVI that is your own joystick customization VI that you layer on top. Then you can access the elements as before, but with your robot's specific names. Note that this is even more useful for buttons, as they can be named (up and down) instead of Button 1 and Button 2.

Greg McKaskle
I think i understand. Would i be able to copy and paste the button and axes from the third photo(labview 2013) into 2014 and it would work?

Last edited by Ragingenferno : 25-02-2015 at 14:51.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-02-2015, 15:06
Kevin Phan's Avatar
Kevin Phan Kevin Phan is offline
College Student
FRC #0357 (Royal Assault)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2010
Location: PA, United States
Posts: 95
Kevin Phan will become famous soon enoughKevin Phan will become famous soon enough
Re: Change in buttons and axes sub vi's

Not necessarily. Since NI has decided to not cluster the axes and buttons in the get joystick values vi for the current version of LabVIEW, you would not be able to do the unbundle function to get your axes and buttons. Now I understand it's hard for you to differentiate between which button is which and how to figure out which element of the array to which. Use the game controller settings on the joystick or controller you're using to find out which buttons or axes correspond with which. You can access this by going into the devices and printers, which can be found on the windows start menu and right click on the controller. Click game controller settings and navigate to settings and there you should be able to test out what number the axes or button is. If you are having trouble with this check on Microsoft's website to find detailed instructions to access the game controller settings. After finding your numbers, you can correspond this with the element number in the array for instance the x-axis is by default on array element #1 (or 0, I don't recall if LabVIEW's starting index for arrays).
__________________
VEX & FRC Student Team Member #357 Royal Assault 2010-2014 "Dare Mighty Things"
2014-2019 Attending Drexel University Major:Electrical Enginnering
Reply With Quote
  #5   Spotlight this post!  
Unread 25-02-2015, 16:34
Ragingenferno's Avatar
Ragingenferno Ragingenferno is offline
That one guy
AKA: Josh
FRC #3053 (Stingers)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2012
Location: NYC
Posts: 39
Ragingenferno is just really niceRagingenferno is just really niceRagingenferno is just really niceRagingenferno is just really niceRagingenferno is just really nice
Re: Change in buttons and axes sub vi's

Quote:
Originally Posted by Kevin Phan View Post
Not necessarily. Since NI has decided to not cluster the axes and buttons in the get joystick values vi for the current version of LabVIEW, you would not be able to do the unbundle function to get your axes and buttons. Now I understand it's hard for you to differentiate between which button is which and how to figure out which element of the array to which. Use the game controller settings on the joystick or controller you're using to find out which buttons or axes correspond with which. You can access this by going into the devices and printers, which can be found on the windows start menu and right click on the controller. Click game controller settings and navigate to settings and there you should be able to test out what number the axes or button is. If you are having trouble with this check on Microsoft's website to find detailed instructions to access the game controller settings. After finding your numbers, you can correspond this with the element number in the array for instance the x-axis is by default on array element #1 (or 0, I don't recall if LabVIEW's starting index for arrays).
We aren't using a controller from microsoft. We are using one of mad cats 3d joysticks with a 3rd axis on it for rotation. We are using omni drive. I have the axis thing down. I'm just not understanding the buttons. In my opinion, instead of editing last years joystick get vi, they could have added a whole new section like a controller vi. lol. I'm not a big fan of change.
Reply With Quote
  #6   Spotlight this post!  
Unread 25-02-2015, 16:59
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 418
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Change in buttons and axes sub vi's

Quote:
Originally Posted by Ragingenferno View Post
We aren't using a controller from microsoft.
Don't matter. If your DS can see it than your computer can. All joysticks conform to a standard for USB devises called HID (Human Interface Devise). Mice, Keyboards, and joysticks fall under this and anything that can be recognized as an HID joystick devise you can follow Kevin Phan's advise to see the buttons/axis. We used this microprocessor before with custom buttons and even it can be seen as an HID joystick: https://www.pjrc.com/teensy/teensy31.html

The button/axis number you see corresponds to the element number for the array of buttons/axis you get out of the WPIlib joystick VI. Note when you go to program this the first element in an array and subsequently button #1 on the joystick will be the number zero. Things in programming count up starting at zero not one.
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
Reply With Quote
  #7   Spotlight this post!  
Unread 25-02-2015, 18:39
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Change in buttons and axes sub vi's

The joystick VIs had not changed in five years, and it was commonly requested to have better Xbox controller support. You can use the 2013 description if that is what you want.

You will want to copy the cluster that has the buttons and use that as the output from your wrapper subVI. The attached images shows an example. Then use that one instead of the one in the palette.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	From Clipboard.PNG
Views:	30
Size:	70.4 KB
ID:	18492  
Reply With Quote
  #8   Spotlight this post!  
Unread 26-02-2015, 14:22
AlDee AlDee is offline
Registered User
FRC #1099
 
Join Date: Mar 2011
Location: Connecticut
Posts: 31
AlDee is an unknown quantity at this point
Re: Change in buttons and axes sub vi's

Quote:
Originally Posted by jman4747 View Post
Don't matter. If your DS can see it than your computer can. All joysticks conform to a standard for USB devises called HID (Human Interface Devise). Mice, Keyboards, and joysticks fall under this and anything that can be recognized as an HID joystick devise you can follow Kevin Phan's advise to see the buttons/axis. We used this microprocessor before with custom buttons and even it can be seen as an HID joystick: https://www.pjrc.com/teensy/teensy31.html

The button/axis number you see corresponds to the element number for the array of buttons/axis you get out of the WPIlib joystick VI. Note when you go to program this the first element in an array and subsequently button #1 on the joystick will be the number zero. Things in programming count up starting at zero not one.
I'm planning to work on a custom controller using the teensy. Can you tell me, if there is any limit to the number of buttons or axis that the driver station will recognize? Did you have to do any additional programming to get it to work with the DS? Also, I'm curious as to how you mounted it. It doesn't look like there are any screw holes or any place to drill any either.
Reply With Quote
  #9   Spotlight this post!  
Unread 26-02-2015, 15:29
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 418
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Change in buttons and axes sub vi's

Quote:
Originally Posted by AlDee View Post
I'm planning to work on a custom controller using the teensy. Can you tell me, if there is any limit to the number of buttons or axis that the driver station will recognize? Did you have to do any additional programming to get it to work with the DS? Also, I'm curious as to how you mounted it. It doesn't look like there are any screw holes or any place to drill any either.
I don't know about the limit of buttons the DS can read the teensy can do 16 (or 32 total if using the ++2 model) and up to 6 Axis. You do have to do additional programming on the teensy, the robot side is exactly the same. As for mounting you need to solder on header pins such that it looks like this: https://www.pjrc.com/store/teensy31_pins.jpg. Attach that to a bread board and then your wires from the switches to the bread board. Also check this: http://www.chiefdelphi.com/media/papers/2666 though be aware that we used the newer example code below for ours. One word of warning, make sure you strain relive the USB cable going from the teensy to the computer. We broke the micro USB off the teensy once and switching to a xbox controller mid competition isn't fun.

Code:
/* Complete USB Joystick Example
   Teensy becomes a USB joystick with 16 or 32 buttons and 6 axis input

   You must select Joystick from the "Tools > USB Type" menu

   Pushbuttons should be connected between the digital pins and ground.
   Potentiometers should be connected to analog inputs 0 to 5.

   This example code is in the public domain.
*/

// Configure the number of buttons.  Be careful not
// to use a pin for both a digital button and analog
// axis.  The pullup resistor will interfere with
// the analog voltage.
const int numButtons = 16;  // 16 for Teensy, 32 for Teensy++

void setup() {
  // you can print to the serial monitor while the joystick is active!
  Serial.begin(9600);
  // configure the joystick to manual send mode.  This gives precise
  // control over when the computer receives updates, but it does
  // require you to manually call Joystick.send_now().
  Joystick.useManualSend(true);
  for (int i=0; i<numButtons; i++) {
    pinMode(i, INPUT_PULLUP);
  }
  Serial.println("Begin Complete Joystick Test");
}

byte allButtons[numButtons];
byte prevButtons[numButtons];
int angle=0;

void loop() {
  // read 6 analog inputs and use them for the joystick axis
  Joystick.X(analogRead(0));
  Joystick.Y(analogRead(1));
  Joystick.Z(analogRead(2));
  Joystick.Zrotate(analogRead(3));
  Joystick.sliderLeft(analogRead(4));
  Joystick.sliderRight(analogRead(5));
  
  // read digital pins and use them for the buttons
  for (int i=0; i<numButtons; i++) {
    if (digitalRead(i)) {
      // when a pin reads high, the button is not pressed
      // the pullup resistor creates the "on" signal
      allButtons[i] = 0;
    } else {
      // when a pin reads low, the button is connecting to ground.
      allButtons[i] = 1;
    }
    Joystick.button(i + 1, allButtons[i]);
  }

  // make the hat switch automatically move in a circle
  angle = angle + 1;
  if (angle >= 360) angle = 0;
  Joystick.hat(angle);
  
  // Because setup configured the Joystick manual send,
  // the computer does not see any of the changes yet.
  // This send_now() transmits everything all at once.
  Joystick.send_now();
  
  // check to see if any button changed since last time
  boolean anyChange = false;
  for (int i=0; i<numButtons; i++) {
    if (allButtons[i] != prevButtons[i]) anyChange = true;
    prevButtons[i] = allButtons[i];
  }
  
  // if any button changed, print them to the serial monitor
  if (anyChange) {
    Serial.print("Buttons: ");
    for (int i=0; i<numButtons; i++) {
      Serial.print(allButtons[i], DEC);
    }
    Serial.println();
  }
  
  // a brief delay, so this runs "only" 200 times per second
  delay(5);
}
Attached Thumbnails
Click image for larger version

Name:	teensy stuff for CD.png
Views:	11
Size:	54.2 KB
ID:	18495  
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
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 10:29.

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