Skip to content

Commit 210ec40

Browse files
committed
PTC motor thermistor support, APP_PPM sleep fix
1 parent 5e4f675 commit 210ec40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+47
-4
lines changed

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
=== FW 3.65 ===
2+
* Added support for PTC motor temperature sensor (e.g. KTY84)
3+
* APP_PPM sleep fix. Should solve CAN issues.
4+
15
=== FW 3.64 ===
26
* Added support for HW60_MK3
37
* Disable shutdown sampling when the watchdog runs slowly.

applications/app_ppm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static THD_FUNCTION(ppm_thread, arg) {
120120
is_running = true;
121121

122122
for(;;) {
123-
chEvtWaitAnyTimeout((eventmask_t)1, ST2MS(2));
123+
chEvtWaitAnyTimeout((eventmask_t)1, MS2ST(2));
124124

125125
if (stop_now) {
126126
is_running = false;
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_0005ohm.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_33k.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_ws2811_33k.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_0005ohm.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/60/VESC_default.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/60/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/60/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/60_MK3/VESC_default.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/60_MK3/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/60_MK3/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/75_300/VESC_default.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/75_300/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/75_300/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/75_300_R2/VESC_default.bin

0 Bytes
Binary file not shown.
Binary file not shown.

build_all/75_300_R2/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/75_300_R2/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/A200S_V21/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/A200S_V22/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/AXIOM/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/DAS_RS/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/HD/VESC_default.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/HD/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/HD/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/UAVC_OMEGA/VESC_default.bin

0 Bytes
Binary file not shown.

conf_general.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
// Firmware version
2424
#define FW_VERSION_MAJOR 3
25-
#define FW_VERSION_MINOR 64
25+
#define FW_VERSION_MINOR 65
2626

2727
#include "datatypes.h"
2828

confgenerator.c

+6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *
130130
buffer_append_float32_auto(buffer, conf->m_dc_f_sw, &ind);
131131
buffer_append_float32_auto(buffer, conf->m_ntc_motor_beta, &ind);
132132
buffer[ind++] = conf->m_out_aux_mode;
133+
buffer[ind++] = conf->m_motor_temp_sens_type;
134+
buffer_append_float32_auto(buffer, conf->m_ptc_motor_coeff, &ind);
133135
buffer[ind++] = (uint8_t)conf->si_motor_poles;
134136
buffer_append_float32_auto(buffer, conf->si_gear_ratio, &ind);
135137
buffer_append_float32_auto(buffer, conf->si_wheel_diameter, &ind);
@@ -394,6 +396,8 @@ bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *c
394396
conf->m_dc_f_sw = buffer_get_float32_auto(buffer, &ind);
395397
conf->m_ntc_motor_beta = buffer_get_float32_auto(buffer, &ind);
396398
conf->m_out_aux_mode = buffer[ind++];
399+
conf->m_motor_temp_sens_type = buffer[ind++];
400+
conf->m_ptc_motor_coeff = buffer_get_float32_auto(buffer, &ind);
397401
conf->si_motor_poles = buffer[ind++];
398402
conf->si_gear_ratio = buffer_get_float32_auto(buffer, &ind);
399403
conf->si_wheel_diameter = buffer_get_float32_auto(buffer, &ind);
@@ -654,6 +658,8 @@ void confgenerator_set_defaults_mcconf(mc_configuration *conf) {
654658
conf->m_dc_f_sw = MCCONF_M_DC_F_SW;
655659
conf->m_ntc_motor_beta = MCCONF_M_NTC_MOTOR_BETA;
656660
conf->m_out_aux_mode = MCCONF_M_OUT_AUX_MODE;
661+
conf->m_motor_temp_sens_type = MCCONF_M_MOTOR_TEMP_SENS_TYPE;
662+
conf->m_ptc_motor_coeff = MCCONF_M_PTC_MOTOR_COEFF;
657663
conf->si_motor_poles = MCCONF_SI_MOTOR_POLES;
658664
conf->si_gear_ratio = MCCONF_SI_GEAR_RATIO;
659665
conf->si_wheel_diameter = MCCONF_SI_WHEEL_DIAMETER;

confgenerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <stdbool.h>
99

1010
// Constants
11-
#define MCCONF_SIGNATURE 793836781
11+
#define MCCONF_SIGNATURE 2967846088
1212
#define APPCONF_SIGNATURE 783041200
1313

1414
// Functions

datatypes.h

+8
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ typedef enum {
6464
OUT_AUX_MODE_UNUSED
6565
} out_aux_mode;
6666

67+
// Temperature sensor type
68+
typedef enum {
69+
TEMP_SENSOR_NTC_10K_25C = 0,
70+
TEMP_SENSOR_PTC_1K_100C
71+
} temp_sensor_type;
72+
6773
// General purpose drive output mode
6874
typedef enum {
6975
GPD_OUTPUT_MODE_NONE = 0,
@@ -300,6 +306,8 @@ typedef struct {
300306
float m_dc_f_sw;
301307
float m_ntc_motor_beta;
302308
out_aux_mode m_out_aux_mode;
309+
temp_sensor_type m_motor_temp_sens_type;
310+
float m_ptc_motor_coeff;
303311
// Setup info
304312
uint8_t si_motor_poles;
305313
float si_gear_ratio;

hwconf/hw.h

+8
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@
364364
#define COMM_USE_USB 1
365365
#endif
366366

367+
#ifndef PTC_TEMP_MOTOR
368+
#if defined(NTC_RES_MOTOR) && defined(ADC_IND_TEMP_MOTOR)
369+
#define PTC_TEMP_MOTOR(res, con, tbase) (((NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR]) - res) / res) * 100 / con + tbase)
370+
#else
371+
#define PTC_TEMP_MOTOR(res, con, tbase) 0.0
372+
#endif
373+
#endif
374+
367375
// Functions
368376
void hw_init_gpio(void);
369377
void hw_setup_adc_channels(void);

mc_interface.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "comm_can.h"
3838
#include "shutdown.h"
3939
#include "app.h"
40+
#include "utils.h"
4041

4142
#include <math.h>
4243
#include <stdlib.h>
@@ -1747,7 +1748,17 @@ static void update_override_limits(volatile mc_configuration *conf) {
17471748
const float rpm_now = mc_interface_get_rpm();
17481749

17491750
UTILS_LP_FAST(m_temp_fet, NTC_TEMP(ADC_IND_TEMP_MOS), 0.1);
1750-
UTILS_LP_FAST(m_temp_motor, NTC_TEMP_MOTOR(conf->m_ntc_motor_beta), 0.1);
1751+
if (conf->m_motor_temp_sens_type == TEMP_SENSOR_NTC_10K_25C) {
1752+
UTILS_LP_FAST(m_temp_motor, NTC_TEMP_MOTOR(conf->m_ntc_motor_beta), 0.1);
1753+
} else if (conf->m_motor_temp_sens_type == TEMP_SENSOR_PTC_1K_100C) {
1754+
float temp = PTC_TEMP_MOTOR(1000.0, conf->m_ptc_motor_coeff, 100);
1755+
1756+
if (UTILS_IS_NAN(temp) || UTILS_IS_INF(temp) || temp > 600.0) {
1757+
temp = 180.0;
1758+
}
1759+
1760+
UTILS_LP_FAST(m_temp_motor, temp, 0.1);
1761+
}
17511762
#ifdef HW_VERSION_AXIOM
17521763
UTILS_LP_FAST(m_gate_driver_voltage, GET_GATE_DRIVER_SUPPLY_VOLTAGE(), 0.01);
17531764
#endif

mcconf/mcconf_default.h

+6
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,12 @@
402402
#ifndef MCCONF_M_OUT_AUX_MODE
403403
#define MCCONF_M_OUT_AUX_MODE OUT_AUX_MODE_OFF // Auxiliary output mode
404404
#endif
405+
#ifndef MCCONF_M_MOTOR_TEMP_SENS_TYPE
406+
#define MCCONF_M_MOTOR_TEMP_SENS_TYPE TEMP_SENSOR_NTC_10K_25C // Motor temperature sensor type
407+
#endif
408+
#ifndef MCCONF_M_PTC_MOTOR_COEFF
409+
#define MCCONF_M_PTC_MOTOR_COEFF 0.61 // %/K coefficient for motor PTC sensor
410+
#endif
405411

406412
// Setup Info
407413
#ifndef MCCONF_SI_MOTOR_POLES

0 commit comments

Comments
 (0)