Skip to content

Commit f0c4d78

Browse files
committed
new etc constants and bms fault fixes
1 parent bebf66b commit f0c4d78

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

BMS/src/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool checkingPrechargeStatus = false;
5959
bool checkingShutdownStatus = false;
6060

6161
bool prechargeDone = false;
62-
bool hasBmsFault = true;
62+
bool hasBmsFault = false; // assume no fault at start
6363
bool isCharging = false;
6464
bool hasFansOn = false;
6565
bool isBalancing = false;
@@ -127,7 +127,6 @@ int main() {
127127
continue; // If not an osEventMessage, continue
128128
}
129129
// Status Message unpacking from bmsEvent
130-
hasBmsFault = false;
131130

132131

133132
maxCellTemp = bmsEvent->maxTemp; // Assign the maxTemp from bmsEvent
@@ -168,6 +167,7 @@ int main() {
168167
// Process the bmsState value in bmsEvent
169168
case BMSThreadState::BMSStartup:
170169
printf("BMS Fault Startup State\n");
170+
hasBmsFault = false;
171171
break;
172172
case BMSThreadState::BMSIdle:
173173
// printf("BMS Fault Idle State\n");
@@ -184,7 +184,6 @@ int main() {
184184
break;
185185
case BMSThreadState::BMSFaultRecover:
186186
printf("BMS Fault Recovery State\n");
187-
hasBmsFault = false;
188187
break;
189188
case BMSThreadState::BMSFault:
190189
printf("*** BMS FAULT ***\n");
@@ -251,7 +250,7 @@ int main() {
251250
}
252251

253252
bms_fault_pin = !hasBmsFault;
254-
bms_fault_inverse_pin = !bms_fault_pin;
253+
bms_fault_inverse_pin = hasBmsFault;
255254

256255

257256
precharge_control_pin = prechargeDone;
@@ -264,7 +263,7 @@ int main() {
264263
}
265264
fan_pwm.write(fan_percent / 100.0);
266265

267-
printf("shutdown state: %x\n", shutdown_measure_pin.read());
266+
// printf("shutdown state: %x\n", shutdown_measure_pin.read());
268267

269268
status_message.bmsFault = hasBmsFault;
270269
status_message.shutdownState = shutdown_measure_pin.read();
@@ -336,8 +335,8 @@ void initIO() {
336335
fan_pwm.period_us(40);
337336
fan_pwm.write(0);
338337
fan_percent = 0;
339-
bms_fault_pin = 1; // assume no fault at start, 1 is no fault
340-
bms_fault_inverse_pin = 0; // assume no fault at start, 0 is no fault
338+
bms_fault_pin = !hasBmsFault; // assume no fault at start, 1 is no fault
339+
bms_fault_inverse_pin = hasBmsFault; // assume no fault at start, 0 is no fault
341340
precharge_control_pin = 0; // positive AIR open at start
342341
state_of_charge = 100; // TODO: CHANGE TO ACCOUNT FOR POSSIBLE DISCHARGE
343342

ETC/src/etc_controller.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ class ETCController {
9494
/** The voltage divider slope for the hall-effect 1 sensor. */
9595
static constexpr float HE1_SCALE = (330.0f / 480.0f);
9696
/** The voltage for HE1 corresponding to 0% pedal travel. */
97-
static constexpr float HE1_LOW_VOLTAGE = 1.824f;
97+
static constexpr float HE1_LOW_VOLTAGE = 0.620f;
9898
/** The voltage for HE1 corresponding to 100% pedal travel. */
99-
static constexpr float HE1_HIGH_VOLTAGE = 2.806f;
99+
static constexpr float HE1_HIGH_VOLTAGE = 2.420f;
100100
/** The difference between the maximum and minimum voltages (100% and 0% travel) for HE1. */
101101
static constexpr float HE1_RANGE =
102102
ETCController::HE1_HIGH_VOLTAGE - ETCController::HE1_LOW_VOLTAGE;
103103
/** The voltage divider slope for the hall-effect 2 sensor. */
104104
static constexpr float HE2_SCALE = (1.0f / 2.0f);
105105
/** The voltage for HE2 corresponding to 0% pedal travel. */
106-
static constexpr float HE2_LOW_VOLTAGE = 1.449f;
106+
static constexpr float HE2_LOW_VOLTAGE = 0.420f;
107107
/** The voltage for HE2 corresponding to 100% pedal travel. */
108-
static constexpr float HE2_HIGH_VOLTAGE = 2.206f;
108+
static constexpr float HE2_HIGH_VOLTAGE = 1.830f;
109109
/** The difference between the maximum and minimum voltages (100% and 0% travel) for HE2. */
110110
static constexpr float HE2_RANGE =
111111
ETCController::HE2_HIGH_VOLTAGE - ETCController::HE2_LOW_VOLTAGE;

0 commit comments

Comments
 (0)