Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Falcon Temperature #23

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/main/java/frc/robot/DriveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
import com.ctre.phoenix.motorcontrol.TalonFXControlMode;
import com.ctre.phoenix.motorcontrol.can.TalonFX;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class DriveModule {
private TalonFX master;
private TalonFX slave1;
private TalonFX slave2;

private Solenoid cooler;

private Solenoid pto;

DriveModule(TalonFX master, TalonFX slave1, TalonFX slave2, Solenoid pto) {
private final double MAX_TEMP = 35; //TODO: Determine optimal temperature

DriveModule(TalonFX master, TalonFX slave1, TalonFX slave2, Solenoid pto, Solenoid cooler) {
this.master = master;
this.slave1 = slave1;
this.slave2 = slave2;

this.slave1.follow(this.master);
this.slave2.follow(this.master);

this.cooler = cooler;

this.pto = pto;
}

Expand All @@ -40,8 +45,14 @@ public void setPTO(boolean engaged) {
/**
* Adds the temperature of the motors to Smart Dashboard.
*/
public void getTemp(String message) {
double[] temp = {master.getTemperature(), slave1.getTemperature(), slave2.getTemperature()};
SmartDashboard.putNumberArray(message, temp);
public double getTemp(TalonFX motor) {
sreeves750 marked this conversation as resolved.
Show resolved Hide resolved
return motor.getTemperature();
}

/**
* Cools falcons using pneumatic coolers if above recommended temperature.
*/
public void coolTemp() {
cooler.set(getTemp(master) > MAX_TEMP || getTemp(slave1) > MAX_TEMP || getTemp(slave2) > MAX_TEMP);
}
}
9 changes: 6 additions & 3 deletions src/main/java/frc/robot/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ public double deadband(double in) {
return Math.abs(in) > DEADBAND_LIMIT ? in : 0.0;
}

public void getTemp() {
left.getTemp("Left Motor Temperature");
right.getTemp("Right Motor Temperature");
/**
* Cools Falcon temperature.
*/
public void coolFalconTemp() {
sreeves750 marked this conversation as resolved.
Show resolved Hide resolved
left.coolTemp();
right.coolTemp();
}
}
11 changes: 8 additions & 3 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.GenericHID.Hand;
Expand Down Expand Up @@ -86,18 +87,22 @@ public void robotInit() {

if (this.drivetrainToggle) {
System.out.print("Initializing drivetrain...");
Solenoid pto = new Solenoid(2,0);
DriveModule leftModule = new DriveModule(
new TalonFX(5),
new TalonFX(6),
new TalonFX(7),
new Solenoid(2, 0)
pto,
new Solenoid(2, 4)
);
DriveModule rightModule = new DriveModule(
new TalonFX(8),
new TalonFX(9),
new TalonFX(10),
new Solenoid(2, 1)
pto,
new Solenoid(2, 5)
);

drive = new Drivetrain(leftModule, rightModule);
System.out.println("done");
} else {
Expand Down Expand Up @@ -162,7 +167,7 @@ public void teleopPeriodic() {

drive.arcadeDrive(turnInput, speedInput);

drive.getTemp();
drive.coolFalconTemp();
}

if (this.photoswitchSensorToggle)
Expand Down