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

PD power seq implementation #249

Merged
merged 4 commits into from
Jan 13, 2024
Merged

PD power seq implementation #249

merged 4 commits into from
Jan 13, 2024

Conversation

devAdhiraj
Copy link
Contributor

No description provided.

signals:
notification:
length: 8
relay_status:
length: 8
Copy link
Collaborator

@ShiCheng-Lu ShiCheng-Lu Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use mc_status: - precharge_status for the precharge status, and add power_distribution to the mc_states target

libraries/ms-common/src/fsm.c Outdated Show resolved Hide resolved
projects/power_distribution/inc/power_seq_fsm.h Outdated Show resolved Hide resolved
@@ -44,3 +44,31 @@ StatusCode pd_set_output_group(OutputGroup group, OutputState state) {
}
return STATUS_CODE_OK;
}

StatusCode pd_set_active_output_group(OutputGroup group) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize the current method we have won't work, since if we're turning everything off that we don't need, that includes the lights and whatnot that we don't want to touch. I think we will need to split this into two output configs, one for the main boards and then one for all the other non-functional outputs (lights etc). We can still use the same methods, we'll just have to specify which output group we're talking about.

}
}
if (!found) {
status_ok_or_return(bts_output_enable_output(&g_output_config[output]));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be disable output right?

static void prv_init_state_output(void *context) {
LOG_DEBUG("Transitioned to INIT_STATE\n");
static PowerFsmContext power_context = { 0 };
static const GpioAddress dcdc_valid_pin = DCDC_VALID;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this pin definition, and use elbert's methods

static PowerFsmContext power_context = { 0 };
static const GpioAddress dcdc_valid_pin = DCDC_VALID;

static GlobalErrorCode prv_fault_check() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the #define fault check to the c file. It should check for a watchdog timeout, or a fault received from BMS, if either has occurred transition to Fault

power_context.latest_state == TURN_ON_DRIVE_OUTPUTS) {
pd_set_output_group(OUTPUT_GROUP_DRIVE, OUTPUT_STATE_OFF);
}
pd_set_output_group(OUTPUT_GROUP_POWER_ON, OUTPUT_STATE_ON);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to set fault state enabled (Relays off)

Comment on lines 91 to 63
OUTPUT_GROUP_HAZARD,
// Power States
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split the outputs into two Enums.
// Outputs for the power FSM are such that if a group is on, all others must be off
// Use pd_set_active_output_group to set power fsm outputs
// PowerFsmOutputs and LightOutputs should not be combined in output groups
OutputPowerFsm {
... = 0,
...
NUM_POWER_FSM_OUTPUTS,
}

// Light outputs are independently controlled, separate to the power states
// Use pd_set_active_output_group to set light outputs
OutputLights {
BPS_STROBE = NUM_POWER_FSM_OUTPUTS,
RIGHT_TURN,
LEFT_TURN,
BRAKE,
};

@@ -89,6 +89,11 @@ typedef enum {
OUTPUT_GROUP_LEFT_TURN,
OUTPUT_GROUP_RIGHT_TURN,
OUTPUT_GROUP_HAZARD,
// Power States
OUTPUT_GROUP_BMS_RELAYS,
OUTPUT_GROUP_POWER_OFF,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OUTPUT_GROUP_POWER_... -> Power fsm output group
OUTPUT_GROUP_LIGHTS_... -> lights output group

@@ -89,6 +89,11 @@ typedef enum {
OUTPUT_GROUP_LEFT_TURN,
OUTPUT_GROUP_RIGHT_TURN,
OUTPUT_GROUP_HAZARD,
// Power States
OUTPUT_GROUP_BMS_RELAYS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, just noticing this but I think we might have more output groups than we need here. Pretty sure they only change for the major states, (OFF | ON | DRIVE | FAULT) so we should only need 4 POWER_FSM_OUTPUTS. Lmk if I missed something

@mitchellostler mitchellostler merged commit 704016f into main Jan 13, 2024
1 check passed
@mitchellostler mitchellostler deleted the power-seq-fsm branch January 13, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants