Datasheet
DMC60C™ Software Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 14 of 16
6.1.2 Java (Robot.java)
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-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;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Joystick;
import com.dmc60c.DMC60C;
public class Robot extends TimedRobot {
//DMC60C with device number 5
private DMC60C _dmc = new DMC60C(5);
//Joystick on USB port 0.
private Joystick _joy = new Joystick(0);
@Override
public void robotInit() {
//Invert motor and encoder based on the hardware configuration.
_dmc.setInverted(false);
_dmc.InvertEncoder(false);
}
@Override
public void teleopInit() {
//Reset the Encoder position to zero.
_dmc.ZeroEncoderPosition();
}
@Override
public void robotPeriodic() {}
@Override
public void teleopPeriodic() {
boolean A = _joy.getRawButton(1);
double stick = -1*_joy.getY();
//If A button is held
if(A){
//Drive -100 to 100 percent duty cycle
_dmc.DriveVoltage(stick*100);
//Report position on Smart Dashboard.
SmartDashboard.putNumber("Position", _dmc.GetEncoderPositionCount());
}
else{
_dmc.disable();
}
}
}
6.1.3 Labview
Use the Position Mode Example project (found in dmc60c-frc-api\Examples\Labview\PositionModeExample). In
teleOp.vi, replace the call to drivePosition with driveVoltage: