FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting joystick buttons to motors

We are attempting to use the joystick trigger to start two motors when pressed (and stop them when not pressed).  We do not want to use the axis.  (I think)

We are using the get joystick vi.

From the get joystick vi we created a control and have unbundled with name to access the buttons.

We wired button 1 to a case structure.  True contains a set motor vi  for each of our two motors.  (We opened communication with the motors in basic robot main.  One we wired and one we did not.)

When running the project, the front panel indicates the trigger pull, but we get no response from the motors.  (We have tested the motors with other projects so we know the problem is not there.)

When running in highlight execution, even though the indicator shows the trigger is pulled, the result is false.  We would really like to have a true.

Any suggestions?

0 Kudos
Message 1 of 28
(20,482 Views)

This would be easier to help you if you posted your VI.

0 Kudos
Message 2 of 28
(4,273 Views)

Good idea.  🙂    Here they are.

Download All
0 Kudos
Message 3 of 28
(4,273 Views)

Dear DebK,

See the attached VI for one possible solution. It's very "rough and ready", but it works. Just replace the Basic Robot Main in the Basic cRIO Robot Project with the VI below to test it out.

Let me know if you have any additional questions!

~Nate

NI FIRST Support

0 Kudos
Message 4 of 28
(4,273 Views)

Your problem is pretty simple - you just need to remove the cluster constant (on the block diagram), and instead connect the wire that actually has the data you want on it.  Connect the same wire that goes to the Button indicator to the Unbundle node.  You'll probably find it helpful to use "Unbundle By Name" in place of "Unbundle."

What you have now is an indicator that shows you the button states, and a separate (and unrelated) constant cluster of all false values.  You're using that cluster of false values, rather than the values you actually read from the joystick, to control the case structure.

0 Kudos
Message 5 of 28
(4,273 Views)

Thanks all.  We are up and running... unbundle by name did the trick.

0 Kudos
Message 6 of 28
(4,273 Views)

For all those who are interested there is now an example program on working with buttons:

Joystick Button Control (Using a Functional Global Variable)


Best Regards,

~Nate

NI FIRST Support

0 Kudos
Message 7 of 28
(4,273 Views)

Hi! Did you install any additional libraries to work with the joystick? When I try to load your VI, I see some interrogation signs instead of the functions. I'm very new to all these labVIEW stuff.

0 Kudos
Message 8 of 28
(4,273 Views)

Hi Juanita,

Do you mean that his VI contains functions that are white squares with black question marks?

This is because the VI's back in 2009 were located in D:\Program Files\National Instruments\LabVIEW 2009\vi.lib\Robotics Library\WPI\  If you hover over one of the functions with the question mark, and toggle on Context Help (hit Ctrl+H), you'll see that it is trying to find the VI within the location above.

The new VI's are located in D:\Program Files\National Instruments\LabVIEW 2014\vi.lib\Rock Robotics\WPI\  Do you have such a directory?  (It might be on your C: drive rather than D:)

I would recommend starting by checking out "Tutorial 4 - Developing a Robot Project" and "Tutorial 5 - Editing Team Code VIs".  These are available from the Tutorials tab when you open LabVIEW for FRC 2015.

All the best,

Ryan

Ryan C.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 28
(4,273 Views)

Hi Ryan

In the FRC 2015 robot project if you look in the teleop.vi  joystic section, in 2015 project they use the WPI_Joystick_GetValue.vi while in the FRC 2014 they use WPI_Joystick_Get.vi. in FRC 2015 they use Index Array while in FRC 2014 they use Unbundle by name to connect Axis or Buttons to Robot drive.

My question is how to connect joystick buttons using the index Array in the 2015 robot project, is it by just numbering the indexes with a constant values  (index0..index9) to reflect joystick button numbers ? and use the corresponding output on the subarray to connect to the Robot drive )?

thanks

macro009

0 Kudos
Message 10 of 28
(4,273 Views)