Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Buttons to change state

    • Drive, Reverse, and Neutral

    • Regen Braking button

    • Hazard Button

  • three 7-segment displays with the below quantities

    • Speedometer (speed in km/h)

      • When we BPS fault it will display the error code instead

    • Current Readings (Amps)

    • Aux Battery Voltage (Volts)

  • Indicator LEDs

    • One for each of the above buttons (D/N/R/Haz/Reg)

    • Left turn signal

    • Right Turn Signal

    • Cruise control enabled indicator

    • BPS Fault Light

    • AFE Loss of Communications

  • Buzzer to highlight important events

    • Button Clicks

    • Aux BPS fault

    • BPS fault

...

  • Pedal Position

    • Maps ADC reading from 0-1 for the Motor Controller

  • Steering Stalk

    • Toggles Left/Right lights

    • Toggles Cruise Control

Expand
titleCAN Signals

TX:

  • cc_info:

    • Target Velocity (Cruise Control Speed)

    • Drive State

    • hazard_enabled

  • drive_output → MCI

    • drive_state

    • cruise_control (cruise control enabled)

    • regen_braking (regen brake enabled)

    • target_velocity (u32)

RX: (with checks to determine if a board has gone offline)

  • power_info (PD)

    • power_state

    • pd_fault

  • motor_info (MCI)

    • velocity_l & velocity_r(current speed)

    • board_fault_bitset (motor fault)

    • pedal_fault (if pedal loses comms)

  • battery_info: (BMS)

    • batt_perc (battery percentage)

    • fault (bms fault)

  • steering:

    • input_cc

    • input_lights

  • pedal_status

    • brake_output (brake value)

  • solar

    • solar_fault

    • (D/N/R)

    • Cruise Control (Boolean)

    • Hazard Enabled (Boolean)

  • cc_pedal:

    • Throttle output (Mapped from 1 - 0) Float

    • Brake output (Boolean)

  • cc_steering:

    • Input CC (Cruise control toggle/decrease/increase)

    • Input Lights (Left/Right lights)

  • cc_regen:

    • Regen Percent (Calculated with battery data to determine max regen permitted)

RX:

  • battery_status (BMS)

    • Fault

    • Aux Battery Voltage

    • AFE Status

  • battery_info (BMS)

    • Max Cell Voltage

    • Min Cell Voltage

  • battery_vt (BMS)

    • Pack Voltage

    • Pack Current

    • Pack Temperature

    • Battery Percentage

  • pd_status (Power Distribution)

    • Power State

    • PD Fault Bitset

    • BPS Persisted Fault

  • motor_controller_vc (MCI)

    • Right/Left motor voltage

    • Right/left motor current

  • motor_velocity (MCI)

    • Right/left motor velocity

    • One pedal brake lights

  • mc_stauts (MCI)

    • Left/Right errors + limit messages

Centre Console Functionality

Module: cc_buttons

This module provides a functions to get gets all button values. Buttons should be read in the fast cycle. They are connected to the pca9555 gpio expander, and must be read over i2c. This read function should just send notifications to the requisite tasks.

...

  • dashboard_init()

  • update_indicators()

    • Gets notification value from button presses, updates indicator lights and output can_messages

      Power button:

      Set cc_power_ctrl.power_event

      POWER_EV_NONE if no power button pressed event

      • POWER_EV_BTN if button is pressed and brake reading == 0

      • POWER_EV_BTN_AND_BRAKE if button is pressed and brake reading != 0

      • Hazard enabled:

        • when pressed, toggle static hazard state

        • update indicator and cc_power_control.hazard_enabled message based on stored value

      • Regen Brake:

        • when pressed, toggle static regen brake state

        • update indicator and drive_output.regen_brake_enabled message based on stored value

      • Lights left/right

        • update left/right indicator based on steering _info.input_lightsstalk position

      • Cruise Control Enabled:

        • update static cc state + indicator based on steering _info.cc_input

        • update indicator based on cc_state

        • update stalk ISR (Button click)

        • update drive_output based on cc_state + target_velocity

  • update_displays() [SEPERATE TASK]

    • Reads values from CAN messages, uses values for 7-seg:

      • motor_info.current_speed Calculated speed using RPM to MPH → speed display

      • battery_info.batt_percentage → battery display

      • if (cruise control enabled) target_velocity → cruise control display (Top)

      • Current reading in Amps → current display (Middle)

      • Aux Battery Voltage → aux batt display (Bottom)

  • cruise_control_monitor()

    • Checks for cruise control inputs from steering stalk

    • Updates Cruise control target speed

...

The Drive FSM handles the control of drive state of the car. It receives the drive buttons (Neutral (N), Drive (D), Reverse(R)) and runs the preparations and checks needed to change the drive state of the car, and communicate communicates this value with the motor controllers.

The initial/default state is Neutral. This is the mandated state of the FSM when we start the car up and are in POWER_OFF state or POWER_ON state as dictated by power distributionIDLE state. In addition, any major faults should force the car into neutral.

The drive state is dependent on power_state == power_drive. We expect to receive this message every cycle, and if we do not receive this message, we will record a fault after 3 cycles and enter neutral.

State Input Functions:

All the following must be met for a transition to happen from the following states

Neutral → Drive/Reverse

  • Button pressed (D/R)

  • Power state == POWER_DRIVE (received from Power distribution)

  • Speed == 0: All drive state transitions should happen when we are stopped

Actions:

  • Transmit DRIVE state to MCI

Neutral → Reverse

  • Button pressed (D)

  • Power state == POWER_DRIVE (received from Power distribution)

  • Speed == 0: All drive state transitions should happen when we are stopped

Actions:

  • Transmit Runs precharge, and closes motor relay

  • Transmit DRIVE/REVERSE state to MCI

Drive/Reverse → Neutral

  • Neutral button or force (sent by power fsm)forced because of fault

  • Transmit NEUTRAL state to MCI

Reverse → Drive OR Drive Neutral

...

Neutral button or force (sent by power fsm) or drive_state != main (drive state)

...

Reverse

  • Since we are an EV we can do this easily! Transmits NEW_STATE to MCI

Expand
titlePower State FSM - Moved to Power Distribution

Power FSM

The power FSM governs the power state of the car. There are 4 main States:

  • POWER_OFF

  • POWER_MAIN

  • POWER_AUX

  • POWER_FAULT

For the main power states however, when we are transitioning there is a sequence of checks we run to make sure that the system is in a correct state to allow a transition. These steps typically involve sending a CAN message to another system, waiting for it to do its checks and balances and then receiving an acknowledgement (ACK) message. If these checks fail, we will transition back to the normal power state.

The sequence model for these states is along the following lines:

  • All steps must be executed successfully before a transition can take place

  • If a step fails, we should handle the error and remain in the current state

The diagram is shown below, hexagons representing the sequence steps. The states themselves have no real functionality in their output functions.

Power Aux Sequence*

  1. Confirm a valid aux status has been received from Power Select Info message

    1. Correct status bits should be set in the message

    2. No fault bits should be set

  2. Transmit TURN_ON_EVERYTHING to Power Distribution and receive BPS heartbeat

    1. Once Power Distribution has turned everything on, we wait for BMS to power up and send heartbeat message, indicating that the power on was successful

*From Power Aux, if a fault condition is detected (ie invalid power select status message) we should return to off

Power main sequence

  1. Confirm Aux Status

    1. Confirm no issues with aux supply at Power Select

    2. Check power select message for valid aux status, and no faults

  2. Power on boards

    1. Tell Power distribution to power on all outputs

  3. Confirm battery status

    1. Wait for BMS to start up and reply with a Heartbeat and status message

    2. This indicates initial state is all good

  4. Close Relays

    1. Transmit message to BMS to close relays and switch to main power

    2. Transmits to BMS to close relays

  5. Confirm DCDC

    1. Check at power select that main power (DCDC) is now in use

  6. Power Main Complete

    1. Sends “ready to drive” to MCI

    2. Start BPS watchdog

Power Off Sequence:

  1. Discharge Precharge

    1. Send message to MCI to discharge precharge

  2. Open Relays (Transition to fault on BPS Fault)

    1. Tell BMS to open the relays

  3. Confirm Back to Aux with power select

  4. Turn Off everything

    1. Tell Power distribution to turn off everything except for power select, centre console, and pedal

Fault

  • This state covers a BPS fault during operation. It occurs if we receive a message from BMS saying that we have a fault condition, or a timeout occurs on the BPS heartbeat message

    • If a message is received saying that a fault has occurred, then we can attempt to handle the specific faultIf a BPS timeout has occurred, we must discharge MCI and loop until BPS communication resumes, or the car is power cycled.

    • Car must be power-cycled and then put into drive to clear the persisted fault

    • BPS indicator is on during this time (and hazard lights flash as well I believe)