LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling a motor through joystick buttons teleop labview

I am attempting to get a motor to be controlled by a push of a button on the joystick during Teleop. I am using LabVIEW programming language, and using the basic controllers supplied by FIRST. My intent is to have one button move the motor forward whenever it is pressed and continue to do so until the button is released. Another button functions the same way with the same motor, but in the opposite direction. I tried to do it by myself then attempted to use examples on this site. None have worked. The current version I have shows no errors, but will not run the motor.

The code is included.

Joy1 uses USB1 and the motors use PWM 8 (as shown) and 7 (for the referenced one). The axis controlled motor runs, but the button controlled one won't. All electrical and mechanical components are correct.

Please Help!!!!!

0 Kudos
Message 1 of 5
(6,141 Views)

Hi there,

 

We made some YouTube videos last year that might help you out a little. 

 

In Step 2, we show how to add a Joystick button to your teleop code.  This is done using last year's code.  But the process is the same this year.

 

http://www.youtube.com/watch?v=3LLpwHy9axk

 

There are 7 short videos in this series.  Some of the other ones might be helpful to you as well.

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 2 of 5
(6,119 Views)

Better to post FRC-related questions in the FRC forum.

 

The motor control VIs expect a value ranging from -32768 to +32767 - the range of a joystick axis, if I'm remembering correctly (I'm not in front of a computer with the FRC toolkit right now).  You can't just tell a motor to turn on; you need to tell it how fast to run.  You do have the right idea with your code - it will run the axis one way while one button is pressed, and the other direction when the other is pressed.  Think about this: What's the range of possible output values from the Boolean to (0,1) function?  What speed will your motor run when you push the button, with your code as it stands now?  What speed do you need to run it at?

0 Kudos
Message 3 of 5
(6,111 Views)

Hello, Aggies2923!

 

nathand is correct, you will receive the best support by posting to the FRC forum, if you have not already done so. During build season, we also offer phone support from 1-7pm central time at (866)-511-6285.

Will Hilzinger | Switch Product Support Engineer | National Instruments
0 Kudos
Message 4 of 5
(6,104 Views)

Sorry for the misinformation about the motor speeds; having access at the moment to an FRC system, the range is in fact -1 to +1.

0 Kudos
Message 5 of 5
(6,098 Views)