Only First Digital Input Works

We are having difficulties with our digital inputs. Only the first initialized DigitalInput is working. Its on the compressor. We’ve defined other digital inputs for limit switches, a counter, and encoders. The switches never change, and the counter is counting with the motor off. Plus the period of the counter does not change. We’ve ohmed out the switches at the plug, and verify +5V and Gnd at the switch when we open and close it. In our code the compressor object is the first object with a Digital Input that is initialized.

Our PWMs out work. Our Solenoids work. Our Relays work. But I/O is a big issue.

We do not see any error messages. Any ideas would be welcomed.

Incorrectly stated first instantiated DigitalInput object is the one that works while it is actually the last one.

Also if its relevant the DigitalInput that works is on Channel 14.

**Examples:
We are using the following for our encoder:
**
package frc3838.robot.subsystems;

import edu.wpi.first.wpilibj.Counter;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc3838.robot.RobotMap;
import frc3838.robot.Setup;
import frc3838.robot.commands.ReportThrowSpeedCommand;
import frc3838.robot.utils.LOG;

public class ThrowerSubsystem extends Subsystem
{
private static double ENCODER_SCALE = 60/32;

private static Counter throwMotorEncoder;
private static void initThrowMotor()
{
    try
    {
        if (Setup.isThrowMotorEnabled() && throwMotor == null)
        {
            LOG.trace("initializing throw motor");
            throwMotorEncoder = new Counter(RobotMap.DigitalIO.THOW_MOTOR_ENCODER);
            throwMotorEncoder.reset();
            throwMotorEncoder.start();
        }
        else
        {
            LOG.info("ThrowMotor is disabled. Will not initialize it.");
        }
    }
    catch (Exception e)
    {
        LOG.error("An exception occurred when ThrowerSubsystem.initThrowMotor was executed.", e);
    }
}

public int getCount()
{
    return throwMotorEncoder.get();
}

public double getSpeed()  // Returns speed in RPM
{
    double speed;
    
    speed = throwMotorEncoder.getPeriod();  // Returns time in sec.
    if (speed == 0)
    {
        return 0.0;
    }
    else
    {
        speed = ENCODER_SCALE/speed; // speed in RPM.  Note 32 Counts/Rev.
        return speed;
    }
}

}

Here is what we do for the Limit Switches:
package frc3838.robot.subsystems;

import edu.wpi.first.wpilibj.PWM;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.DigitalInput;
import frc3838.robot.RobotMap;
import frc3838.robot.Setup;
import frc3838.robot.commands.shooting.OperateTurretCommand;
import frc3838.robot.utils.LOG;

public class TurretSubsystem extends Subsystem
{

private static PWM turretPanMotorPWM;
private static int turretPanSetting = RobotMap.Constants.TURRET_MOTOR_PWM_START;
private static Encoder turretEncoder;
private static DigitalInput turretCWLimit;
private static DigitalInput turretCCWLimit;

//static initializer block

static
{
    LOG.trace("TurretSubsystem initializer block executing");

    LOG.debug("TurretSubsystem initializer block exiting");
}

private static void initTurretMotorPWM()
{
    try
    {
        if (Setup.isTurretPanMotorEnabled() && turretPanMotorPWM == null)
        {
            LOG.trace("initializing turretMotorPWM");
            turretPanMotorPWM = new PWM(RobotMap.PWMChannels.TURRET_MOTOR_CHANNEL);
            turretPanMotorPWM.setRaw(turretPanSetting);
            if (RobotMap.IN_DEBUG_MODE)
            {
                SmartDashboard.putInt("TURRET_MOTOR", turretPanSetting);
            }
            LOG.trace("initializing turretEncoder");
            turretEncoder = new Encoder(RobotMap.DigitalIO.TURRET_ENCODER_A, RobotMap.DigitalIO.TURRET_ENCODER_B);
            turretEncoder.reset();
            turretEncoder.start();
            turretCWLimit = new DigitalInput(RobotMap.DigitalIO.TURRET_LIMIT_CW);
            turretCCWLimit = new DigitalInput(RobotMap.DigitalIO.TURRET_LIMIT_CCW);
            
        }
    }
    catch (Exception e)
    {
        LOG.error("An exception occurred when TurretSubsystem.initturretMotor"
                  + "PWM was executed.", e);
    }
}

public boolean getTurretCWLimit()
{
    return turretCWLimit.get();
}

public boolean getTurretCCWLimit()
{
    return turretCCWLimit.get();
}

public int getPosition()
{
    return turretEncoder.get();
}

}

End of Examples:
Our trace log shows that these methods are called and the Digital Inputs are the same as shown on the SmartDashboard.

What do we try next? All suggestions are extremely appreciated.

What does your wiring diagram look like?

Are these switches mechanical or hall-effect or optical or something else?

Your are using named constants for the switch channels. Is the numbering correct versus the actual wiring on the robot?

Found It!

Our cable between the cRIO and the Digital Side Car had pins that were recessed and probably not making contact. Replacing the cable to an older one fixed most everything.

We did have a Victor that wouldn’t work. Replacing the Victor fixed that too. Now we’re up, bagged, and working on adding more functionality to the SW.

For reference our switches were mechanical, and were wired to short the signal to ground. We had 5V on the signal side of the switch, and 0V on the other, until we closed the switch and obtained 0V.