Hi, I am trying to make a “t-shirt cannon” robot for our school. We have an old base and a t-shirt gun. We just want to have 2 solenoids control the charger and trigger for the t-shirt gun. When we add code for the solenoid (using the WPILIB example changed to our Rev pneumatic hub hardware) the code will not make the solenoids fire. If we have the robot connected to the rev hardware client AND the driver station enabled we can fire the solenoids from the hardware client.
When not connected and running the code in driver station we can drive the base. I am frustrated as I think the code is correct as it is just the example code in WPILIB with our added base driving code, which is super simple. Any suggestions on how to troubleshoot. I am a coach and our team is not super great at FRC, but we have fun.
Are they 12V or 24V solenoids? If 24, did you change the REV PH to 24V mode? If not, your code is likely fine but there just isn’t enough power to trigger the solenoids.
In case that’s not the case, could you share your code?
If the power turns out to be to low. I heard of teams putting relays from the PCM to the solenoid. Especially if the solenoid is a larger 2", compared to the 1/4" ones that are legal.
If the Solenoids are firing with the use of the REV Hardware Client, just not when you enable the robot with your robot code, then your issue is almost certainly a communication issue with the Pneumatic hub (check your CAN wiring), or you have a problem with your code.
Would definitely recommend linking your code here for others to take a look at. It makes things like this 1000x easier to diagnose over the internet.
Good catch. I missed that it worked with the hardware client
Here is the code I just tried, after switching the REVPH to 24 volt just in case. The switch changed nothing.
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.TimedRobot;
/**
- This is a sample program showing the use of the solenoid classes during operator control. Three
- buttons from a joystick will be used to control two solenoids: One button to control the position
- of a single solenoid and the other two buttons to control a double solenoid. Single solenoids can
- either be on or off, such that the air diverted through them goes through either one channel or
- the other. Double solenoids have three states: Off, Forward, and Reverse. Forward and Reverse
- divert the air through the two channels and correspond to the on and off of a single solenoid,
- but a double solenoid can also be “off”, where the solenoid will remain in its default power off
- state. Additionally, double solenoids take up two channels on your PCM whereas single solenoids
- only take a single channel.
*/
public class Robot extends TimedRobot {
private final Joystick m_stick = new Joystick(0);
// Solenoid corresponds to a single solenoid.
private final Solenoid m_solenoid = new Solenoid(PneumaticsModuleType.REVPH, 0);
// DoubleSolenoid corresponds to a double solenoid.
private final DoubleSolenoid m_doubleSolenoid =
new DoubleSolenoid(PneumaticsModuleType.REVPH, 1, 2);
private static final int kSolenoidButton = 1;
private static final int kDoubleSolenoidForward = 2;
private static final int kDoubleSolenoidReverse = 3;
@Override
public void teleopPeriodic() {
/*
* The output of GetRawButton is true/false depending on whether
* the button is pressed; Set takes a boolean for whether
* to use the default (false) channel or the other (true).
*/
m_solenoid.set(m_stick.getRawButton(kSolenoidButton));
/*
* In order to set the double solenoid, if just one button
* is pressed, set the solenoid to correspond to that button.
* If both are pressed, set the solenoid will be set to Forwards.
*/
if (m_stick.getRawButton(kDoubleSolenoidForward)) {
m_doubleSolenoid.set(DoubleSolenoid.Value.kForward);
} else if (m_stick.getRawButton(kDoubleSolenoidReverse)) {
m_doubleSolenoid.set(DoubleSolenoid.Value.kReverse);
}
}
}
Additionally the Solenoids are basic FRC CKD which we have used in the past.
And the weird thing is, Rev hardware client only works if driver station is enabled. I have set systems up with no Rio in the past running the rev hardware client and they worked.
Thanks
if the rio is connected the robot must be enabled. The rio is sending disabled packets as long as its not enabled, preventing the rev client from doing anything. unplug the rio from the can chain and everything will work
Have you tried putting logging into teleopPeriodic
to verify that these lines are being invoked?
We had an issue like this. Try the makeDoubleSolenoid method on the pneumatics hub. I think that is what did it for us.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.