Advertisement
natsfr

Thermistor Validation

Nov 22nd, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.71 KB | None | 0 0
  1. clear;
  2.  
  3. // LEFT Column = Temperature
  4. // RIGHT Column = Resistance (in kOhm)
  5. meas_values = csvRead("./thermistor.csv", ";", "double");
  6.  
  7. BETA = 3910;
  8.  
  9. KELVIN = 273.15;
  10.  
  11. T0 = 298.15; // Kelvin (25 °C)
  12. R0 = 100000; // ohm @ T0
  13.  
  14. meas_temp = meas_values(:,1);
  15. meas_res = meas_values(:,2) * 1000;
  16.  
  17. calc_temp = (1 ./ ((1/T0)+(1/BETA)*(log(meas_res/R0)))) - KELVIN;
  18.  
  19. Rfix = 1000;
  20. VCC = 5;
  21. adc_step = VCC/1024;
  22.  
  23. // Calculate ADC output val
  24. exp_val = ((meas_res ./ (Rfix + meas_res))*5) ./ adc_step;
  25.  
  26. subplot(311);
  27. plot(meas_res, calc_temp, "green");
  28. plot(meas_res, meas_temp, "red");
  29.  
  30. subplot(312);
  31. plot(meas_temp, exp_val, "blue");
  32.  
  33. subplot(313);
  34. plot(meas_temp, meas_temp - calc_temp, "green");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement