How do i add two "True" values

What i want to do is this.

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 :slight_smile:

1514
Whcirobotics

So to clarify…Kick when:

  • switch 1 = true

  • switch 2 = true

  • switch 3 = false
    Retract when:

  • switch 3 = true
    Leave as is (kicking/retracting) for:

*]All other cases

What i mean to say is this:
the three switches are this:

Proximity switch : switch 1
Safe Switch : switch 2
Armed Switch : switch 3

What i want to do in autonomous is this:

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.

Pictures attached in word file.

autonomus pictures.doc (242 KB)


autonomus pictures.doc (242 KB)

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

autonomus pictures.doc (314 KB)


autonomus pictures.doc (314 KB)

You must have one heck of a kicker mechanism :slight_smile:

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.

It also sounds like your kicker code could benefit from a state machine: http://frcmastery.com/try-me/state-machines/

–Ryan

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! :slight_smile:

1514
Whcirobotics

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.

The output of an AND gate is true if and only if both inputs are true. Is that what you are asking ?

**

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.

AND.jpg
AND2.jpg


AND.jpg
AND2.jpg

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

**

I have changed my code to what Mark suggested. I will try the code at school on Monday after school. If it does not work i will get back to you guys. :slight_smile:

1514
Whcirobotics

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: