Solenoid Default Questions

Hello, I am the programmer for team 5496 and am using Java. I have created a base drive code for my DoubleSolenoids and am trying to set a default starting value, that is, I would like to know how to make my DoubleSolenoids start in a certain position (kForward or kReverse) without always being required to return there, such as could be done with an else statement. Here is a sample of my DoubleSolenoid code if it helps:

if (SolenoidO == true) {
mySolenoid.set(DoubleSolenoid.Value.kForward);
}
else
{
if (SolenoidC == true) {
mySolenoid.set(DoubleSolenoid.Value.kReverse);
}
else
{
mySolenoid.set(DoubleSolenoid.Value.kOff);
}
}

The simple and robust way is to use a single solenoid valve with a spring return. It will be in the default position except when you activate it.

If you’re running out of time to get a single solenoid valve (wonder why?) you could put code to set the value of the solenoid to kFwd or kRev in your autonomous init and/or teleop init function. (Doing this in robotInit will not work as the actuators are disabled at that point.) Assuming you don’t want your init function to wait long enough for the switch, you can set a timer to tell the periodic function when to disable it.

Have you considered a mechanical solution to the problem? Have a drive team member actuate the mechanical detents on the solenoids (The little buttons), so they’re in the right state prior to starting. All they need is a pulse in the right direction, they don’t need to be constantly powered. A mechanical button press at the start will ensure they are always in a “default” configuration.