Modules
precharge_control
receives can message for precharge
begins precharge (sets gpio pin)
acks the precharge message (checks the gpio state after setting it, if it’s the same, ack status OK)
receives can message for discharge (power-off sequence, bms faults)
acks the message
receives fault events for discharge(internally generated if the mci’s fault)
sends precharge complete message when precharge is complete (interrupt)
keeps a global state of the precharge status (the interrupt should be triggered on both rising and falling)
mci_data_broadcast
listens on the CAN network for mci data. (interrupt driven)
sends it on the car’s internal CAN network. (can happen when the interrupt goes off)
relay_rx - not needed by mc_interface
sets gpio state
will have a guard (precharge status can be used here)
Need to successfully disable
reads from it
acks message
will be a library
drive_rx
receive messages (only drive state) and keep a global state, also raise events
calls fsm directly with the event to change state
if already in drive and is set to drive, just return ok
pedal_rx
will be a library (has its own storage)
receives pedal messages (brake and throttle values) (in one message)
stores them in its storage
has a watchdog timer (sets to 0 brake 0 throttle if times out)
cruise_rx
receives cruise messages: on, off, increase, decrease
raises event
mci_output
has a public method to enable or disable the output
soft timer output behaviour is defined as follows for the drive state
Throttle | Brake | Current | Velocity |
---|---|---|---|
[0, 100] | (brake_threshold, 100] | function of brake value: brake_to_regen_map() → [0, MAX_REGEN] | 0 |
[0, regen_threshold] | [0, brake_threshold] | function of (throttle - regen_threshold) throttle_to_regen_map() → [0, MAX_REGEN_IN_THROTTLE] | 0 |
(regen_threshold, 100] | [0, brake_threshold] | throttle_to_acceleration_map() → [0, MAX_CURRENT] | reverse ? -100 : 100 |
from the table, the key values are:
brake_threshold: currently unknown
throttle/regen_threshold: currently_unknown
MAX_REGEN: 1.0f
MAX_REGEN_IN_THROTTLE: currently unknown
MAX_CURRENT: 1.0f
drive_output_fsm
has a can rx handler that processes an event directly upon drive state message
acks the message upon transitioning
allows repeat state commands (i.e. being set to drive while in drive is fine)
states:
off
off → drive: drive event gets raised from a drive state message.
off → reverse: reverse event gets raised from drive state message.
drive
drive → off: must happen immediately, can happen using a method and calling
fsm_process_event
explicitly.drive → reverse: reverse event gets raised from drive state message. (filtered at center console)
drive → cruise: cruise control ON message gets received.
reverse
reverse → drive: trivial (filtered at center console)
cruise:
cruise → cruise:
increase/decrease target speed
cruise → drive:
cancellation: through brake/throttle press
architecture:
have a repeating soft_timer for outputting to the motor controller.
body of soft_timer will be as follows:
if internal state is drive/reverse, make drive/reverse commands.
if internal state is cruise, make cruise commands and handle cruise logic (checking pedals)
soft_timer is cancelled when we’re in off.
uses heartbeat_rx library
Incoming CAN Messages
Message ID | Parameters | |
---|---|---|
CAR_DRIVE_STATE | u_8 drive_staet | |
BEGIN_PRECHARGE | ||
THROTTLE_OUTPUT | ||
SET_RELAY_STATES | ||
BRAKE_PRESSED | ||
CRUISE_CONTROL_COMMAND | ||
POWERTRAIN_HEARTBEAT |
Outgoing CAN Messages
Message ID | Parameters | DESCRIPTION |
---|---|---|
PRECHARGE_COMPLETED | no data | |
CRUISE_CONTROL_CANCELLED | no data | |
MOTOR_CONTROLLER_STATUS | u64 | |
MOTOR_CONTROLLER_DATA | u32 type, u32 data | |