Oil pump temp and internal oil temp have vastly different sensors to MG1 and MG2 and will need different biasing resistors to suit.
The measurement is not trivial, the resistance is not a linear curve. It will follow a Steinhart-Hart function, the coefficients of which must be found through experimentation (measuring the resistance at known temperatures). Since the transmission will not fit in an oven or fridge, this will have to be done in ambient temperatures, giving a small range of readings. In reality, you want a reading from each extreme end of the desired scale and one in the middle.
In the GS450h, the motor temperatures often exceeded 70C.
https://www.thinksrs.com/downloads/pdfs ... ulator.pdf
I wrote a SHH function and some associated bits with this, never got the A B or C values sorted though. Here's a snip from my cooling code, this isn't active yet in my project, I just run pumps at full and fans at full when radiator water temp gets above 40C.
Code: Select all
//temperature sensors = final temps are in main file.
//#define TEMP_MG1 0 //these are in main file, just here for reference
//#define TEMP_MG2 1
//#define TEMP_TRANS 2
//#define TEMP_OIL 3
//#define TEMP_INSIDE 4
//#define TEMP_RAD 5
//#define TEMP_HEATER 6
//#define TEMP_OUTSIDE 7
float ntc_temp[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; //temperature output in c
uint16_t ntc_raw[8] = {0, 0, 0, 0, 0, 0, 0, 0}; //0 to 1023 input
float ntc_ohms[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; // R1* (1023.0 / (float)ntc_raw - 1.0};
float ntc_bias[8] = {249000, 249000, 18000, 680000, 100000, 10000, 15000, 100000}; //bias resistor in ohms
float log_ntc_ohms[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; //working variable
float ntc_a[8] = {1.484778004e-03, 1.484778004e-03, 1.484778004e-03, 1.484778004e-03, 1.484778004e-03, 1.484778004e-03, 1.484778004e-03, 1.484778004e-03}; //steinhart-hart function
float ntc_b[8] = {2.348962910e-04, 2.348962910e-04, 2.348962910e-04, 2.348962910e-04, 2.348962910e-04, 2.348962910e-04, 2.348962910e-04, 2.348962910e-04}; //steinhart-hart function
float ntc_c[8] = {1.006037158e-07, 1.006037158e-07, 1.006037158e-07, 1.006037158e-07, 1.006037158e-07, 1.006037158e-07, 1.006037158e-07, 1.006037158e-07}; //steinhart-hart function
void process_ntc(uint8_t i)
{
//at this point, we have already read ntc_raw from the input
ntc_ohms[i] = ntc_bias[i] * (1023.0 / (float)ntc_raw[i] - 1.0);
log_ntc_ohms[i] = log(ntc_ohms[i]);
ntc_temp[i] = (1.0 / (ntc_a[i] + ntc_b[i] * log_ntc_ohms[i] + ntc_c[i] * log_ntc_ohms[i] * log_ntc_ohms[i] * log_ntc_ohms[i]));
ntc_temp[i] -= 273.15;
if (ntc_temp[i]>200)ntc_temp[i]=200;
if (ntc_temp[i]<-200)ntc_temp[i]=-200;
}
void run_cooling()
{
ntc_raw[TEMP_MG1] = analogRead(pin_temp_mg1);
ntc_raw[TEMP_MG2] = analogRead(pin_temp_mg2);
ntc_raw[TEMP_TRANS] = analogRead(pin_temp_trans);
ntc_raw[TEMP_HEATER] = analogRead(pin_temp_heater);
//demux: oil is Y5=1, radin is Y4=0, radout is Y6=2, outside is Y7=3
ntc_raw[TEMP_INSIDE] = demux(0);
ntc_raw[TEMP_OIL] = demux(1);
ntc_raw[TEMP_RAD] = demux(2);
ntc_raw[TEMP_OUTSIDE] = demux(3);
//temp_dcdc1 and 2 are from CAN bus
//6x module temps and 3x inlet temps from charger over CAN bus
//battery temps from CAN bus
//inverter temps from MTH
for (int i = 0; i < 8; i++)
{
if (ntc_raw[i] > 0 && ntc_raw[i] < 1023) process_ntc(i);
else ntc_temp[i] = 0.0f;
}