Skip to content

Commit 9a4fbfe

Browse files
author
Ezra Boley
committed
Bout to pivot
1 parent 8ae3ee7 commit 9a4fbfe

File tree

21 files changed

+350
-433
lines changed

21 files changed

+350
-433
lines changed

embedded/app/include/state_machine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ typedef struct state_t {
6666
char *name; // FIXME Thinking about switching this to a number
6767
stateTransition_t **transitions;
6868
stateTransition_t *fault;
69+
int (*intro)(void);
6970
int numTransitions;
7071
int transitionCounter;
7172
} state_t;

embedded/app/include/states.h

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
/* Pressure sensor acceptable limits (in PSI) */
1010
#define PS1_BOTTOM_LIMIT_IDLE -50
1111
#define PS1_BOTTOM_LIMIT_PRE 500
12-
#define PS1_BOTTOM_LIMIT_CRAWLPOST -50
12+
#define PS1_BOTTOM_LIMIT_CRAWLPOST 300
1313
#define PS1_TOP_LIMIT_PRE 1300
1414
#define PS1_TOP_LIMIT_CRAWLPOST 50
1515
#define PS1_TOP_LIMIT_IDLE 1300
1616

1717
#define PS2_BOTTOM_LIMIT_IDLE -15
18-
#define PS2_BOTTOM_LIMIT_PRE 120
18+
#define PS2_BOTTOM_LIMIT_PRE 125
1919
#define PS2_BOTTOM_LIMIT_CRAWLPOST -15
2020
#define PS2_TOP_LIMIT_IDLE 150
2121
#define PS2_TOP_LIMIT_PRE 300
@@ -24,32 +24,32 @@
2424

2525
#define PS3_BOTTOM_LIMIT_IDLE -10
2626
#define PS3_BOTTOM_LIMIT_PRE -15
27-
#define PS3_BOTTOM_LIMIT_BRAKING 150
27+
#define PS3_BOTTOM_LIMIT_BRAKING 120
2828
#define PS3_BOTTOM_LIMIT_CRAWLPOST -15
2929
#define PS3_TOP_LIMIT_IDLE 15
3030
#define PS3_TOP_LIMIT_PRE 15
31-
#define PS3_TOP_LIMIT_BRAKING 300
32-
#define PS3_TOP_LIMIT_CRAWLPOST 15
31+
#define PS3_TOP_LIMIT_BRAKING 150
32+
#define PS3_TOP_LIMIT_CRAWLPOST 150
3333

3434
#define SEC_PS1_BOTTOM_LIMIT_IDLE -50
35-
#define SEC_PS1_BOTTOM_LIMIT_PRE 1000
36-
#define SEC_PS1_BOTTOM_LIMIT_CRAWLPOST 0
37-
#define SEC_PS1_TOP_LIMIT_PRE 3000
38-
#define SEC_PS1_TOP_LIMIT_CRAWLPOST 20
39-
#define SEC_PS1_TOP_LIMIT_IDLE 50
35+
#define SEC_PS1_BOTTOM_LIMIT_PRE 600
36+
#define SEC_PS1_BOTTOM_LIMIT_CRAWLPOST 300
37+
#define SEC_PS1_TOP_LIMIT_PRE 1400
38+
#define SEC_PS1_TOP_LIMIT_CRAWLPOST 1400
39+
#define SEC_PS1_TOP_LIMIT_IDLE 1400
4040

4141

4242
#define SEC_PS2_BOTTOM_LIMIT_IDLE -15
43-
#define SEC_PS2_BOTTOM_LIMIT_PRE 150
43+
#define SEC_PS2_BOTTOM_LIMIT_PRE 120
4444
#define SEC_PS2_BOTTOM_LIMIT_CRAWLPOST 0
45-
#define SEC_PS2_TOP_LIMIT_PRE 275
45+
#define SEC_PS2_TOP_LIMIT_PRE 150
4646
#define SEC_PS2_TOP_LIMIT_CRAWLPOST 20
4747
#define SEC_PS2_TOP_LIMIT_IDLE 15
4848

4949
#define SEC_PS3_BOTTOM_LIMIT_IDLE -15
50-
#define SEC_PS3_BOTTOM_LIMIT 0
51-
#define SEC_PS3_TOP_LIMIT 20
52-
#define SEC_PS3_TOP_LIMIT_IDLE 15
50+
#define SEC_PS3_BOTTOM_LIMIT -15
51+
#define SEC_PS3_TOP_LIMIT 150
52+
#define SEC_PS3_TOP_LIMIT_IDLE 150
5353

5454
#define PV_TOP_LIMIT 20
5555
#define PV_BOTTOM_LIMIT 10
@@ -59,21 +59,21 @@
5959
#define MAX_BATT_TEMP_PRERUN 33 /* Degrees Celcius */
6060
#define MAX_BATT_TEMP_RUN 48 /* Degrees Celcius */
6161

62-
#define MAX_BATT_CURRENT_STILL 0
62+
#define MAX_BATT_CURRENT_STILL 5
6363
#define MAX_BATT_CURRENT_MOVING 265
6464

6565
/* In mV */
66-
#define MAX_CELL_VOLTAGE 4200
67-
#define MIN_CELL_VOLTAGE 3000
66+
#define MAX_CELL_VOLTAGE 4.200
67+
#define MIN_CELL_VOLTAGE 3.000
6868

6969
#define MAX_PACK_VOLTAGE 302.5
7070
#define MIN_PACK_VOLTAGE_PRERUN 266.4
7171
#define MIN_PACK_VOLTAGE_RUN 235
7272
#define MIN_PACK_VOLTAGE_POSTRUN 224
7373

74-
#define MIN_SOC_PRERUN 90
75-
#define MIN_SOC_RUN 75
76-
#define MIN_SOC_POSTRUN 60
74+
#define MIN_SOC_PRERUN 20
75+
#define MIN_SOC_RUN 10
76+
#define MIN_SOC_POSTRUN 10
7777

7878
/* RMS Acceptable Limits FIXME is this too hot?*/
7979
#define MIN_IGBT_TEMP 10
@@ -92,34 +92,29 @@
9292
#define MAX_CONTROL_TEMP_RUN 88
9393
#define MAX_CONTROL_TEMP_POSTRUN 88
9494

95-
#define MIN_MOTOR_TEMP 10
96-
#define MAX_MOTOR_TEMP_PRERUN 50
97-
#define MAX_MOTOR_TEMP_RUN 200
98-
#define MAX_MOTOR_TEMP_SAFEAPPROACH 130
99-
100-
#define MIN_RPM_IDLE -350
101-
#define MIN_RPM_PUMPDOWN -30
102-
#define MIN_RPM_PROPULSION -30
103-
#define MIN_RPM_POST -350
95+
#define MIN_RPM_IDLE -1000
96+
#define MIN_RPM_PUMPDOWN -1000
97+
#define MIN_RPM_PROPULSION -1000
98+
#define MIN_RPM_POST -1000
10499

105100
#define MAX_RPM_IDLE 350
106101
#define MAX_RPM_PUMPDOWN 30
107102
#define MAX_RPM_PROPULSION 10000
108103
#define MAX_RPM_POST 30
109104
#define MAX_RPM_CRAWL 350
110105

111-
#define PHASE_A_MIN 0
112-
#define PHASE_A_MAX_PRE 0
113-
#define PHASE_A_MAX_PROPULSION 452
114-
#define PHASE_A_MAX_POST 0
115-
#define PHASE_A_MAX_CRAWL 200
106+
#define PHASE_A_MIN -480
107+
#define PHASE_A_MAX_PRE 10
108+
#define PHASE_A_MAX_PROPULSION 480
109+
#define PHASE_A_MAX_POST 5
110+
#define PHASE_A_MAX_CRAWL 480
116111

117-
#define DC_BUS_VOLTAGE_MIN 0
112+
#define DC_BUS_VOLTAGE_MIN -5
118113
#define DC_BUS_VOLTAGE_MAX 360
119114

120-
#define DC_BUS_CURRENT_MIN 0
115+
#define DC_BUS_CURRENT_MIN -5
121116
#define DC_BUS_CURRENT_MAX_IDLE 319
122-
#define DC_BUS_CURRENT_MAX_PUMPDOWN 1
117+
#define DC_BUS_CURRENT_MAX_PUMPDOWN 2
123118
#define DC_BUS_CURRENT_MAX_PROP 319
124119
#define DC_BUS_CURRENT_MAX_BRAKING 0.01
125120
#define DC_BUS_CURRENT_MAX_POST 0.01
@@ -134,12 +129,12 @@
134129
#define CMD_TORQUE_MAX_POST 0
135130
#define CMD_TORQUE_MAX_CRAWL 40
136131

137-
#define ACTUAL_TORQUE_MIN 0
132+
#define ACTUAL_TORQUE_MIN -10
138133
#define ACTUAL_TORQUE_MIN_BRAKING -100
139134
#define ACTUAL_TORQUE_MAX_PRE 20
140135
#define ACTUAL_TORQUE_MAX_RUN 90
141-
#define ACTUAL_TORQUE_MAX_BRAKING 0
142-
#define ACTUAL_TORQUE_MAX_STOPPED 1
136+
#define ACTUAL_TORQUE_MAX_BRAKING 10
137+
#define ACTUAL_TORQUE_MAX_STOPPED 10
143138
#define ACTUAL_TORQUE_MAX_CRAWL 40
144139
#define ACTUAL_TORQUE_MAX_POST 20
145140

embedded/app/include/transitions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ int toBraking(void);
1212
int toCrawl(void);
1313

1414
int toRunFault(void);
15+
16+
int toServPrecharge(void);
1517
#endif

embedded/app/main/badgerloop_HV.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
#include "HVTCPSocket.h"
88
#include "HV_Telem_Recv.h"
99
#include "data_dump.h"
10-
#include "connStat.h"
1110

1211

1312
extern "C"
1413
{
15-
#include <signal.h>
14+
#include "bbgpio.h"
15+
#include "connStat.h"
16+
#include <signal.h>
1617
#include <rms.h>
1718
#include "motor.h"
1819
#include "hv_iox.h"
@@ -75,12 +76,17 @@ int main() {
7576

7677
while(1) {
7778
runStateMachine();
79+
80+
/* printf("CONN STAT: TCP - %d | UDP - %d\n", */
81+
/* checkTCPStat(),*/
82+
/* checkUDPStat());*/
7883
if (data->flags->shouldBrake) {
7984
signalLV((char *)"brake");
8085
data->flags->shouldBrake = false;
8186
}
8287
if (data->flags->brakeInit) {
8388
signalLV((char *)"primBrakeOff");
89+
usleep(1000);
8490
signalLV((char *)"secBrakeOff");
8591
data->flags->brakeInit = false;
8692
}

embedded/app/main/badgerloop_LV.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <unistd.h>
5-
#include "connStat.h"
65
#include "LVTelemetry_Loop.h"
76
#include "LVTCPSocket.h"
87

@@ -13,7 +12,8 @@ extern "C"
1312
#include "lv_iox.h"
1413
#include "nav.h"
1514
#include "braking.h"
16-
15+
16+
#include "connStat.h"
1717
#include "proc_iox.h"
1818
#include "imu.h"
1919
#include <data.h>
@@ -26,13 +26,16 @@ int init() {
2626

2727
initProcIox(true);
2828
initLVIox(true);
29-
/* Init all peripherals */
29+
30+
/* Init all peripherals */
3031
SetupIMU();
3132
initRetros();
3233
initPressureMonitor();
3334
initNav();
35+
3436
/* Init telemetry services */
35-
SetupLVTelemetry((char *) DASHBOARD_IP, DASHBOARD_PORT);
37+
38+
SetupLVTelemetry((char *) DASHBOARD_IP, DASHBOARD_PORT);
3639
SetupLVTCPServer();
3740

3841
return 0;
@@ -44,9 +47,11 @@ int main() {
4447
printf("Error in initialization! Exiting...\r\n");
4548
exit(1);
4649
}
47-
flags_t *f = data->flags;
50+
int errs = 0;
4851
while(1) {
4952
usleep(100000);
53+
/* if (errs > 100) brake();*/
54+
5055
if (data->flags->shouldBrake) {
5156
brake();
5257
data->flags->shouldBrake = false;
@@ -67,7 +72,14 @@ int main() {
6772
brakeSecondaryUnactuate();
6873
data->flags->brakeSecRetr = false;
6974
}
70-
// Control loop
75+
if (!checkUDPStat() || !checkTCPStat())
76+
errs += 1;
77+
else
78+
errs = 0;
79+
80+
81+
82+
// Control loop
7183
}
7284
return 0;
7385

0 commit comments

Comments
 (0)