-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata_conversions.py
61 lines (47 loc) · 1.29 KB
/
data_conversions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import math
def thermistorConversion(x):
# Thermistor Constants
A = 1.403 * 0.001
B = 2.373 * 0.0001
C = 9.827 * 0.00000001
try:
V = x * 5 / (2**10)
R = 2956 / ((4.945 / V) - 1)
if R > 0:
T = 1 / (A + B * math.log(R) + C * (math.log(R)) ** 3)
else:
T = 0
except ZeroDivisionError as e:
T = 0
return round(T - 273.15, 2)
def thermistor2Conversion(x):
# Thermistor Constants
A = 1.468 * 0.001
B = 2.383 * 0.0001
C = 1.007 * 0.0000001
try:
V = x * 5 / (2**10)
R = 2948 / ((4.945 / V) - 1)
if R > 0:
T = 1 / (A + B * math.log(R) + C * (math.log(R)) ** 3)
else:
T = 0
except ZeroDivisionError as e:
T = 0
return round(T - 273.15, 2)
def thermocouple3Conversion(x):
return x/1000
# im being lazy -antoine
def pressureConversion(x):
minVoltage = 1.0
maxVoltage = 5.0
minPressure = 0.0
maxPressure = 1000.0
voltage = x * 0.000188
raw = (voltage - minVoltage) * (maxPressure - minPressure) / (
maxVoltage - minVoltage
) + minPressure
corrected = raw # insert calibration code here
return round(corrected, 2)
def loadCell2Conversion(x):
return round((x/1024) * (500/2.2), 2)