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

Implement PDU 24A #221

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
436cd7b
Added current reading to pdu.c, added the sending of current via CAN …
bjackson312006 Nov 7, 2024
be4306e
Changes in Embedded-Base submodule that were preventing building
bjackson312006 Nov 7, 2024
242e5fe
Updated submodule
bjackson312006 Nov 7, 2024
7d6a26a
Updated submodule
bjackson312006 Nov 7, 2024
1ccf1f7
Formatting
bjackson312006 Nov 7, 2024
c60dfb7
Condensed current into 1 CAN message, changed pca9539 to tca9539
bjackson312006 Nov 8, 2024
75aa2d4
reverted pca9539 to tca9539 change, will do that at the end. also for…
bjackson312006 Nov 9, 2024
f7c7d37
Formatting
bjackson312006 Nov 9, 2024
c2d19db
Formatting
bjackson312006 Nov 9, 2024
3dd772a
Updated pinout according to schematic
bjackson312006 Nov 10, 2024
6affcce
Forgot to remove comments
bjackson312006 Nov 10, 2024
136af62
Updated fuse and shutdown pins in read_fuses and read_shutdown
bjackson312006 Nov 10, 2024
526d1c1
Changed SHUTDOWN_ADDR and CTRL_ADDR to correspond w/ datasheet
bjackson312006 Nov 10, 2024
d70e409
Formattng
bjackson312006 Nov 10, 2024
b66ca51
Formatting
bjackson312006 Nov 10, 2024
dfcab75
Updated read_fuse and read_shutdown in pdu.c based on schematic. Also…
bjackson312006 Nov 10, 2024
d30cc77
pdu.c: Removed global hi2c pointer,
bjackson312006 Nov 13, 2024
8b61fed
Removed functions in pdu.h that I left in by mistake. Also comment ch…
bjackson312006 Nov 13, 2024
32185f4
pdu.c: Corrected ina_write_reg wrapper function
bjackson312006 Nov 13, 2024
bd2889c
Added comment for calibration constants, and made tsms_pin const
bjackson312006 Nov 19, 2024
74e0930
switch to cubemx version 6.13.0
jr1221 Jan 13, 2025
3b97753
Revert "switch to cubemx version 6.13.0"
jr1221 Jan 13, 2025
3c641e2
Merge branch 'develop' into feature/PDU-24A
jr1221 Jan 13, 2025
c6d49ed
fix my merge mistakes
jr1221 Jan 13, 2025
7814f87
fmt
jr1221 Jan 13, 2025
ec16123
add adc2 pc0 pc1 for pump temp sense
jr1221 Jan 13, 2025
e68056d
Added ADC DMA for pump sensors
bjackson312006 Jan 13, 2025
297b86f
Revert accidental formatting changes in main.c
bjackson312006 Jan 13, 2025
ad0d719
Added control line functions for PDU 24A
bjackson312006 Jan 16, 2025
872eb81
Formatting whoops
bjackson312006 Jan 16, 2025
e85fcb9
Reorganized PDU 24A control functions so less messy
bjackson312006 Jan 16, 2025
fa570c8
Removed redundant functions
bjackson312006 Jan 16, 2025
6f2effd
Removed merge conflicts
bjackson312006 Jan 24, 2025
2a4f278
Merge branch 'develop' into feature/PDU-24A
bjackson312006 Jan 24, 2025
7bf8231
Formatting
bjackson312006 Jan 24, 2025
1b93d91
Merge branch 'feature/PDU-24A' of github.com:Northeastern-Electric-Ra…
bjackson312006 Jan 24, 2025
53a279a
Made GPIO #defines consistent with Altium (a few pins are unused)
bjackson312006 Jan 24, 2025
0f9679a
Uncommented Shutdown GPIO init
bjackson312006 Jan 24, 2025
fe59815
Moved pdu #defines to pdu.h since there were a lot
bjackson312006 Jan 24, 2025
c00889c
Changed read_pump_sens to correct CANID in monitor.c
bjackson312006 Jan 25, 2025
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
1 change: 1 addition & 0 deletions Core/Inc/cerberus_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
#define CANID_LV_MONITOR 0x503
#define CANID_PEDALS_ACCEL_MSG 0x504
#define CANID_PEDALS_BRAKE_MSG 0x505
#define CANID_PDU_CURRENT 0x508
// Reserved for MPU debug message, see yaml for format
#define CANID_EXTRA_MSG 0x701
1 change: 1 addition & 0 deletions Core/Inc/fault.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef enum {
BSPD_PREFAULT = 0x1000,
LV_MONITOR_FAULT = 0x2000,
RTDS_FAULT = 0x4000,
PDU_CURRENT_FAULT = 0x8000,
MAX_FAULTS
} fault_code_t;

Expand Down
45 changes: 28 additions & 17 deletions Core/Inc/pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "cmsis_os.h"
#include "pca9539.h"
#include "INA226.h"
#include <stdbool.h>
#include <stdint.h>

Expand All @@ -13,6 +14,10 @@ typedef struct {
osMutexId_t *mutex;
pca9539_t *shutdown_expander;
pca9539_t *ctrl_expander;
ina226_t *motor_controller_current_sensor;
ina226_t *battbox_fans_current_sensor;
ina226_t *pumps_current_sensor;
ina226_t *lv_boards_current_sensor;
} pdu_t;

/* Creates a new PDU interface */
Expand All @@ -26,15 +31,16 @@ int8_t write_fan_battbox(pdu_t *pdu, bool status);

/* Function to Read the Status of Fuses from PDU */
typedef enum {
FUSE_BATTBOX,
FUSE_LVBOX,
FUSE_FAN_RADIATOR,
FUSE_MC,
FUSE_FAN_BATTBOX,
FUSE_PUMP,
FUSE_DASHBOARD,
FUSE_BRAKELIGHT,
FUSE_BRB,
BATTBOX_FUSE_STAT,
LV_BOARDS_FUSE_STAT,
RADFAN_FUSE_STAT,
BUCK_FUSE_STAT,
FANBATTBOX_FUSE_STAT,
PUMP_FUSE_STAT0,
DASHBOARD_FUSE_STAT,
BRKLIGHT_FUSE_STAT,
SD_TO_BRB_FUSE_STAT,
PUMP_FUSE_STAT1,
MAX_FUSES
} fuse_t;

Expand All @@ -59,14 +65,14 @@ int8_t read_tsms_sense(pdu_t *pdu, bool *status);
/* Functions to Read Status of Various Stages of Shutdown Loop */
typedef enum {
CKPT_BRB_CLR, /* Cockpit BRB */
BMS_OK, /* Battery Management System (Shepherd) */
INERTIA_SW_OK, /* Inertia Switch */
SPARE_GPIO1_OK,
IMD_OK, /* Insulation Monitoring Device */
BSPD_OK, /* Brake System Plausbility Device */
BOTS_OK, /* Brake Over Travel Switch */
HVD_INTLK_OK, /* HVD Interlock */
HVC_INTLK_OK, /* HV C Interlock*/
BMS_GOOD, /* Battery Management System (Shepherd) */
INERTIA_SW_GOOD, /* Inertia Switch */
SPARE_GPIO1,
IMD_GOOD, /* Insulation Monitoring Device */
BSPD_GOOD, /* Brake System Plausbility Device */
BOTS_GOOD, /* Brake Over Travel Switch */
HVD_INTLK_GOOD, /* HVD Interlock */
HVC_INTLK_GOOD, /* HV C Interlock*/
//SIDE_BRB_CLR, /* Side BRB */
//TSMS, /* Tractive System Main Switch */
MAX_SHUTDOWN_STAGES
Expand All @@ -81,6 +87,11 @@ typedef enum {
*/
int8_t read_shutdown(pdu_t *pdu, bool status[MAX_SHUTDOWN_STAGES]);

// Function for reading current
int8_t read_all_current(pdu_t *pdu, float *motor_controller_current,
float *battbox_fans_current, float *pumps_current,
float *lv_boards_current);

/**
* @brief Taskf for sounding RTDS.
*
Expand Down
48 changes: 48 additions & 0 deletions Core/Src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,53 @@
static bool tsms = false;
osMutexId_t tsms_mutex;

/**
* @brief Read current of MC, battox fans, pumps, and LV boards and send a CAN message with the result.
*/
void read_current(pdu_t *pdu)
{
fault_data_t fault_data = { .id = PDU_CURRENT_FAULT,
.severity = DEFCON5 };
can_msg_t msg = { .id = CANID_PDU_CURRENT, .len = 8, .data = { 0 } };

float motor_controller_current;
float battbox_fans_current;
float pumps_current;
float lv_boards_current;

if (read_all_current(pdu, &motor_controller_current,
&battbox_fans_current, &pumps_current,
&lv_boards_current)) {
fault_data.diag = "Failed to read current";
queue_fault(&fault_data);
}

uint16_t int_motor_controller_current =
(uint16_t)(motor_controller_current * 1000);
uint16_t int_battbox_fans_current =
(uint16_t)(battbox_fans_current * 1000);
uint16_t int_pumps_current = (uint16_t)(pumps_current * 1000);
uint16_t int_lv_boards_current = (uint16_t)(lv_boards_current * 1000);

struct __attribute__((__packed__)) {
uint16_t motor_controller;
uint16_t battbox_fans;
uint16_t pumps_current;
uint16_t lv_boards;
} current_data;

current_data.motor_controller = int_motor_controller_current;
current_data.battbox_fans = int_battbox_fans_current;
current_data.pumps_current = int_pumps_current;
current_data.lv_boards = int_lv_boards_current;

memcpy(msg.data, &current_data, msg.len);
if (queue_can_msg(msg)) {
fault_data.diag = "Failed to send current CAN message";
queue_fault(&fault_data);
}
}

/**
* @brief Read the open cell voltage of the LV batteries and send a CAN message with the result.
*/
Expand Down Expand Up @@ -120,6 +167,7 @@ void vNonFunctionalDataCollection(void *pv_params)
for (;;) {
read_lv_sense(mpu);
read_fuse_data(pdu);
read_current(pdu);

/* delay for 1000 ms (1k ticks at 1000 Hz tickrate) */
osDelay(1000);
Expand Down
Loading