Files
protocol_convert_software_BD3/test/test_cal.py

50 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from math import log
Rr = 10000.0
A = -6.01188
B = 4622.53337
C = -86421.72414
R=13226
t= 2*C/((B**2-4*C*(A-log(R)))**0.5-B)-273.15
print(R,t)
x=9.0878
y= -0.112*x**3+4.8477*x**2-85.572*x+489.01
print(y)
A=0.4116
B=0.931
C=-9
y= (-B+ (B**2-4*A*C)**0.5)/2/A
print(y)
y=359 #180
combined = round(y / 0.00205479)
low16 = combined & 0xFFFF
high4 = (combined >> 16) & 0xF
#d = (high4 << 16) | low16
d = (low16 << 16) | (high4 << 0)
print(f"特殊公式8反推y={y} low16={hex(low16)}high4 = {hex(high4)}, d={hex(d)}")
# y = 30
# if y < (0.0973 * 1840 + 180): # 区间1y < 359.032
# m = (y - 180) / 0.0973
# elif y > (0.0974 * 1840 - 179.46): # 区间2y > -0.444
# m = (y + 179.46) / 0.0974
# else: # m=1840
# m = 1840.0
y = 150 #30240
if y < (180): # 区间1
m = (y + 179.46) / 0.0974
elif y > (180): # 区间2
m = (y - 180) / 0.0973
else: # m=1840
m = 0.0
print(f"特殊公式11-1反推y={y} d={ float(round(m))}")
# 组帧需要整数,返回四舍五入
#return float(round(m))