View Full Version : HELP: 2 Motors 1 Button in LabVIEW
Hi
We are trying to program 2 motors to run in only one direction when a single button is pushed. We have tried a couple of different things with the code but nothing seems to be working. We get no response from either motor.
I have attached pictures of the code we tried. When using buttons 2,3,4, & 5 to run the motors in forward and reverse separately, everything works fine. Any help would be greatly appreciated.
16305
16306
We used the method outlined by Team 358 here:
http://team358.org/files/programming/ControlSystem2009-/LabVIEW/ButtonMotor.png
notmattlythgoe
18-02-2014, 09:38
The issue is, you have multiple values going into those motors at one time. If button 4 is not pressed and the trigger is pressed you are feeding both a value of 0 and a value of -1 into x motor at the same instant. You'll need to set the code up so you only have one set for each motor being used at any given time.
Invictus3593
18-02-2014, 09:41
In both pictures, you are trying to set each motor to two different values at the same time (having two MotorSet vi's for each motor). This causes the cRio to have to choose between the two values you're sending but it gets indecisive and doesn't cooperate. Condense your code down to only using one MotorSet for both of them and it should work.
Tom Line
18-02-2014, 09:56
It is good LabVIEW programming practice to absolutely never use more than 1 motor set for a given motor that can execute concurrently. It creates race conditions where you have no idea which one is being set.
As the others have said - get rid of your multiple sets and use one for each motor.
Thanks for the replies! That makes perfect sense.
Would it work if we wired button 1 to the green wires for buttons 2 and 4? Essentially having 2 buttons going into a single T/F operator.
I don't have the code in front of me or I would just try it.
Alan Anderson
18-02-2014, 10:24
Delete the second pair of Motor Set functions. Use boolean OR functions on the button values to make multiple buttons able to activate the motor. I'm sorry, I don't have LabVIEW handy in order to show you an example.
notmattlythgoe
18-02-2014, 10:25
Thanks for the replies! That makes perfect sense.
Would it work if we wired button 1 to the green wires for buttons 2 and 4? Essentially having 2 buttons going into a single T/F operator.
I don't have the code in front of me or I would just try it.
I like Alan's solution.
Mark McLeod
18-02-2014, 10:29
Just move that bottom Select up and add it as a third Select to each of the previous cascades for the x & y motors.
You can add as many Selects as you have buttons.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.