We are trying to program two motors in labview to run by pressing buttons on the joystick.
can anyone help us out?
We are trying to program two motors in labview to run by pressing buttons on the joystick.
can anyone help us out?
Please describe in detail exactly what you want to do. The more information you give about your goal, the more helpful will be the answers you receive.
What kind of motors? Which way do you want them to turn? Are the motors completely separate, or does the action of one depend on the action of the other? Will you be wiring the motors to a Spike, a Victor, or a Jaguar? Which joystick buttons do you want to use? Do you want them to run only while the buttons are pressed and stop when the buttons are released, or will you have a “start” button and a “stop” button? As you can see, there are a lot of things that will make a difference. Pin them down for us and we can give you plenty of useful advice.
Well, we can use any buttons, but we think it simple enough to go with buttons numbered one and two.
The goal of this is to have two motors, which are attached to wheels (for a total of two separate motors and two separate wheels), spin and launch a soccer ball, similar to those tennis ball launchers.
We want the buttons set up so that the motors activate when button #1 is pressed, and then continue running until button two is pressed.
The motors (CIM motors) are directly attached to the wheels (no chain or anything) and need to spin in opposite directions.
We will be wiring them to jaguars.
What happens if button 2 is pressed before button 1? What happens when button 1 is released? What happens when button 2 is released? What happens when button 1 and button 2 are pressed at the same time?
Well, pressing number 2 only stops the motor. if it isn’t started already, then nothing happens. nothing is initiated from the releasing of button 1. its just the pressing that activates the motor. same thing with button number two, except with stopping it. when they are pressed at the same time, well i hadn’t figured that in so i don’t know.
It sound like a simple “State Machine” will do the trick.
Default it so that a “0” value is sent to both Victors. Then when button 1 is pressed, a 1 is sent to one victor and a -1 is sent to the other. Have this second state look for button 2 to be pressed. If 2 is not pressed, it stays in this state. Once button 2 is pressed, it switches state back to the first, default, state.
The last bit of logic you might want to apply is to prevent the pressing of both buttons 1 and 2 at the same time from causing a problem. To do this, place an AND gate in line with button 1, then put an inverter between button 2 and the second input on the AND gate. The output of the AND gate will go into the state machine as the button 1 input.
well we aprieciate all the help, but we need to know what labview will look like to make this work.
Do you know how to read the state of a joystick button?
Do you know how to set the speed of a motor connected to a Jaguar?
Do you know what a Case block is in LabVIEW?
What program will you be starting with? Will this program need to do anything besides controlling the two motors?
Along the lines of what Alan suggested… it is much more valuable for you to learn the process than it is for us to give you the answers. Don’t get me wrong, I will help in any way I can, but for now I would prefer to point you to sources where you can learn the processes.
Let’s start off with my favorite site for learning LabView from an FRC perspective. There are a couple different links into the site that work, but this is my favorite. This is on the LVMastery web site.
I’ll bet by the time you run through the first 14 lessons, you will be able to answer your own question. Do your self a big favor and don’t stop after #14, finish them all. It will be well worth your time.
Assuming the answers to the first three questions I posed a couple of posts ago are all “yes”:
Open the joystick and both motors in the Begin vi, giving them useful names with RefNum Set functions. Close them all in the Finish vi.
Put two Case blocks in the Teleop vi.
Wire the “Buttons” output of a Joystick Get to an Unbundle By Name and choose the two buttons you want to use.
Wire the state of the first joystick button to the selector terminal of the first Case block. Inside the “True” case, set both motors to run at the desired speed. Leave the “False” case empty.
Wire the state of the second joystick button to the selector terminal of the second Case block. Inside the “True” case, set both motors to stop. Leave the “False” case empty.
This will do exactly what you asked for, including the part about not being sure what happens when both buttons are pressed simultaneously.
Thank you so much this helped tremendously.
That is exactly why we are here. Please feel free to ask if you need any additional help.