-
Notifications
You must be signed in to change notification settings - Fork 1
/
oven.py
59 lines (45 loc) · 1004 Bytes
/
oven.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
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM
import time
psu_pin = "P9_15"
fan_pin = "P9_14"
H1_pin = "P8_13"
H2_pin = "P9_42"
H1 = None
H2 = None
def oven_init():
fan_init()
psu_on()
def oven_cleanup():
PWM.cleanup()
GPIO.cleanup()
def fan_init():
PWM.start(fan_pin, 9, 100)
def fan_duty(duty):
if 9.55 <= duty <= 18.0:
PWM.set_duty_cycle(fan_pin, duty)
def fan_min():
fan_duty(9.7)
time.sleep(0.5)
fan_duty(9.55)
def fan_off():
PWM.set_duty_cycle(fan_pin, 9)
def psu_on():
GPIO.setup(psu_pin, GPIO.OUT)
GPIO.output(psu_pin, GPIO.HIGH)
def psu_off():
GPIO.output(psu_pin, GPIO.LOW)
class Heater():
def __init__(self, pin, freq, inv = 0):
self.pin = pin
PWM.start(self.pin, 0, freq, inv)
def set_duty(self, duty):
PWM.set_duty_cycle(self.pin, duty)
H1 = Heater(H1_pin, 1)
H2 = Heater(H2_pin, 1)
oven_init()
time.sleep(50)
H1.set_duty(0)
H2.set_duty(0)
time.sleep(10)
fan_off()