Go to Post Copies gonna copy. - Arpan [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-02-2012, 22:47
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
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.

Last edited by ksanger : 20-02-2012 at 22:48. Reason: To enable notifications
Reply With Quote
  #2   Spotlight this post!  
Unread 21-02-2012, 07:51
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Only First Digital Input Works

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.SmartDashboar d;
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.SmartDashboar d;
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.OperateTurretComma nd;
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2012, 10:30
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Only First Digital Input Works

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?
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
Reply With Quote
  #4   Spotlight this post!  
Unread 22-02-2012, 07:22
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Only First Digital Input Works

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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:54.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi