在Python和C中Steinhart-Hart和Beta热敏电阻温度模型。实现和实用程序

thermistor-utils的Python项目详细描述


热敏电阻实用程序

基于python的库实现热敏电阻值转换的模型 从温度到电阻,反之亦然。在

斯坦哈特——哈特模型

实现精度

SH resistance to temperature chartSH temperature to resistance chart

如何使用

# import the Steinhart--Hart and or the Beta converterfromthermistor_utilsimportSH_converter

从a、B和C系数创建转换器:

^{pr2}$

如果它们不可用,转换器可以从 三个均匀分布的温度和电阻读数。在

根据温度/分辨率读数创建转换器:

readings=((0,27445),(25,10000),(50,4160),)conv=SH_converter.from_points(readings)

以适合后续使用的形式打印系数 python和C:

print(repr(conv))# SH_converter(0.0008402250578523375, 0.00025963477647737156, 1.5674403473853433e-07, 0, 50)print(conv.to_cstr())# {0.0008402250578523375, 0.00025963477647737156, 1.5674403473853433e-07, 0, 50}# compact but less precise representation# (inverse of coefficients and no temperature range)print(conv.to_cstr(compact=True,with_temps=False))# {1./1190, 1./3852, 1./6379828}

使用C中的参考实现(示例1.C):

#include<stdio.h>#include<thermistor_utils.h>intmain(void){structsh_scoefficients={0.0008402250578523375,0.00025963477647737156,1.5674403473853433e-07};// 25C to Ohm and 10k Ohm to CelsiusdoubleR_at_25=sh_resistance(coefficients,25),T_at_10000=sh_temperature(coefficients,10000);printf("25 Celsius -> %.0f Ohms\n",R_at_25);printf("10k Ohms   -> %.0f Celsius\n",T_at_10000);}

要从examples目录编译和运行:

$ mkdir -p ../bin
$ gcc -o ../bin/example-1 \
    -I../src/include \
    ../src/sh_converter.c \
    -lm \
    example-1.c

$ ../bin/example-1
25 Celsius -> 10000 Ohms
10k Ohms   -> 25 Celsius

贝塔模型

实现精度

Beta resistance to temperature chartBeta temperature to resistance chart

如何使用

# import the Steinhart--Hart and or the Beta converterfromthermistor_utilsimportBeta_converter

从beta值创建转换器:

beta,R0,T0=(3380,10000,25)conv=Beta_converter(beta,R0,T0)

以适合以后在中使用的形式打印beta值 python和C:

print(repr(conv))# Beta_converter(3380, 10000, 25)print(conv.to_cstr())# {3380, 10000, 25}

使用C中的参考实现(示例2.C):

#include<stdio.h>#include<thermistor_utils.h>intmain(void){structbeta_sbpar={3380,10000,25};// 25C to Ohm and 10k Ohm to CelsiusdoubleR_at_25=beta_resistance(bpar,25),T_at_10000=beta_temperature(bpar,10000);printf("25 Celsius -> %.0f Ohms\n",R_at_25);printf("10k Ohms   -> %.0f Celsius\n",T_at_10000);}

要从examples目录编译和运行:

$ mkdir -p ../bin
$ gcc -o ../bin/example-2 \
      -I../src/include \
      ../src/beta_converter.c \
      -lm \
      example-2.c

$ ../bin/example-2
25 Celsius -> 10000 Ohms
10k Ohms   -> 25 Celsius

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Leetcode移动零:我的bug在哪里?   Selenium WebDriver中隐式等待()中的java错误   macos如何从Java中访问资源文件。在OS X和Java 7上运行的应用程序包?   java setSelectionBackGround()不在jTable中设置颜色   java使用URL加载图像   JAVA在不删除空格的情况下拆分   java在Android上将Google+配置文件图片从Uri转换为位图   java我无法访问JSP页面中的modelmap值   javaaspose数据集。readXml生成更复杂的结构   java是否有任何方法可以查询用户是否存在于基于SAML的身份提供程序中?   java如何在每次添加文本时在listview一侧永久添加标题?   JavaJSP:我能呈现出比当前编写器输出更高的stringwriter吗?   JDK 8中的java Javadoc:无效的“不允许自关闭元素”