Button Programming: Is this right?

Hello. I’m learning LabVIEW, and I need to make a “simple” 3-button programming for controlling 2 motors attached to a lever. I have an image of what I’ve come up so far, and I would appreciate any feedback that I get. Also, I have a few questions:

1.) How do I set a specific PWM value for the motors I’m trying to control? Do I use the Motors_SetSpeed key or the Motor_Open key for controlling this?

2.) How do I tell a motor to stop?

Again, any and all input is appreciated.





It seems you’re opening multiple references for each set or get. All you need to do is open one reference for each physical device and wire it to as many get/set vi’s as you want. Also, you’re opening the motors within the while loop, which will slow the loop a lot. Move the Open Motor vi’s to the left of the while loop and wire them to the get/set vi’s in the while loop.

Motors take -1 to 1 for values, with 0 being don’t move. I think if you fix the multiple references and opening motors in the loop, it will work.

Ewww… :eek: Thats just nasty…

Assuming you started with the Advanced Framework, you can just draw from the main RobotData cluster for your joystick and motor references, then use those whenever you need them – I don’t really know anything about the Basic one, only that it is much less organized and would be harder to do complicated things to.

I have included my team’s teleop.vi, which has the robotData cluster heavily modified to suit our needs and delivers out control to other SubVis.

Note the cleanness, but LabView takes a lot of getting used to how control and data flow, as does programming in general. However you really must notice how much of your code was repeat, that is never good.





Could you be a little more specific as to what you are trying to do?

Basically, I want to have the first button tell the motor to go forward, the 2nd button to tell it to go in reverse, and the third button to tell the motor to stop…But now, I want to make the first and second buttons triggers so that only when you hold them down does the motor follow the command…otherwise, it doesn’t move…

The attached picture is the basic idea of what we did to run a motor using two switches, with one switch signals Forward, the other signals reverse. All you then need to do is set the different speeds for the different cases. Use the joystick buttons instead of the boolean button. Then Wire the Pink wires from the Open_motor.vi to the Set_Speed.vi.

Let me know if it was helpful.

We are using are using a three way toggle switch with the driver station user I/O, and a similar program to do about the same thing, (run a motor Forward, Reverse and Neutral). We have been successful.





Haha your code is a little messy… but basically, to clean that up, you should call all your “Motor: Open Jaguar” and such outside of the big case structure thing. (Ie. to the far left near the Joystick Opens). You can also close the motors easier outside of that case structure to help clean it up. (Also should get rid of those white/pink blocks that mean that the motors aren’t being called in ever case of the structure.)

Attached is our main code… which isn’t all that clean either but it works well enough. Basically what we have that is similar to your situation is when it’s calling a motor outside the main case thing (the one with PWM 4) whichis then wired to a “Motor: Set Speed” inside a case structure that is wired to a button. In the true case (when the button is pressed) of the case structure, it will go full power (255) and the opposite in the false case (0). The motor is then closed outside that bigger case structure.

If that doesn’t help, let me know.





OK, so looking at your suggestions and with some outside help, I decided to try this. (Pics at the bottom) However, I don’t understand why only Butoon 2 activates and stay’s activated until the robot is shut off. All of your help and suggestions would be greatly appreciated…Thanks!









The first image shows that when both buttons are false, the motors are set to 0. If you delete the motor effects there, releasing a button will not change a motor – assuming that is what you want.

Well, I would like to create a switch so that the motors DO deactivate when the buttons for the specific direction are released, and I tried using the case structure shown, but like I said before, Only button 2 activates the motors and keeps them activated until the robot is shut off, which is NOT the behavior that I want…

I’m still not sure I understand what you want, but the reason buttons 1 and 2 behave differently is because you are wiring different motor refs to them. In the three images you attached, two of them take the motor refs wired into the top of the struct, one of them takes the motor refs wired into the left. I can’t see the rest of the diagram, but I suspect those are different motors.

Make all three of them affect the same pair of motors.

Greg McKaskle

I have included my team’s teleop.vi, which has the robotData cluster heavily modified to suit our needs and delivers out control to other SubVis.

What is that Acc. Arcade, and the Acceleration Cap devref?

Thanks to everyone for their help! We fixed the trigger and now our arm works like it should. However, I still can’t get the motors to go in reverse…Am I supposed to do that from the default drive programming they gave us?