Formula Student Electronics & Software
The code for the embedded software
|
TeensyC1 - Caixa 1 - Located inside PCBs box
TeensyC3 - Caixa 3 - Located behind DashBoard
BMS - Battery Management System - Inside TSAC
Bamocar - Inverter/Controller
APPS - Accelerator Pedal Position Sensor - Pedal Box
BL - Brake Light
Inputs:
Outputs:
Documentation -> The mechanical part of buttons and switches vibrate slightly when closed or opened causing multiple undesired false states (similar to noise). This library filters out these undesired state changes.
In this case, we only use the function fell() that returns true if the pin signal transitions from high to low since the last update.
TS means Tractive System. If TS is on, it is because the shutdown system is closed (everything has no errors and the pilot requests to turn on the TS).
C3 Teensy knows that TS is on because Bamocar has one register that saves the DC voltage and if DC Voltage > 0, that is because the TS is on.
This teensy also has a FIFO Filter
only accepts messages from:
EV4.11.6
The vehicle is in Ready-to-drive (R2D) mode as soon as the motor(s) will respond to the input of the APPS.
EV4.11.7
After the TS has been activated, additional actions must be required by the driver to set the vehicle to R2D mode, e.g. pressing a dedicated start button. The transition to R2D mode must only be possible during the actuation of the mechanical brakes and a simultaneous dedicated additional action.
EV4.11.8
The R2D mode must be left immediately when the SDC is opened.
To enter the R2D logic all these conditions must be true:
If that is true:
c++ can1.write(clearErrors);
c++ while (not transmissionEnabled and CANTimer > CANTimeoutMS) { can1.write(transmissionRequestEnable); CANTimer = 0; }
c++ while (not BTBReady and CANTimer > CANTimeoutMS) { can1.write(BTBStatus); CANTimer = 0; }
c++ can1.write(noDisable);
When we receive a message from BAMOCAR (the id is BAMO_RESPONSE_ID) and the content (msg.buf) equals the predefined message “BTBResponse” the BTBReady variable is set to true.
This message “BTBResponse” was defined based on this document, page 19 shows two routine examples here we can see the expected response when BTB is closed (ready for operation).
This function enables a set of values from the BAMOCAR to be sent to the CAN BUS periodically.
Even though the logging itself is performed in the C1 teensy, these messages are requested here to only start the logging when the car is in R2D mode.
This is a diagram of the readApps() function:
These are the real values of apps:
This image is just an example to show the meaning of the variables used in the code.
This has been removed in the 2024 FSG Rules but this code implements this feature.