Skip to content

Commit 1366186

Browse files
committed
Added individual LIM temps
1 parent 8144a15 commit 1366186

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Common/Inc/config.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ const Data_Segment_t BMS_ERROR_CODE = {BMS_BOARD, 8, 8};
5555

5656
// BEGIN SENSORS BOARD DEFS
5757
//FIRST FRAME
58-
const Data_Segment_t PRESSURE = {SENSOR_BOARD_1, 1, 2};
59-
const Data_Segment_t LIM_ONE_TEMP = {SENSOR_BOARD_1, 3, 3};
60-
const Data_Segment_t LIM_TWO_TEMP = {SENSOR_BOARD_1, 4, 4};
58+
const Data_Segment_t PRESSURE = {SENSOR_BOARD_1, 1, 1};
59+
const Data_Segment_t LIM_ONE_TEMP_ONE = {SENSOR_BOARD_1, 2, 2};
60+
const Data_Segment_t LIM_ONE_TEMP_TWO = {SENSOR_BOARD_1, 3, 3};
61+
const Data_Segment_t LIM_ONE_TEMP_THREE = {SENSOR_BOARD_1, 4, 4};
62+
const Data_Segment_t LIM_TWO_TEMP_ONE = {SENSOR_BOARD_1, 5, 5};
63+
const Data_Segment_t LIM_ONE_TEMP_TWO = {SENSOR_BOARD_1, 6, 6};
64+
const Data_Segment_t LIM_TWO_TEMP_THREE = {SENSOR_BOARD_1, 7, 7};
6165
const Data_Segment_t SENSORS_ERROR_CODE_1 = {SENSOR_BOARD_1, 8, 8};
6266
//SECOND (IMU) FRAME
6367
const Data_Segment_t X_ACCEL = {SENSOR_BOARD_2, 1, 2};

Sensors/Core/Src/lim.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "adc.h"
1010
#include <math.h>
1111

12-
void get_lim_data(uint8_t lim_temps[NUM_LIMS]) {
12+
void get_lim_data(uint8_t lim_temps[NUM_THERM_TOTAL]) {
1313
for (uint8_t i = 0; i < NUM_LIMS; i++) {
1414
lim_temps[i] = 0;
1515
}
@@ -23,14 +23,13 @@ void get_lim_data(uint8_t lim_temps[NUM_LIMS]) {
2323
HAL_ADC_PollForConversion(&hadc3, 100);
2424
uint16_t adc_data = HAL_ADC_GetValue(&hadc3);
2525

26-
uint8_t avg_temp = (get_temp(adc_data) / NUM_THERM_PER_LIM);
27-
lim_temps[i < 3 ? 0 : 1] += avg_temp;
26+
lim_temps[i] += get_temp(adc_data);
2827
}
2928
}
3029

3130
uint8_t get_temp(uint16_t adc_value) {
32-
uint32_t voltage_in = adc_value * (MAX_VOLTAGE / MAX_ADC_COUNT);
33-
uint32_t thermistor_resistance = (voltage_in * R10K) / (VOLTAGE_SUPPLY - voltage_in);
31+
float voltage_in = adc_value * (MAX_VOLTAGE / MAX_ADC_COUNT);
32+
float thermistor_resistance = (voltage_in * R10K) / (VOLTAGE_SUPPLY - voltage_in);
3433

3534
uint8_t temp_steinhart = -ABSOLUTE_ZERO + (NOMINAL_TEMPERATURE * B_COEFFICIENT)/(NOMINAL_TEMPERATURE
3635
* log(thermistor_resistance / R10K) + B_COEFFICIENT);

Sensors/Core/Src/main.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int main(void)
105105
int8_t x_gyro = 0;
106106
int8_t y_gyro = 0;
107107
int8_t z_gyro = 0;
108-
uint8_t lim_temps[NUM_LIMS];
108+
uint8_t lim_temps[NUM_THERM_TOTAL];
109109
uint8_t error_code_1 = 0;
110110
uint8_t error_code_2 = 0;
111111

@@ -129,8 +129,12 @@ int main(void)
129129

130130
//Pack CAN messages
131131
CAN_set_segment(&tx_frame, PRESSURE, pressure);
132-
CAN_set_segment(&tx_frame, LIM_ONE_TEMP, lim_temps[0]);
133-
CAN_set_segment(&tx_frame, LIM_TWO_TEMP, lim_temps[1]);
132+
CAN_set_segment(&tx_frame, LIM_ONE_TEMP_ONE, lim_temps[0]);
133+
CAN_set_segment(&tx_frame, LIM_ONE_TEMP_TWO, lim_temps[1]);
134+
CAN_set_segment(&tx_frame, LIM_ONE_TEMP_THREE, lim_temps[2]);
135+
CAN_set_segment(&tx_frame, LIM_TWO_TEMP_ONE, lim_temps[3]);
136+
CAN_set_segment(&tx_frame, LIM_TWO_TEMP_TWO, lim_temps[4]);
137+
CAN_set_segment(&tx_frame, LIM_TWO_TEMP_THREE, lim_temps[5]);
134138
CAN_set_segment(&tx_frame, SENSORS_ERROR_CODE_1, error_code_1);
135139

136140
CAN_set_segment(&imu_frame, X_ACCEL, x_accel);

0 commit comments

Comments
 (0)