Part Number: MSP430FR6989 I am trying the basic thermistor program using my launchpad and I am having trouble using the log() function. When I take the log() of the variable I received an error. I then used logf() of the variable and the program compiled and downloaded to the board but the value was incorrect. What am I doing wrong here? int Vo_raw; float R1 = 10000; float logR2, R_t, T, Vo_volt; float c1 = 1.12924e-03, c2 = 2.34108e-04, c3 = 0.87755e-07; void setup() { pinMode(23, INPUT); Serial.begin(9600); } void loop() { Vo_raw = analogRead(23);//V_out signal from board Vo_volt = Vo_raw * 3.3/4096; //convert from signal to volts R_t = (3.3*R1)/Vo_volt - R1 ; //voltage divider equation to determine resistance logR2 = logf(Vo_volt); //take log of voltage T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); //thermistor equation T = T - 273.15; //celsius to kelvin T = (T * 9.0)/ 5.0 + 32.0; //kelvin to F Serial.print("log(Resist): "); Serial.print(logR2); Serial.print("; Temp: "); Serial.print(T); Serial.print("; Resistance: "); Serial.print(R_t); Serial.print("; Volts: "); Serial.println(Vo_volt); delay(1000); }
↧