]>
Commit | Line | Data |
---|---|---|
ec56fabb MF |
1 | import piplates.DAQCplate as DAQC |
2 | import time | |
3 | from decimal import Decimal | |
4 | DAQC.setDOUTbit(0,0) | |
5 | #thermistor reading function | |
6 | def compressor(state=None): | |
7 | if state==None: | |
8 | return DAQC.getDOUTbyte(0) | |
9 | if state==True: | |
10 | DAQC.setDOUTbit(0,0) | |
11 | if state==False: | |
12 | DAQC.clrDOUTbit(0,0) | |
13 | ||
14 | def temp_get(volts,supply_voltage=5): | |
15 | divider_resistor=10000 | |
16 | ohms = Decimal(divider_resistor*supply_voltage/volts-divider_resistor) #calculate the ohms of the thermisttor | |
17 | #IVT oem NTC | |
18 | a = Decimal(1.298022762e-3) | |
19 | b = Decimal(2.365068126e-4) | |
20 | c = Decimal(0.9305914923e-7) | |
21 | #Steinhart Hart Equation | |
22 | # T = 1/(a + b[ln(ohm)] + c[ln(ohm)]^3) | |
23 | temp = 1/(a + b*ohms.ln() + c*ohms.ln()**3) | |
24 | tempc = temp - Decimal(273.15) #K to C | |
25 | return tempc | |
26 | ||
27 | while(True): | |
28 | vv_retur=temp_get(DAQC.getADC(0,0),DAQC.getADC(0,8)) | |
29 | hetgas=temp_get(DAQC.getADC(0,1),DAQC.getADC(0,8)) | |
30 | print("VV retur:",vv_retur) | |
31 | print("Hetgas:",hetgas) | |
32 | print("Kompressor:",compressor()) | |
33 | if vv_retur < 35: | |
34 | compressor(True) | |
35 | print("Returtemp under 35. Startar kompressor") | |
36 | if vv_retur > 45: | |
37 | compressor(False) | |
38 | print("Returtemp över 45. Stänger av kompressor") | |
39 | # import pdb;pdb.set_trace() | |
40 | time.sleep(1) | |
41 |