Red Light Racing

  • Increase font size
  • Default font size
  • Decrease font size

Engine Coolant Temperature Sensor

E-mail Print PDF

 /*
 * Lupo to Insight Engine Coolant Temperature (ECT) Conversion
 * by Jake Staub (1/9/09)
 *
 * Takes the Lupo ECT voltage signal, converts it to a temperature,
 * then turns the temperature into the required Insight resistance
 * value.
 * Lupo temp(volt) = a*volt^3 + b*volt^2 + c*x + d.
 * Insight res(temp) = e*f^(g*temp).
 */

int ECTvolt = 2;   // Lupo IAT sensor input pin
int val = 0;       // variable to store the ADC value coming from the Lupo ECT sensor
float volt = 0;    // variable to store Lupo voltage value
int fractional;    // variable to store fractional Lupo voltage value
int temp = 0;      // variable to store Lupo calculated temperature value
int res = 0;       // variable to strore Insight calculated resistance value
float a = -5.77;   // constant derived from Lupo temp vs. voltage curve fit
int b = 48;        // constant derived from Lupo temp vs. voltage curve fit
int c = -171;      // constant derived from Lupo temp vs. voltage curve fit
int d = 345;       // constant derived from Lupo temp vs. voltage curve fit
int e = 9272;      // constant derived from Insight res vs. temp curve fit
float f = 2.718;   // natural number
float g = -0.0182; // constant derived from Insight res vs. temp curve fit

void setup() {
  Serial.begin(9600);  // opens serial port for debugging
}

void loop() {
  val = analogRead(ECTvolt);                // reads the value from the sensor
  volt = val / 204.8;                       // converts digital val to analog volt
  val = val / 205;                          // converts digital val to analog val
  fractional = (volt - val)*1000;           // calculates decimal voltage value
  Serial.print("volt = ");                  // prints "volt = "
  Serial.print(val);                        // prints integer volt value
  Serial.print(".");                        // prints "."
  Serial.println(fractional);               // prints decimal volt value
  delay(3000);                              // 3 second delay (3000 ms)
  temp = a*pow(volt,3) + b*pow(volt,2) +
  c*volt + d;                               // Lupo temperature as a function of voltage
  Serial.print("temp = ");                  // prints "temp = "
  Serial.println(temp);                     // prints analog temperature value
  delay(3000);                              // 3 second delay (3000 ms) 
  res = e*pow(f,(g*temp));                  // Insight resistance as a function of temperature
  if (res < 30)                             // resistance limit
  {res = 30;}
  Serial.print("res = ");                   // prints "res = "
  Serial.println(res);                      // prints analog resistance value
  delay(3000);                              // 3 second delay (3000 ms)
 }

 

Donate

Help us shake things up!

Powered by easy paypal donation

User Login

Countdown to Bonneville

 
 Auto X-Prize Contender