Created
January 7, 2016 18:49
-
-
Save spot62/6708e990b20c63505aa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
struct point { | |
int t; | |
double R; | |
}; | |
const struct point NCP18XH103F03RB_10K[]={ | |
{ .t=1250, .R= 0.531 }, | |
{ .t=1200, .R= 0.596 }, | |
{ .t=1150, .R= 0.672 }, | |
{ .t=1100, .R= 0.758 }, | |
{ .t=1050, .R= 0.858 }, | |
{ .t=1000, .R= 0.974 }, | |
{ .t= 950, .R= 1.110 }, | |
{ .t= 900, .R= 1.268 }, | |
{ .t= 850, .R= 1.452 }, | |
{ .t= 800, .R= 1.669 }, | |
{ .t= 750, .R= 1.925 }, | |
{ .t= 700, .R= 2.228 }, | |
{ .t= 650, .R= 2.586 }, | |
{ .t= 600, .R= 3.014 }, | |
{ .t= 550, .R= 3.535 }, | |
{ .t= 500, .R= 4.161 }, | |
{ .t= 450, .R= 4.917 }, | |
{ .t= 400, .R= 5.834 }, | |
{ .t= 350, .R= 6.948 }, | |
{ .t= 300, .R= 8.315 }, | |
{ .t= 250, .R= 10.000 }, | |
{ .t= 200, .R= 12.081 }, | |
{ .t= 150, .R= 14.674 }, | |
{ .t= 100, .R= 17.926 }, | |
{ .t= 50, .R= 22.021 }, | |
{ .t= 0, .R= 27.219 }, | |
{ .t= -50, .R= 33.892 }, | |
{ .t=-100, .R= 42.506 }, | |
{ .t=-150, .R= 53.650 }, | |
{ .t=-200, .R= 68.237 }, | |
{ .t=-250, .R= 87.559 }, | |
{ .t=-300, .R=113.347 }, | |
{ .t=-350, .R=148.171 }, | |
{ .t=-400, .R=195.652 }, | |
{ .t=-450, .R=261.000 }, | |
{ .t=-500, .R=352.000 }, | |
{ .t=-550, .R=484.000 } | |
}; | |
const size_t NCP18XH103F03RB_10K_SZ = sizeof(NCP18XH103F03RB_10K)/sizeof(struct point); | |
const double ADCVREF = 2.5; | |
const size_t ADCRES = 12; | |
int main() | |
{ | |
const double ADCVONE = ADCVREF/(1<<ADCRES); | |
size_t n; | |
printf("termistor:\n"); | |
for(n=0;n<NCP18XH103F03RB_10K_SZ;n++) | |
{ | |
double i = ADCVREF / ( 10. + NCP18XH103F03RB_10K[n].R); | |
double vout = i*10.; | |
printf("\t{\t%u,\t%4i }, /* T=%3iC R=%3.3fK Uadc=%1.5fV */\n", (unsigned)(vout/ADCVONE), NCP18XH103F03RB_10K[n].t, | |
(unsigned)(0.1*NCP18XH103F03RB_10K[n].t), NCP18XH103F03RB_10K[n].R, vout); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment