Skip to content

Commit 3a9d812

Browse files
committed
HV Steamfitters Updates
1 parent fb41f39 commit 3a9d812

File tree

8 files changed

+48
-32
lines changed

8 files changed

+48
-32
lines changed

embedded/app/include/states.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* Pressure sensor acceptable limits (in PSI) */
1010
#define PS1_BOTTOM_LIMIT_IDLE -50
11-
#define PS1_BOTTOM_LIMIT_PRE 0
11+
#define PS1_BOTTOM_LIMIT_PRE -50
1212
#define PS1_BOTTOM_LIMIT_CRAWLPOST 300
1313
#define PS1_TOP_LIMIT_PRE 1300
1414
#define PS1_TOP_LIMIT_CRAWLPOST 1000
@@ -32,15 +32,15 @@
3232
#define PS3_TOP_LIMIT_CRAWLPOST 150
3333

3434
#define SEC_PS1_BOTTOM_LIMIT_IDLE -50
35-
#define SEC_PS1_BOTTOM_LIMIT_PRE 300
35+
#define SEC_PS1_BOTTOM_LIMIT_PRE -300
3636
#define SEC_PS1_BOTTOM_LIMIT_CRAWLPOST 300
3737
#define SEC_PS1_TOP_LIMIT_PRE 1400
3838
#define SEC_PS1_TOP_LIMIT_CRAWLPOST 1400
3939
#define SEC_PS1_TOP_LIMIT_IDLE 1400
4040

4141

4242
#define SEC_PS2_BOTTOM_LIMIT_IDLE -15
43-
#define SEC_PS2_BOTTOM_LIMIT_PRE 0
43+
#define SEC_PS2_BOTTOM_LIMIT_PRE -10
4444
#define SEC_PS2_BOTTOM_LIMIT_CRAWLPOST 0
4545
#define SEC_PS2_TOP_LIMIT_PRE 150
4646
#define SEC_PS2_TOP_LIMIT_CRAWLPOST 150

embedded/app/main/badgerloop_HV.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ printf("Ezra\n");
5959
sig.sa_sigaction = emergQuitter;
6060
sigaction(SIGINT, &sig, NULL);
6161
/* Start 'black box' data saving */
62-
/* SetupDataDump();*/
62+
SetupDataDump();
6363

6464
return 0;
6565
}
@@ -73,7 +73,7 @@ int main() {
7373
fprintf(stderr, "Error in initialization! Exiting...\r\n");
7474
exit(1);
7575
}
76-
76+
fprintf(stderr,"torque,rpm\n");
7777
while(1) {
7878
runStateMachine();
7979

@@ -106,6 +106,7 @@ int main() {
106106
} else {
107107
i += 1;
108108
}
109+
fprintf(stderr, "%d,%d,%d\n", data->rms->actualTorque, data->rms->motorSpeed, getuSTimestamp());
109110
usleep(10000);
110111

111112
// Control loop

embedded/app/src/states.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
pow(35181.0 * (x), 3) - \
3535
pow(303240.0 * (x), 2) - (1000000.0 * (x)))
3636

37-
#define MAX_RETRO 3
37+
#define MAX_RETRO 1
3838
#define MAX_PACKET_LOSS 500
3939
/* Imports/Externs */
4040
extern int internalCount;
@@ -100,10 +100,10 @@ stateTransition_t * pumpdownAction() {
100100
}
101101

102102
// CHECK PRESSURE
103-
if(!checkPrerunPressures()){
103+
/* if(!checkPrerunPressures()){
104104
fprintf(stderr, "Pressure failure\n");
105105
pErrs += 1;
106-
} else pErrs = 0;
106+
} else pErrs = 0;*/
107107

108108
if(!checkPrerunBattery()){
109109
fprintf(stderr, "prerun batt fault\n");
@@ -134,10 +134,10 @@ stateTransition_t * propulsionAction() {
134134

135135
// CHECK FAULT CRITERIA
136136
// CHECK PRESSURE -- PreRun function still valid here
137-
if (!checkPrerunPressures()) {
137+
/* if (!checkPrerunPressures()) {
138138
fprintf(stderr, "Pressure failing\n");
139139
pErrs += 1;
140-
} else pErrs = 0;
140+
} else pErrs = 0;*/
141141

142142
if(!checkRunBattery()){
143143
printf("Failed battery\n");
@@ -149,7 +149,7 @@ stateTransition_t * propulsionAction() {
149149
rErrs += 1;
150150
} rErrs = 0;
151151

152-
if (getuSTimestamp() - data->timers->startTime > 30000000/*MAX_RUN_TIME*/){
152+
if (getuSTimestamp() - data->timers->startTime > 7000000/*MAX_RUN_TIME*/){
153153
fprintf(stderr, "Prop timeout\n");
154154
return stateMachine.currState->next;
155155
}
@@ -239,10 +239,10 @@ stateTransition_t * stoppedAction() {
239239
if (checkNetwork() != 0) return stateMachine.currState->fault;
240240
// CHECK FAULT CRITERIA
241241

242-
if(!checkBrakingPressures()){ // Still unchanged
242+
/* if(!checkBrakingPressures()){ // Still unchanged
243243
printf("Pressures failing\n");
244244
pErrs += 1;
245-
} else pErrs = 0;
245+
} else pErrs = 0;*/
246246

247247
if(!checkBrakingBattery()){ // Still unchanged
248248
fprintf(stderr, "Battery error\n");
@@ -262,10 +262,10 @@ stateTransition_t * stoppedAction() {
262262

263263
stateTransition_t * servPrechargeAction() {
264264
data->state = 6;
265-
if (!checkBrakingPressures()) {
265+
/* if (!checkBrakingPressures()) {
266266
fprintf(stderr, "Pressure failed\n");
267267
return findTransition(stateMachine.currState, RUN_FAULT_NAME);
268-
} else pErrs = 0;
268+
} else pErrs = 0;*/
269269

270270
if (!getIMDStatus()) {
271271
fprintf(stderr, "getIMDStatus()");
@@ -299,10 +299,10 @@ stateTransition_t * crawlAction() {
299299
return findTransition(stateMachine.currState, POST_RUN_NAME);
300300
}
301301

302-
if(!checkCrawlPostrunPressures()){
302+
/* if(!checkCrawlPostrunPressures()){
303303
printf("pres fail\n");
304304
pErrs += 1;
305-
} else pErrs = 0;
305+
} else pErrs = 0;*/
306306

307307
if(!checkCrawlBattery()){
308308
printf("batt fail\n");
@@ -369,7 +369,7 @@ stateTransition_t * safeToApproachAction() {
369369
/* return stateMachine.currState->fault;*/
370370
/* } */
371371
pressure_t *p = data->pressure;
372-
if (p->primTank > 30 || p->primTank < -15 ||
372+
/* if (p->primTank > 30 || p->primTank < -15 ||
373373
p->primLine > 20 || p->primLine < -10 ||
374374
p->primAct > 20 || p->primAct < -10 ||
375375
p->secTank > 30 || p->secTank < -15 ||
@@ -378,7 +378,7 @@ stateTransition_t * safeToApproachAction() {
378378
p->pv > 20 || p->pv < 13 ){
379379
fprintf(stderr, "Pressures are out of the safe range\n");
380380
return findTransition(stateMachine.currState, NON_RUN_FAULT_NAME);
381-
}
381+
}*/
382382

383383
if (checkNetwork() != 0) return findTransition(stateMachine.currState, NON_RUN_FAULT_NAME);
384384
if (data->flags->emergencyBrake) {

embedded/data/include/data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ typedef struct motion_t {
142142
*
143143
*/
144144
typedef struct bms_t {
145-
float packCurrent;
145+
// float packCurrent;
146+
int64_t packCurrent;
146147
float packVoltage;
147148
int imdStatus;
148149
uint16_t packDCL;

embedded/peripherals/src/bms.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ int bmsParseMsg(uint32_t id, uint8_t *msg) {
4040
bms_t *bms = data->bms;
4141
switch(id) {
4242
case 0x6B0:
43-
bms->packCurrent = msg[1] | msg[0] << 8;
44-
bms->packCurrent /= 10;
45-
bms->packVoltage = msg[3] | msg[2] << 8;
46-
bms->packVoltage /= 10;
43+
bms->packCurrent = (msg[1] | msg[0] << 8)/10;
44+
printf("0x6B0 Pack Current 1\ 0: %f\n", bms->packCurrent);
45+
//int64_t tryTwo = (((int16_t) msg[1]) |((int16_t) msg[0]) << 8)/10;
46+
//printf("0x6B0 Pack Current hepl: %lld\n", tryTwo);
47+
48+
bms->packVoltage = (msg[3] | msg[2] << 8)/10;
4749
bms->Soc = msg[4]/2;
4850
bms->relayStatus = msg[6] | msg[5] << 8;
4951
bms->cellMaxVoltage = ((msg[5] << 8)| msg[6]) /10000.0;
@@ -68,8 +70,7 @@ int bmsParseMsg(uint32_t id, uint8_t *msg) {
6870
/* printf("ID: 0x%3lx\r\n", (long unsigned int) id);*/
6971
bms->relayStatus = msg[1] | msg[0] << 8;
7072
bms->relayStatus = msg[0];
71-
bms->inputVoltage = msg[2] | (msg[3] << 8);
72-
bms->inputVoltage /= 10;
73+
bms->inputVoltage = (msg[2] | (msg[3] << 8))/10;
7374
#ifdef DEBUG_BMS
7475
printf("Relay status %d\r\n", bms->relayStatus);
7576
printf("Input Source Supply Voltage: %f\r\n", bms->inputVoltage);
@@ -109,8 +110,7 @@ int bmsParseMsg(uint32_t id, uint8_t *msg) {
109110
bms->Soc /= 2;
110111
bms->packResistance = msg[1] | (msg[2] << 8);
111112
bms->packHealth = msg[3];
112-
bms->packOpenVoltage = msg[4] | (msg[5] << 8);
113-
bms->packOpenVoltage /= 10;
113+
bms->packOpenVoltage = (msg[4] | (msg[5] << 8))/10;
114114
bms->packCycles = msg[6] | (msg[7] << 8);
115115
#ifdef DEBUG_BMS
116116
printf("SOC %d\r\n", bms->Soc);
@@ -121,9 +121,16 @@ int bmsParseMsg(uint32_t id, uint8_t *msg) {
121121
#endif
122122
break;
123123
case 0x150:
124+
// printf("");
125+
// float twoTrye = (msg[0] | (msg[1] << 8))/10;
126+
// printf("0x150 Pack Current 0/1: %f\n", twoTrye);
127+
128+
// float twoTry2 = (msg[1] | (msg[0] << 8))/10;
129+
// printf("0x150 Pack Current 1/ 0: %f\n", twoTry2);
130+
124131

125132
/* bms->avgTemp = msg[0];*/
126-
bms->packCurrent /= 10;
133+
// bms->packCurrent /= 10;
127134
/* bms->cellMinVoltage = ((msg[3] << 8) | msg[4]) / 10000.0;*/
128135
/* bms->packVoltage = msg[2] | (msg[3] << 8);*/
129136
/* bms->packVoltage /= 10;*/

embedded/peripherals/src/rms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int rmsCmdResponseParse(uint8_t *rmsData, uint16_t filter, bool write) {
149149
}
150150
int rmsSendHbMsg(uint16_t torque) {
151151

152-
uint8_t payload[] = {TORQUE_SCALE_LWR(torque), 0/*TORQUE_SCALE_UPR(torque)*/, 0x0, 0x0,
152+
uint8_t payload[] = {TORQUE_SCALE_LWR(torque), TORQUE_SCALE_UPR(torque), 0x0, 0x0,
153153
0x1, 0x1, 0x0, 0x0};
154154

155155
sem_wait(&canSem);

middleware/src/HVTCPSocket.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void *TCPLoop(void *arg)
191191
// HEARTBEAT
192192
if (!strncmp(buffer, "ping", MAX_COMMAND_SIZE))
193193
{
194+
printf("ping\n");
194195
// Send acknowledge packet back
195196
send(new_socket, (char *)"pong1", strlen("pong1"), 0);
196197
}
@@ -226,7 +227,7 @@ void signalLV(char *cmd)
226227
addr.sin_port = htons(LV_SERVER_PORT);
227228

228229
if (connect(srvFd, (SA*)&addr,addrlen) != 0) {
229-
fprintf(stderr, "Failed to open port\n");
230+
// fprintf(stderr, "Failed to open port\n");
230231
close(srvFd);
231232
return;
232233
}

middleware/src/data_dump.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void currentDateTime(char *buf) {
3737
/* Thread Loop */
3838
void *DataLoop(void *arg){
3939

40+
printf("START DATA LOOP\n");
41+
4042
(void) arg;
4143

4244
FILE *fp;
@@ -45,16 +47,20 @@ void *DataLoop(void *arg){
4547
char timestamp[80];
4648
currentDateTime(timestamp);
4749

48-
sprintf(dir, "../data_logs/%s.csv", timestamp);
50+
sprintf(dir, "../../data_logs/LOG.csv", timestamp);
4951

5052
fp = fopen (dir,"w");
5153
if (fp == NULL){
5254
printf("Unable to open file\n");
5355
return NULL;
5456
}
57+
58+
5559

5660
fprintf(fp, "FRP,FPD,FRC,FP,FEB,TST,TLR,TLR1,TLR2,TLR3,Pps1,Pps2,Pps3,Sps1,Sps2,Sps3,pv,pos,vel,accel,retC,pCurr,pVol,pDCL,pCCL,pRes,pHealth,pOV,pC,pAH,iV,Soc,hiT,loT,cMax,cMin,cAvg,mCells,nCells,igbtTemp,GDBT,CBT,mT,mS,paC,pbC,pcC,dcbV,lvV,cc1,cc2,fC1,fC2,cT,aT,rS,eF,dcbC,oVL\n");
5761

62+
printf("ABOUT TO DATA LOOP\n");
63+
5864
while(1){
5965

6066
// FLAGS

0 commit comments

Comments
 (0)