You are here

Add another motor temperature sensor type (only minor tweak needed)

2 posts / 0 new
Last post
Henque19
Offline
Last seen: 3 years 6 months ago
VESC Original
Joined: 2019-05-22 10:14
Posts: 17
Add another motor temperature sensor type (only minor tweak needed)

TLDR: Please add sensor type "PTC 1K at 25oC" to the list of motor senors. Same as "PTC 1K at 100oC", but as name implies: 1Kohm resistance at 25 degrees instead of 100 degrees.

More details: My motor temp sensor is a "KTY-83". The "KTY-84" is supported, so only a very minor change to firmware is needed (the KTY-83 is mentioned in "mc_interface.c", but not used as far as I can tell). I've hade a look in the code, there is a function called "PTC_TEMP_MOTOR" defined in "hwconf/hw.h":

#define PTC_TEMP_MOTOR(res, con, tbase)			(((NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR]) - res) / res) * 100 / con + tbase)

The "tbase" parameter seems to be the base temperature that would be 25 degrees in my case. So to add this feature, it seems a new case in "mc_interface.c" is needed (as below) and an added element in the VESC tool.

	UTILS_LP_FAST(m_temp_fet, NTC_TEMP(ADC_IND_TEMP_MOS), 0.1);
	switch(conf->m_motor_temp_sens_type) {
	case TEMP_SENSOR_NTC_10K_25C:
		UTILS_LP_FAST(m_temp_motor, NTC_TEMP_MOTOR(conf->m_ntc_motor_beta), 0.1);
		break;
	case TEMP_SENSOR_PTC_1K_100C:
		{
			float temp = PTC_TEMP_MOTOR(1000.0, conf->m_ptc_motor_coeff, 100);

                	if (UTILS_IS_NAN(temp) || UTILS_IS_INF(temp) || temp > 600.0) {
                        	temp = 180.0;
                	}

                	UTILS_LP_FAST(m_temp_motor, temp, 0.1);
		}
		break;
	case TEMP_SENSOR_PTC_1K_25C:
		{
			float temp = PTC_TEMP_MOTOR(1000.0, conf->m_ptc_motor_coeff, 25);

                	if (UTILS_IS_NAN(temp) || UTILS_IS_INF(temp) || temp > 600.0) {
                        	temp = 180.0;
                	}

                	UTILS_LP_FAST(m_temp_motor, temp, 0.1);
		}
		break;
	}

I hope this is a minor feature that is relatively simple to implement. Thanks for all the awesome work you do, the latest position tracking at zero speed is black magic!

Henque19
Offline
Last seen: 3 years 6 months ago
VESC Original
Joined: 2019-05-22 10:14
Posts: 17

It seems that the KTY-83 sensor has been added in the latest update, awesome! Thank you so much!!