-
Notifications
You must be signed in to change notification settings - Fork 0
Modules
This module performs the two safety checks related to the accelerator position sensors. A periodic function, APPS_100Hz, runs at 100Hz. This function calls two helper functions that perform the following checks.
The formula SAE rules require that no torque is requested from the motor if the accelerator position sensors read more than 10% differently for 100ms. The function for this check requires nothing more than the current positions indicated by each accelerator position sensor. It is implemented using a state machine, with four states. See F30/Electronics/firmware/VC/APPS_state_machine for a state diagram. Each iteration of this check advances the state machine by 10ms with the new positions as inputs. The output of this state machine sets and clears FaultCode_APPS_SENSOR_DISAGREEMENT.
This check is run at the same cadence as the above, every 10ms within the top level APPS function. A basic hysteresis is used to set/clear the fault. If the brake is on and the average accelerator position is greater than a set point, FaultCode_APPS_DOUBLE_PEDAL is set. If the average accelerator position drops below a reset level, the fault is cleared. This hysteresis is mandated by competition rules.
This module is responsible for converting the two accelerator sensor ADC readings into accelerator positions. A simple linear conversion is used to convert the ADC reading to a voltage, and the voltage to an accelerator position. The two positions are averaged to produce an average accelerator position.