Do you need to set a double solenoid to off after bringing it in?

If you are using a double solenoid and retract it should you after that set the solenoid to be off?

You can, but it’s not necessary, since most solenoids are fine with 100% duty cycle for the duration of a match at least. If you do set it to off, you need to wait on the order of 200 ms to do so, to allow time for the solenoid to actuate.

2 Likes

For Command Based Programming, the best way to do this is generally to use the Command built-in timeout methods setTimeout() and isTimedOut().

example:

/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package frc.robot.commands;

import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.command.Command;
import frc.robot.Robot;

public class ActuateSolenoid extends Command {
  public ActuateSolenoid() {
    // Use requires() here to declare subsystem dependencies
    // eg. requires(chassis);
    requires(Robot.solenoidSubsystem);
  }

  // Called just before this Command runs the first time
  @Override
  protected void initialize() {
    setTimeout(0.3); // Seconds
    Robot.solenoidSubsystem.setSolenoid(DoubleSolenoid.Value.kForward);
  }

  // Called repeatedly when this Command is scheduled to run
  @Override
  protected void execute() {
  }

  // Make this return true when this Command no longer needs to run execute()
  @Override
  protected boolean isFinished() {
    return isTimedOut();
  }

  // Called once after isFinished returns true
  @Override
  protected void end() {
    Robot.solenoidSubsystem.setSolenoid(DoubleSolenoid.Value.kOff);
  }

  // Called when another command which requires one or more of the same
  // subsystems is scheduled to run
  @Override
  protected void interrupted() {
    end();
  }
}

It’s not clear what you’re really asking here, so I’m going to back up a bit.

Unless you’re moving a cylinder back and forth several times a second, both of the solenoids should be off (no voltage applied) most of the time, and in any case you should never energize both at the same time. Each time you want the cylinder to move back or forth, you should strobe/pulse that side’s solenoid with a short burst (@Peter_Johnson suggests 200ms, which sounds OK) then switch to both sides being off. In this case, the solenoid valve (and therefore cylinder) will remain in the state you put it in when no current is applied. If you want the cylinder to return to the “original” state, you need to strobe the opposite side’s solenoid with a short burst.

As @Peter_Johnson also notes, most solenoid valves are fine being energized for the duration of a match, but I still recommend against leaving a solenoid valve energized needlessly because you will likely have the robot enabled for longer periods of time than a match, for purposes such as calibration and practice and demos and maybe even parades.

Given the enhanced composition (command grouping) capability of the 2020 WPIlib command-based programming, it makes sense to make each double solenoid a subsystem and have two commands to switch the solenoid as @ExploitSage shows above; this way if you hit the extend and retract buttons in close succession, only one side will be energized at a time because the later command will interrupt the earlier. Personally, I’d likely call those commands something like “extendThisCylinder()” and “retractThisCylinder()”, or “extendThisArm()” “retractThisArm()”, replacing “This” in each case with something more meaningful in your context.

I’ve been running double solenoids at 100% duty cycle for years and never had a problem with it. Even if the robot is enabled for hours at a time during driving practice, it’s never been the limiting factor by far in my experience. Is it the best practice? No. Is it good enough for FRC? In my experience, yes.

1 Like

No harm, very likely some good, in learning best practice before you need to use it.

3 Likes

I would write a function that has one solenoid on or the other, but not both at the same time. Not a high frequency occurrence but it is possible to bump a valve in just the right way to force it to shift if you don’t have a solenoid forcing it one way or the other. If you are concerned about duty cycle, remember that the single solenoid valves are on 100% of the time when actuated.

This is important to note. If you are planning any kind of rough and tumble play, you will want to keep a double solenoid activated in one position or another. We experienced this in 2016 - with our catapult release solenoid set to off, we were experiencing frequent misfires when we crossed the ramparts. Once we set the solenoid to be always on, we never had the problem again.
It seems that if the solenoid is not activated, the small sliding “gate” inside is free to move around. In a normal factory automation scenario, this is never a problem. In our application however, it very well can be.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.