Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
hardwareSettings.hpp
Go to the documentation of this file.
1#pragma once
2
3constexpr int COMPONENT_TIMESTAMP_TIMEOUT = 500;
4constexpr int RES_TIMESTAMP_TIMEOUT = 200;
5constexpr int DC_VOLTAGE_TIMEOUT = 150;
6constexpr int DC_VOLTAGE_HOLD = 1000;
7constexpr int EBS_BUZZER_TIMEOUT = 8000;
8constexpr int LED_BLINK_INTERVAL = 500;
9constexpr int PROCESS_INTERVAL = 200;
10constexpr int SLOWER_PROCESS_INTERVAL = 30;
11constexpr int INITIAL_CHECKUP_STEP_TIMEOUT = 500;
12constexpr unsigned long READY_TIMEOUT_MS = 5000;
13constexpr unsigned long RELEASE_EBS_TIMEOUT_MS = 1000;
14constexpr unsigned long ENGAGE_EBS_TIMEOUT_MS = 5000;
15constexpr int WD_TIMEOUT_MS = 500;
18constexpr int LIMIT_RPM_INTERVAL = 500000;
19
20constexpr int ADC_MAX_VALUE = 1023;
21constexpr int SOC_PERCENT_MAX = 100;
22constexpr int MAX_MISSION = 7;
23constexpr int PULSES_PER_ROTATION = 48;
24constexpr int SECONDS_IN_MINUTE = 60;
25constexpr float MICRO_TO_SECONDS = 1e-6f;
26
27// Number of consecutive different values of a digital input to consider change
28// (to avoid noise)
29constexpr int CHANGE_COUNTER_LIMIT = 5;
30constexpr int WD_PULSE_INTERVAL_MS = 50;
31constexpr int WATCHDOG_TOGGLE_DURATION = 1000;
32constexpr int WATCHDOG_TEST_DURATION = 1000;
33
34constexpr float MAX_V_ANALOG = 3.3; // Volts
35constexpr float MIN_HYDRAULIC_V = 0.5; // Volts
36
37// Hydraulic pressure sensor constants
38constexpr float HYDRAULIC_PRESSURE_SLOPE = 65.0f; // bar/V slope from sensor equation
39constexpr int HYDRAULIC_PRESSURE_MAX_BAR = 95; // Maximum pressure in bar
40
41// Hydraulic pressure sensor ADC calculations
42// Sensor equation: U = (p/65) + 0.5, where 65 is the slope of the linear function
43// With 10-bit ADC (0-1023 over 0-3.3 V): U = (N / 1023) x 3.3
45 static_cast<int>(MIN_HYDRAULIC_V / MAX_V_ANALOG * ADC_MAX_VALUE); // 155
46constexpr float MAX_HYDRAULIC_V =
48 MIN_HYDRAULIC_V; // (95/65) + 0.5 ≈ 1.96V
50 static_cast<int>(MAX_HYDRAULIC_V / MAX_V_ANALOG * ADC_MAX_VALUE); // 607
53/*
54 * ===========
55 * OUTPUT PINS
56 * ===========
57 */
58
59constexpr int ASSI_BLUE_PIN = 25;
60constexpr int ASSI_YELLOW_PIN = 12;
61
62constexpr int EBS_VALVE_REAR_PIN = 17;
63constexpr int EBS_VALVE_FRONT_PIN = 13;
64
65constexpr int CLOSE_SDC = 21;
66// #define SDC_LOGIC_WATCHDOG_OUT_PIN 10
67constexpr int SDC_BSPD_OUT = 14;
68
69constexpr int BRAKE_LIGHT = 2;
70constexpr int WD_SDC_CLOSE = 40; // high if bspd is high (sdc closed)?
71constexpr int WD_ALIVE = 15;
72
73/*
74 * ==========
75 * INPUT PINS
76 * ==========
77 */
78
79constexpr int ASMS_IN_PIN = 18;
80constexpr int AMI = 19;
81
82// When pressure on the line passes the threshold defined, pin is set to HIGH
83constexpr int EBS_SENSOR1 = 41;
84constexpr int EBS_SENSOR2 = 39;
85constexpr int SDC_TSMS_STATE_PIN = 22;
86
87constexpr int RL_WSS = 5;
88constexpr int RR_WSS = 4;
89constexpr int BRAKE_SENSOR = 38;
90constexpr int SOC = 24;
91constexpr int ATS = 16;
92constexpr int ASATS = 20;
93constexpr int WD_READY = 37;
94constexpr int WD_SDC_RELAY = 33;
constexpr int SDC_BSPD_OUT
constexpr unsigned long READY_TIMEOUT_MS
constexpr int HYDRAULIC_PRESSURE_MAX_BAR
constexpr int CLOSE_SDC
constexpr int ADC_MAX_VALUE
constexpr int EBS_VALVE_FRONT_PIN
constexpr int EBS_VALVE_REAR_PIN
constexpr int WATCHDOG_TEST_DURATION
constexpr int PROCESS_INTERVAL
constexpr int HYDRAULIC_PRESSURE_SPAN_ADC
constexpr int HYDRAULIC_PRESSURE_ADC_MAX
constexpr unsigned long RELEASE_EBS_TIMEOUT_MS
constexpr float MICRO_TO_SECONDS
constexpr int ASMS_IN_PIN
constexpr int RR_WSS
constexpr int RES_TIMESTAMP_TIMEOUT
constexpr int LIMIT_RPM_INTERVAL
constexpr float MAX_HYDRAULIC_V
constexpr int SECONDS_IN_MINUTE
constexpr int WD_SDC_RELAY
constexpr float MIN_HYDRAULIC_V
constexpr int SOC
constexpr unsigned long ENGAGE_EBS_TIMEOUT_MS
constexpr int COMPONENT_TIMESTAMP_TIMEOUT
constexpr int LED_BLINK_INTERVAL
constexpr int CHANGE_COUNTER_LIMIT
constexpr int WD_TIMEOUT_MS
constexpr int EBS_SENSOR2
constexpr int BRAKE_PRESSURE_UPPER_THRESHOLD
constexpr int BRAKE_PRESSURE_LOWER_THRESHOLD
constexpr int SLOWER_PROCESS_INTERVAL
constexpr int RL_WSS
constexpr float MAX_V_ANALOG
constexpr int DC_VOLTAGE_HOLD
constexpr int HYDRAULIC_PRESSURE_ADC_MIN
constexpr int WD_SDC_CLOSE
constexpr int WD_READY
constexpr int WD_ALIVE
constexpr int WD_PULSE_INTERVAL_MS
constexpr int INITIAL_CHECKUP_STEP_TIMEOUT
constexpr int ASSI_BLUE_PIN
constexpr int MAX_MISSION
constexpr float HYDRAULIC_PRESSURE_SLOPE
constexpr int EBS_SENSOR1
constexpr int ASATS
constexpr int PULSES_PER_ROTATION
constexpr int BRAKE_LIGHT
constexpr int ATS
constexpr int AMI
constexpr int WATCHDOG_TOGGLE_DURATION
constexpr int SOC_PERCENT_MAX
constexpr int EBS_BUZZER_TIMEOUT
constexpr int SDC_TSMS_STATE_PIN
constexpr int BRAKE_SENSOR
constexpr int ASSI_YELLOW_PIN
constexpr int DC_VOLTAGE_TIMEOUT