...
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)
discharges (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)
precharge_status_fsm
not really needed… precharge’s simple enough
...
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
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
...
will be a library
simply just acks powertrain messages
pedal_rx
receives pedal messages
stores them in its storage
cruise_rx
receives cruise messages: on, off, increase, decrease
raises event
drive_output_fsm
receives pedal messages (throttle and brake), and makes a decision on
target speed
throttle value
has two modes: cruise and normal
in normal,
in cruise, sets target speed
...
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.
drive → cruise: cruise control ON message gets received.
reverse
reverse → drive: trivial
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.
soft_timer is cancelled when we’re in off.
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 |
...