
其中 B 、R25在NTC spec中可以查看到。
Rup在ADC采样电路原理图中查看
- #include
- #include
-
- //12bit ADC
- int main()
- {
- /* Write C code in this online editor and run it. */
- printf("Hello, World! \n");
- int adc = 0;
- int B = 3975;//3975K
- int R25 = 10000; //10K
- int Rup = 15000; //15K
- float Rt;
- float cacl;
-
- for(adc =0;adc < 4096;adc++)
- {
- Rt = ((adc * Rup) /(4096 - adc));
- cacl = (B*298.15/(298.15*log(Rt/R25) + B)) - 273.15;
- printf("%d %f %f \n",adc,Rt,cacl);
- }
-
-
-
-
- return 0;
- }