Joystick Buttons?

I need help programming the KOP joystick buttons in LabView using the Basic Framework. We are trying to turn a motor clockwise when Joystick button 4 is pressed then invert the motor when Joystick button 5 is pressed. With our current code we can get button 5 to spin a motor, BUT nothing happens when button 4 is pressed.

We have tried a number of different fixes. It seem that this multiple button issue always occurs when we try to program more than one button to activate the same motor. I’ve attached a picture of our recent failure. Can anyone help!

You’ve opened a motor twice. Try sending a wire branch to the second case stament instead of opening PWM 5 twice.

Also nestle the case statements - so put the button 5 case statment within the false of the button 4 statement or vise versa. Make sense?

Would nesting make the motor spin when NO buttons are pressed? We don’t want the motors to spin unless a button is pressed.

Opening the motors twice was a failed fix. We have changed that back.

you can’t open a motor twice. It will have a race condition and they will fight each other. We had that with tank drive, so if that isn’t your problem, then look else where.
Also, try making a sub vi for the opening of motors, then a sub vi for logic depending on the values, then make a close sub vi.

If we take the SetSpeed=0 out of the false conditions we can get both buttons to work. HOWEVER, now it doesn’t stop…!

Does that help anyone?

make both of the joysticks come in on a Or statement. (the image is my code)

ex.JPG


ex.JPG

your set speed to 0 would be in the false statement of the interior case statement.
This would make the motor stop when no buttons are pressed but if one or the other is, it will send that value.
-so I will walk you through it (I don’t have Labview on this computer)

Open Motor
get button 5
___Case statement
_____true
________set speed to Right Crab speed inverse
_____false
________get button 4
________Case Statement
__________true
_____________set speed to Right Crab speed
__________false
_____________set speed to 0

I think we got it!!! Wow, thanks everyone. I think we might be ready to ship.