@@ -8,7 +8,7 @@ namespace VCFInterfaceConstants {
88 /* Teensy 4.1 GPIO pins */
99
1010 /* Not on Schematic
11- // constexpr int BTN_DIM_READ = 28;
11+ // constexpr int BTN_DIM_READ = 28; // Currently used for steering system recalibration TODO: change pin
1212 // constexpr int BTN_PRESET_READ = 31;
1313 // constexpr int BTN_MODE_READ = 27; // USED TO BE 26.
1414 */
@@ -93,9 +93,9 @@ namespace VCFInterfaceConstants {
9393 constexpr float FL_LOADCELL_OFFSET = 0.0 ;
9494 constexpr float FR_LOADCELL_SCALE = 1.0 ; // Values
9595 constexpr float FR_LOADCELL_OFFSET = 0.0 ;
96-
96+
9797 constexpr float FR_SUS_POT_SCALE = 0.01396 ; // Calibrated for mm between mounting bolts
98- constexpr float FR_SUS_POT_OFFSET = 150.8 ; // Can change offset once car is on ground to center at zero
98+ constexpr float FR_SUS_POT_OFFSET = 150.8 ;
9999 constexpr float FL_SUS_POT_SCALE = 0.01396 ; // Same as FR
100100 constexpr float FL_SUS_POT_OFFSET = 150.8 ;
101101
@@ -125,7 +125,7 @@ namespace VCFSystemConstants {
125125 constexpr uint32_t ACCEL_MAX_SENSOR_PEDAL_2 = 4000 ;
126126 constexpr float ACCEL_DEADZONE_MARGIN = 0 .03f ;
127127 constexpr float ACCEL_MECHANICAL_ACTIVATION_PERCENTAGE = 0 .05f ;
128-
128+
129129 constexpr uint32_t BRAKE_1_MIN_ADDR = 16 ;
130130 constexpr uint32_t BRAKE_2_MIN_ADDR = 20 ;
131131 constexpr uint32_t BRAKE_1_MAX_ADDR = 24 ;
@@ -137,6 +137,30 @@ namespace VCFSystemConstants {
137137 constexpr uint32_t BRAKE_MAX_SENSOR_PEDAL_2 = 4000 ;
138138 constexpr float BRAKE_DEADZONE_MARGIN = 0 .04f ;
139139 constexpr float BRAKE_MECHANICAL_ACTIVATION_PERCENTAGE = 0 .5f ;
140+
141+ // Steering System Constants
142+ constexpr uint32_t MIN_STEERING_SIGNAL_ANALOG_ADDR = 56 ; // Raw ADC value from analog sensor at minimum (left) steering angle (calibration)
143+ constexpr uint32_t MAX_STEERING_SIGNAL_ANALOG_ADDR = 60 ; // Raw ADC value from analog sensor at maximum (right) steering angle
144+ constexpr uint32_t MIN_STEERING_SIGNAL_DIGITAL_ADDR = 32 ; // Raw ADC value from digital sensor at minimum (left) steering angle
145+ constexpr uint32_t MAX_STEERING_SIGNAL_DIGITAL_ADDR = 36 ; // Raw ADC value from digital sensor at maximum (right) steering angle
146+
147+ constexpr int32_t ANALOG_MIN_WITH_MARGINS_ADDR = 40 ;
148+ constexpr int32_t ANALOG_MAX_WITH_MARGINS_ADDR = 44 ;
149+ constexpr int32_t DIGITAL_MIN_WITH_MARGINS_ADDR = 48 ;
150+ constexpr int32_t DIGITAL_MAX_WITH_MARGINS_ADDR = 52 ;
151+
152+
153+ // implausibility values
154+ constexpr float ANALOG_TOLERANCE = 0 .05f ; // +- 0.5% error (analog sensor tolerance according to datasheet)
155+ constexpr float DIGITAL_TOLERANCE = 0 .05f ; // +- 0.2 degrees error
156+ constexpr float ERROR_BETWEEN_SENSORS_TOLERANCE = 5 .0f ;
157+
158+ // rate of angle change
159+ constexpr float MAX_DTHETA_THRESHOLD = 50 .0f ; // maximum change in angle since last reading to consider the reading valid
160+
161+ // degrees per bit
162+ constexpr float DEG_PER_COUNT_DIGITAL = 360 .0f / 16384 .0f ;
163+ constexpr float DEG_PER_COUNT_ANALOG = 360 .0f / 3686 .4f ;
140164}
141165
142166// software configuration constants
@@ -150,45 +174,52 @@ namespace VCFTaskConstants {
150174 constexpr unsigned long CAN_SEND_PRIORITY = 10 ;
151175 constexpr unsigned long CAN_SEND_PERIOD = 2000 ; // 2 000 us = 500 Hz
152176
153- constexpr unsigned long PEDALS_PRIORITY = 5 ;
154- constexpr unsigned long PEDALS_SEND_PERIOD = 4000 ; // 4 000 us = 250 Hz
155- constexpr unsigned long PEDALS_SAMPLE_PERIOD = 500 ; // 500 us = 2 kHz
156-
157- constexpr unsigned long PEDALS_RECALIBRATION_PRIORITY = 150 ;
158- constexpr unsigned long PEDALS_RECALIBRATION_PERIOD = 100000 ; // 100 000 us = 10 Hz
159-
177+
160178 constexpr unsigned long BUZZER_PRIORITY = 20 ;
161179 constexpr unsigned long BUZZER_WRITE_PERIOD = 100000 ; // 100 000 us = 10 Hz
162-
180+
163181 constexpr unsigned long DASH_SAMPLE_PRIORITY = 21 ;
164182 constexpr unsigned long DASH_SAMPLE_PERIOD = 100000 ; // 100 000 us = 10 Hz
165-
183+
166184 constexpr unsigned long DASH_SEND_PRIORITY = 7 ;
167185 constexpr unsigned long DASH_SEND_PERIOD = 100000 ; // 100 000 us = 10 Hz
168-
186+
169187 constexpr unsigned long DEBUG_PRIORITY = 100 ;
170188 constexpr unsigned long DEBUG_PERIOD = 10000 ; // 10 000 us = 2 Hz
171-
189+
172190 constexpr unsigned long NEOPIXEL_UPDATE_PRIORITY = 90 ;
173191 constexpr unsigned long NEOPIXEL_UPDATE_PERIOD = 100000 ; // 100 000 us = 10 Hz
174-
175- constexpr unsigned long STEERING_SEND_PRIORITY = 25 ;
176- constexpr unsigned long STEERING_SEND_PERIOD = 4000 ; // 4 000 us = 250 Hz
177-
192+
193+
178194 constexpr unsigned long LOADCELL_SAMPLE_PRIORITY = 24 ;
179195 constexpr unsigned long LOADCELL_SAMPLE_PERIOD = 250 ; // 250 us = 4 kHz
180-
196+ constexpr unsigned long LOADCELL_SEND_PRIORITY = 25 ;
197+ constexpr unsigned long LOADCELL_SEND_PERIOD = 4000 ; // 4 000 us = 250 Hz
198+
181199 constexpr unsigned long ETHERNET_SEND_PRIORITY = 20 ;
182200 constexpr unsigned long ETHERNET_SEND_PERIOD = 100000 ; // 100 000 us = 10Hz
201+
202+ constexpr unsigned long PEDALS_PRIORITY = 5 ;
203+ constexpr unsigned long PEDALS_SEND_PERIOD = 4000 ; // 4 000 us = 250 Hz
204+ constexpr unsigned long PEDALS_SAMPLE_PERIOD = 500 ; // 500 us = 2 kHz
205+
206+ constexpr unsigned long PEDALS_RECALIBRATION_PRIORITY = 150 ;
207+ constexpr unsigned long PEDALS_RECALIBRATION_PERIOD = 100000 ; // 100 000 us = 10 Hz
183208
184- constexpr unsigned long LOADCELL_SEND_PRIORITY = 25 ;
185- constexpr unsigned long LOADCELL_SEND_PERIOD = 4000 ; // 4 000 us = 250 Hz
209+ constexpr unsigned long STEERING_SEND_PRIORITY = 25 ;
210+ constexpr unsigned long STEERING_SEND_PERIOD = 4000 ; // 4 000 us = 250 Hz
186211
212+ constexpr unsigned long STEERING_SAMPLE_PERIOD = 1000 ; // 2000 us = 500 Hz
213+ constexpr unsigned long STEERING_SAMPLE_PRIORITY = 10 ;
214+
215+ constexpr unsigned long STEERING_RECALIBRATION_PRIORITY = 150 ;
216+ constexpr unsigned long STEERING_RECALIBRATION_PERIOD = 100000 ;
217+
187218 // IIR filter alphas
188219 constexpr float LOADCELL_IIR_FILTER_ALPHA = 0 .01f ;
189220
190221 constexpr unsigned long WATCHDOG_PRIORITY = 1 ;
191222 constexpr unsigned long WATCHDOG_KICK_PERIOD = 10000 ; // 10 000 us = 100 Hz
192223}
193224
194- #endif /* VCF_CONSTANTS */
225+ #endif /* VCF_CONSTANTS */
0 commit comments