02-11-2015 01:06 PM
First time programers trying to get our joysticks to make a motor go forward and backwards as well as turn a solenoid on and off. We have it programmed like the picture below with the joysticks working fine going to our tank drive. We havent been able to get our trigger and button 2 to work on our joystick to anything else. Any ideas what could be our issue?
Thanks for any help!
Team 3292
02-11-2015 03:02 PM
Hey Team 3292,
Thanks for posting your code, it helped in troubleshooting. From the code you posted, it looks like you are trying to get the motor connected to PWM 5 to move in one direction when button 0 on LeftStick is pressed and to move in the other direction when button 1 on RightStick is pressed.
You will need this code in the "Begin" VI. This code sets up both joysticks and the motor. I used PWM 8, but you would use PWM 5.
Next, you will need the following code in the "Teleop" VI. This code is commented, and what it does is reads the values from each joystick, indexes the 0th button or button 0, and uses some logic to move the motor.
If we look at the logic more closely, we see that when either both buttons are pressed or both buttons are released, the motor does not move at all. When only one button is pressed, we check if it's the left one. If it is, we move the motor backward. If it is not, we know that it's the right one because we know that at least one button is pressed. We then take this output and wire it to the PWM input of the motor set output vi.
Finally, to close everything properly, use the following code in the "Finish" VI. This will close everything out well.
This can be a little confusing so let us know what questions you have.
Robots Rule!
-Jim
02-11-2015 05:03 PM
So we added in the codes that was suggested said to add in, and we still don't have any joystick buttons working.
02-11-2015 07:30 PM
Hey guys, can you attach the teleop VI or another picure of your code like in the first post. All the project is is a list of VIs, but does not include any of the code.
Thanks,
-Jim
02-12-2015 07:41 AM
Here are some pictures of our code again. A quick overview of what we did. We put the begin code in the begin vi, the teleop code in the teleop vi, and the finish code in the finish code vi but that is under team code. We also attached our scheduling loop because that is where we were told to put our tank drive after we were having issues. When we put our tank drive code in the teleop we were getting 1 second intervals spurts of it working. Basically on and off. When we put it on the scheduling loop it worked fine.
Thank you guys for all the help so far!
Tom
Team 3292
02-12-2015 01:31 PM
Hey Tom,
Since we implemented the motor control in the Teleop.vi, remove any subVI that has "MOTOR" at the top and is that orangish color in the Scheduling loop.
Also, we're opening the joysticks twice: once in the Begin.vi and once in the Scheduling Loop. I would get rid of the "Joystick Open.vi"s outside the loop and keep the ones in Begin.vi. then, you could call the joysticks by reference just like you currently do in the Teleop.vi.
Finally, if you follow the model we've set up by opening references in the Begin.vi, using those references in the Teleop.vi, and closing everything in the Finish.vi, there shouldn't be a problem moving the drive control to Teleop.vi.
02-12-2015 03:00 PM
I just want to make sure I understand what I need to do. On the scheduling
loop I can delete our Tank Drive System and then move that all over to the
Teleop VI.
I then should delete the open Joystick in the scheduling loop and then when
I right click, create constant, on the get joysticks should I reference
them as USB 0 and USB 1?
Then I don't mean to question to you, but if I delete my motors out of my
scheduling loop, how will the motors know when the joysticks tells them to
move.
02-12-2015 06:20 PM
Robot Main VI