Only when one switch is true and the other switch is true, extend the solenoid and retract back when the third switch turns off. I do not know how to use ONLY the true values of the switches to make it do this in Autonomus. Because if either is false that means it is not safe to kick so dont kick yet. Help needed
Retract the kicker when first autonomous is on.
As it is coming up, the proximity will come on. When proximity comes on, slow down the motor(motor is connected to the safe switch.
When Armed comes on (The switch that says the kicker is all the way to the top) turn the motor(or the safe switch. Same thing) in the negative direction. And when that safe switch comes on Stop the motor as it is all the way out of the way and it is safe to kick
When that is true.. The safe switch is ON and the Armed switch is ON then extend the solenoid. And extend till the Armed switch comes OFF and when it does go off retract back.
Our kicker works perfectly fine. But i just want it to do the kicking in autonomous without the user input (obviously).
This is what i have written in the code so far… I dont know if it is right.
i realized i did something wrong. I also want it to retract when the Armed switch turns off. NOT only when Armed and Safe is false. So i added the solenoid retract to True in both Cases
When Armed switch is false
And
When Armed and Safe are false so here is another snippet included
Would it work to move your (working) teleop code into a subVI that you could call from both autonomous and teleop? Make the inputs to the VI be whatever is normally controlled by your drivers, so your autonomous routine could supply these inputs instead.
I have tried to make the kicker by the state machine way, with the Enums and everything. But it was a lot of case structures. i made it worked with just 3 if statements so that is not my problem.
But what is my problem is that i want it to kick when (2) values of 2 switches is true. I did it by adding another Case structure in autonomus over the two “True” cases and did the solenoid extend and retract.
I am asking if there is a better way > to do this. Like a ( + ) that adds the true values. maybe? i have written the code and posted it, in my attachments above. If you know a way to do this tell me!
It looks like boolean operators would help simplify this. For example, where you have several nested case statements in which some of the cases do nothing, you could just have the appropriate ands, ors, xors, nots, etc. leading to a single case. Do a little exploration of the boolean pallete (functions >> programming >> boolean) with context help. And then maybe try some truth tables with all possible inputs and their desired outputs to figure which ones you need to use.
edit: The link Ether posted below explains all the boolean operators (except implies, but that’s a derived one anyway) available on the boolean pallete. It also has the “truth tables” I was talking about, showing all pairs of inputs and their associated output. Also, check out the “Select” VI (also on the boolean pallete) for picking motor speeds. With some of the boolean tools you might be able to get rid of the case statements all together.
Here’s a LabVIEW example of what they’re talking about.
The first picture ANDs two switches (they both must be TRUE to get the true case), the second ANDs three switches (and reverses one switch for good measure). The second way can be expanded to include as many switches as you like.
If Mark’s post was the answer you were looking for, and you want to learn more, then download this book and read chapter 7, especially the example in section 7.9
For cases like these, where you have several boolean values that are used in evaluating for several situations, I use what I call a boolean state table to represent the desired functionality.
Here’s a screenshot from my old software development guide:
The example this was for had a left and right drive control for inputs 1 and 2, bumper switches on 3 and 4, and an “auto navigation” toggle on input 5.
One way of coding this is to take each row and evaluate it with boolean logic, then bundle the results into a boolean array. With the boolean array you can use the following code: