Skip to content

Commit 25c4417

Browse files
Added detection for unsafe temp and battery levels
1 parent b9f710f commit 25c4417

File tree

4 files changed

+50
-13
lines changed

4 files changed

+50
-13
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package frc.robot.constants;
22

33
public class BattMonConstants {
4-
4+
//All of these aren't right and will need to be determined
55
public static double kBatt1 = 42;
66
public static double kBatt2 = 42;
77
public static double kPDP = 42;
88
public static double kTemp = 42;
9+
10+
public static double kBatt1Low = 2;
11+
public static double kBatt2Low = 2;
12+
public static double kPDPHigh = 42;
13+
public static double kTempHigh = 300;
914
}

src/main/java/frc/robot/subsystems/battMon/BattMonHardware.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import edu.wpi.first.wpilibj.DigitalInput;
55
import edu.wpi.first.wpilibj.DutyCycle;
66
import frc.robot.constants.BattMonConstants;
7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
97

108
public class BattMonHardware implements BattMonIO {
119

@@ -17,16 +15,10 @@ public class BattMonHardware implements BattMonIO {
1715
private DutyCycle batt2Cycle = new DutyCycle(batt2);
1816
private DutyCycle PDPCycle = new DutyCycle(PDP);
1917
private DutyCycle tempCycle = new DutyCycle(temp);
20-
private Logger logger;
2118

22-
private double batt1Output;
23-
private double batt2Output;
24-
private double pdpOutput;
25-
private double tempOutput;
2619
private Counter tempCounter = new Counter(temp);
2720

2821
public BattMonHardware() {
29-
logger = LoggerFactory.getLogger(this.getClass());
3022
tempCounter.setUpSourceEdge(true, false);
3123
}
3224

src/main/java/frc/robot/subsystems/battMon/BattMonIO.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ public interface BattMonIO {
66

77
@AutoLog
88
public class BattMonIOInputs {
9-
public double batt1Output = 0;
10-
public double batt2Output = 0;
11-
public double pdpOutput = 0;
12-
public double tempOutput = 0;
9+
public double batt1Output;
10+
public double batt2Output;
11+
public double pdpOutput ;
12+
public double tempOutput ;
1313
}
1414

1515
public default void updateInputs(BattMonIOInputs inputs) {}

src/main/java/frc/robot/subsystems/battMon/BattMonSubsystem.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,53 @@
22

33
import edu.wpi.first.wpilibj2.command.SubsystemBase;
44
import frc.robot.subsystems.battMon.BattMonIO.BattMonIOInputs;
5+
import edu.wpi.first.wpilibj.Alert;
6+
import edu.wpi.first.wpilibj.Alert.AlertType;
57

68
public class BattMonSubsystem extends SubsystemBase {
9+
//Private objects
710
private BattMonIO io;
811
private BattMonIOInputs inputs = new BattMonIOInputs();
12+
//Alerts
13+
private Alert lowBattAlert = new Alert("WARNING low battery", AlertType.kWarning);
14+
private Alert highTempAlert = new Alert("WARNING reaching maximum temp!", AlertType.kWarning);
15+
private Alert dangerTempAlert = new Alert("DANGER MAXIMUM TEMP REACHED", AlertType.kError);
16+
private Alert safeAgainAlert = new Alert("SAFE Temp low. Limits removed", AlertType.kInfo);
917

1018
@Override
1119
public void periodic() {
20+
//Refresh data and graph it
1221
io.updateInputs(inputs);
22+
23+
//Check for dangerous outputs NOTE all of these values are temporary
24+
if (inputs.batt1Output > 1000){
25+
lowBattAlert.set(true);
26+
}else {
27+
lowBattAlert.set(false);
28+
}
29+
30+
if (inputs.tempOutput > (1000 * inputs.pdpOutput)){
31+
highTempAlert.set(true);
32+
safeAgainAlert.set(false);
33+
}else if (inputs.tempOutput > (2000 * inputs.pdpOutput)
34+
&& inputs.tempOutput < (1000 * inputs.pdpOutput)) {
35+
highTempAlert.set(false);
36+
dangerTempAlert.set(true);
37+
}else {
38+
highTempAlert.set(false);
39+
dangerTempAlert.set(false);
40+
safeAgainAlert.set(true);
41+
}
42+
1343
}
44+
45+
public enum battMonStates {
46+
47+
NORMAL,//Safe Temp
48+
WARNING,//Reaching Dangerous temps
49+
DANGER,//Dangerous temps
50+
BATTLOW //Low Battery
1451
}
52+
53+
}
54+

0 commit comments

Comments
 (0)