So we need a motor to function for an elevator. I have little experience with programming in Labview.
Here’s an example that uses the x axis of a joystick to run a single motor.
Start with the FRC examples that were installed with LabVIEW. You can find the link to them on the Support tab of the Getting Started window. Use the Tutorials to learn how to incorporate the example code into your robot project.
I am using the “button control of motor example”. What is that tan box that comes out of the Joystick Get Values box and how do I get it?
Thanks.
That is an index array. You can get that from the array palette. Both the axis and button outputs are arrays. The array that is linked to those outputs will output the axises/buttons of the joystick in chronological order. It’s a neat way to visualize the functions of the joystick.
If you hover the mouse over anything in LabVIEW, the contextual help window will tell you a lot about it. If your help window is not showing up, press control-H to enable it.
I think you’re talking about the Index Array function. You will find it in the Arrays subpalette, in the top row of the function palette that appears when you right-click on a blank spot in a vi’s block diagram. Its inputs are an array of values (such as the boolean array that comes out of the Buttons terminal) and one or more integers. The output(s) give(s) you the value(s) in the specified location(s) of the array.
I put that in the Teleop.vi. Now i’m confused, how does it know what button and PWM slot the motor is plugged into. We are also using a Logitech controller and would like L2 to make the motor spin one way and R2 the other way.
The right half of Team358’s Single Motor Example, the part labeled “Teleop.vi”, goes in the Teleop vi. The left half, labeled “Begin.vi”, goes in the Begin vi. The other examples assume the same Begin.vi code.
The enumerated constant wired to the input of the Motor Open function defines which PWM channel is being controlled. The index numbers wired to the Index Array pull the associated button values from the array. I think the L2 button on a Logitech gamepad is number 6, and R2 is button number 7, but you can find out for yourself by setting a probe on the Buttons array coming out of the Joystick Get Values.
Where do we find the probe?
Right-click a wire. One of the commands in the pop-up menu is “Probe”. That will add a line to the Probe Watch Window which will show you the current value on the wire when the code is running.
You need to “Run” the Robot Main vi using the white Run arrow at the left end of the toolbar (as opposed to “Build” and “Run as startup”) in order for the interactive debugging to be available.
How do you change the max speed of the motor?
In the Button Control of Motor Example, the numbers with orange outlines are the values that get sent to the motor. You can change the “1” to whatever value you want to set when the “forward” button is pressed, and the “-1” to the “backward” value. (You can even change the “0” for the motor to run at some speed when neither button is pressed, but that’s probably not what you want.)
Thank you so much for all the help. We got it all programmed and working. Team 4791 Thanks you.