Skip to content

Restructured VCU FSM to separate individual cases in EM_Fault().#91

Open
EmadsGitHub wants to merge 5 commits intomainfrom
VCU_FSM_Restructure
Open

Restructured VCU FSM to separate individual cases in EM_Fault().#91
EmadsGitHub wants to merge 5 commits intomainfrom
VCU_FSM_Restructure

Conversation

@EmadsGitHub
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread vcu/Src/drive_by_wire.c Outdated
sendCAN_VCU_Throttle_Failure();
int currentState = fsmGetState(&VCUFsmHandle);
DEBUG_PRINT("Throttle read failure, trans to fatal failure\n");
sendDTC_FATAL_VCU_F7_EV_FATAL();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's send DTC 30 before invoking VCU FATAL DTC. Without it, the fatal DTC doesn't tell us anything about the root cause.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They are called before you call that function pretty sure.

Comment thread common/Data/2024CAR.dbc Outdated
SG_ ChannelCurrentMCRight : 0|16@1+ (0.01,0) [0|0] "Amps" Vector__XXX
SG_ ChannelCurrentAUX : 0|16@1+ (0.01,0) [0|0] "" Vector__XXX

BO_ 2287668226 VCU_Toggle_EM_Off: 8 VCU_F7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can put this all in one message and have distinct signals

Comment thread vcu/Src/drive_by_wire.c Outdated
{ STATE_EM_Enable, EV_EM_Toggle, &ToggleMotorsOff },
{ STATE_Failure_Fatal, EV_ANY, &fatalTransition },
{ STATE_ANY, EV_CAN_Receive_HV, &processHvState}, // From DCU. Check HV toggle response from the BMU
// { STATE_ANY, EV_CAN_Receive_EM, &processEmState}, // From DCU. Happens locally now so remove it
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove any events nots used, especially stuff commented out

Comment thread vcu/Src/drive_by_wire.c Outdated
@@ -102,7 +110,7 @@ Transition_t transitions[] = {
{ STATE_EM_Enable, EV_BTN_TC_Toggle, &toggleTC}, // From DCU
// { STATE_EM_Enable, EV_BTN_Endurance_Mode_Toggle, &toggleEnduranceMode}, // From DCU
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Endurance mode not in use, remove for now as we don't even have a working endurance mode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove debounce timer, I can't comment on it since it wasn't modified, see line 156

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On second thought keep the transition and add a note endurance mode not currently in use, also remove everything that says "from DCU"

Comment thread vcu/Src/drive_by_wire.c
{
sendDTC_WARNING_Throttle_Failure(3);
return EM_Fault(EV_Throttle_Failure);
return Throttle_Shutdown(EV_Throttle_Failure);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove comments on lines 216 and 217

Comment thread vcu/Src/drive_by_wire.c
Comment thread vcu/Src/drive_by_wire.c
VCU_States_t state = shutDownMotors(STATE_HV_Disable);
return state;
}
uint32_t Generic_EM_Fault(uint32_t event){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

change all function return types to be VCU_States_t instead as necessary

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

its supposed to be uint32_t but I think I messed up by declaring it as VCU_States_t in the function

Comment thread common/Data/2024CAR.dbc Outdated
BO_ 2287668226 VCU_Toggle_EM_Off: 8 VCU_F7
SG_ EMFaultEvent : 0|8@1+ (1,0) [0|255] "" Vector__XXX

BO_ 2287733762 VCU_HV_Disable_Twice: 8 VCU_F7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is Disable twice?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Its for disableRedundancy, tbh idk why I didn't keep it the same name

Comment thread vcu/Src/drive_by_wire.c Outdated
uint32_t EM_Fault(uint32_t event)
{
int newState = STATE_Failure_Fatal;
uint32_t BPS_Failure_Shutdown(uint32_t event){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BPS is brake pressure sensor. you have redundant transitions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I was just copying the transitions from how it was initially lol

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My suggestion is when working on something, don't assume what was previously done is perfect. Investigate what it is you're working on and find ways to improve it outside of what was just asked of you. It's some good feedback one of my previous employers gave me to improve as an engineer. For example in this case the VCU state machine isn't perfect and could use some optimization

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I found out that BPS_Failure wasn't implemented out so I removed it

Comment thread vcu/Src/drive_by_wire.c Outdated
{ STATE_EM_Enable, EV_EM_Toggle, &EM_Fault },
{ STATE_HV_Enable, EV_Hv_Disable, & DisablingHV},
{ STATE_EM_Enable, EV_Bps_Fail, &BPS_Failure_Shutdown },
{ STATE_EM_Enable, EV_Hv_Disable, & DisablingHV},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove extra space between & and DisablingHV

Comment thread vcu/Src/drive_by_wire.c Outdated
sendCAN_VCU_Toggle_EM_Off();
DEBUG_PRINT("EM Toggle, trans to EM Disabled\n");
//disable TC
disableRegen();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would move disableRegen and disable_TC to MotorStop

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