Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- // LEFT Column = Temperature
- // RIGHT Column = Resistance (in kOhm)
- meas_values = csvRead("./thermistor.csv", ";", "double");
- BETA = 3910;
- KELVIN = 273.15;
- T0 = 298.15; // Kelvin (25 °C)
- R0 = 100000; // ohm @ T0
- meas_temp = meas_values(:,1);
- meas_res = meas_values(:,2) * 1000;
- calc_temp = (1 ./ ((1/T0)+(1/BETA)*(log(meas_res/R0)))) - KELVIN;
- Rfix = 1000;
- VCC = 5;
- adc_step = VCC/1024;
- // Calculate ADC output val
- exp_val = ((meas_res ./ (Rfix + meas_res))*5) ./ adc_step;
- subplot(311);
- plot(meas_res, calc_temp, "green");
- plot(meas_res, meas_temp, "red");
- subplot(312);
- plot(meas_temp, exp_val, "blue");
- subplot(313);
- plot(meas_temp, meas_temp - calc_temp, "green");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement