01-23-2013 01:41 AM
Also, i've been looking for a way to get into a video chat with a Labview developer later in the season once mostly everything is working to collaborate on maybe better ways to do it and to fix some things. Do you have any ideas on how to go about this? I know this forum is here and would most likely answer any question I had, but it's much faster and productive, on both sides, to have a better form of contact like this.
01-23-2013 07:18 AM
01-23-2013 09:30 AM
For starters can you get rid of the toggling you're trying to accomplish, and simply run the motor if the button is held? Or will that cause the rest to break as well? Something like this?
As I mentioned before, you'll likely see some issue with your current toggle code.
01-23-2013 11:02 AM - edited 01-23-2013 11:03 AM
Well I can certainly try it that way just to test it, but the reason I want it as a toggle switch is that we want that to turn on the motor for our shooting mechanism, and then allow a trigger button to be pushed only when that motor is on for a pneumatic to push a frisbee, one at a time, into the launcher. But holding down the motor button can easily lead to mistakes of not applying enough pressure/moving the joystick.
In the attachments is what FRC suggests to do, is it what their example code for a latching joystick is, I added the solenoids and motors, though.
Here's also an image of it:
The main issue I see with this though is the problem I had earlier, which is when everything else was just disabled with this code in, but I put the registry get, close, and anything else except for the joystick inside the outer loop.
I'm not sure exactly how all of that works with loops and why I had that issue earlier, any ideas?
And i'l try out just holding the button tonight maybe, just to see it it will work with some of it.
External download for attachment:
01-23-2013 11:49 AM - edited 01-23-2013 12:04 PM
You do not want to close the motor in this VI (presumably, teleop.vi, yes?) because then you will not be able to use it anymore. I believe there is a specific close or shutdown VI that gets called which is where you'll close all the registry things.
In the VI image you posted, I think your Motor.Set Output should be inside the inner case structure. And, depending on the value from the Not, you should wire your 0 or 1 to turn the motor on and off. Additionally, you would want to put your Joystick.Get inside the loop. As it stands now, you're only reading the joystick value once at the very beginning of execution.
The case structure business can be cleaned up a bit using Select, as in my image below. (This is can further be turned into one of several other constructs so you don't have 10 of these in teleop.vi, though that is somewhat more advanced.)
Those shift registers are on the walls of the while loop of Teleop.vi in my former teams logomotion code. (I obviously changed what I do with the New Latch Value to help you out here though.
Before you do anything with the image I posted try implementing the changes I discussed earlier this post (and if that doesn't work, my previous post).
01-23-2013 05:18 PM
What do you mean inside the inner loop?
If the Set Output for the motor is inside the false loop, how does that allow for it to work? Also, where exactly should the joystick calling go? Inside the first loop or the 1st inner loop or the loop inside the 1st inner loop?
01-23-2013 06:48 PM - edited 01-23-2013 06:49 PM
@Arkacaro wrote:
What do you mean inside the inner loop?
If the Set Output for the motor is inside the false loop, how does that allow for it to work? Also, where exactly should the joystick calling go? Inside the first loop or the 1st inner loop or the loop inside the 1st inner loop?
If you read the comment inside the inner case structure that says "...toggle the latched value", that means the result of the Not operation is your new latch value. Therefore if that value is false your motor should not run. If that value is true you'll want to turn it on. As it is now it is going strictly based on the button value. You're not using any of that logic at all.
Your question about the Joystick is posed improperly, using wrong names. There is one loop. The large outer grey structure is the loop. All the other structures are case structures. The Joystick.Get should go within the while loop but outside the case structures.
EDIT: This is the same person, elset191, but I'm on my coworker's laptop and I was unknowingly logged in.
01-23-2013 07:13 PM
So as how it is the case structure outside of the NOT function case structure doesn't actually trigger because the NOT makes is false when the button is hit instead? Or just the latched Joystick Value?
Should setting the output be outside of those case structures, but using the latched joystick value boolean instead?
01-23-2013 08:21 PM
@Arkacaro wrote:
So as how it is the case structure outside of the NOT function case structure doesn't actually trigger because the NOT makes is false when the button is hit instead? Or just the latched Joystick Value?
Should setting the output be outside of those case structures, but using the latched joystick value boolean instead?
The outer case structure acts on the raw input from the joystick, not on the latched value. This is because the wire from Button 1 is going directly to the case selector (the tunnel with the ?).
I'm going to change my earlier response about put the Set Output inside the inner case after the Not, to put it after the nested structures. Again, choose the value to set based on the value of Latched Joystick Value.
Again, remove the Motor close from the loop.
If you are running this VI independently you should replace your Get Registry (both of them) with an Open. If this VI is stand alone, you will be trying to get "LMotor 1" which has never been opened anywhere. Of course if you're using this as a subVI where you open it somewhere else, it should work fine.
01-23-2013 08:42 PM - edited 01-23-2013 08:43 PM
I have been removing things/adding things as you've said before, just that I don't always update that I exactly did that.
Is this more so what you mean?
The "After the nested structures" I'm assuming is after the case structures, correct?
I set the value based on the value of a Latched Joystick Value, I think.
And this VI is running under Teleop, and the Motor and Joystick have been identified in the Begin vi, so I'm assuming it should work this way?