kopia lustrzana https://github.com/jamesgao/kiln_controller
Add code / model for a limit switch
rodzic
cbce1ddce8
commit
c04f9a5556
|
@ -19,7 +19,7 @@ class Stepper(threading.Thread):
|
|||
[0,0,1,1],
|
||||
[1,0,0,1]]
|
||||
|
||||
def __init__(self, pin1=5, pin2=6, pin3=13, pin4=19, timeout=1):
|
||||
def __init__(self, pin1=5, pin2=6, pin3=13, pin4=19, timeout=1, home_pin=None):
|
||||
super(Stepper, self).__init__()
|
||||
self.daemon = True
|
||||
|
||||
|
@ -32,9 +32,11 @@ class Stepper(threading.Thread):
|
|||
GPIO.setup(pin2, GPIO.OUT)
|
||||
GPIO.setup(pin3, GPIO.OUT)
|
||||
GPIO.setup(pin4, GPIO.OUT)
|
||||
self.home_pin = home_pin
|
||||
GPIO.setup(home_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
|
||||
self.phase = 0
|
||||
self.timeout = timeout
|
||||
self.home()
|
||||
self.start()
|
||||
|
||||
def stop(self):
|
||||
|
@ -56,6 +58,18 @@ class Stepper(threading.Thread):
|
|||
self.queue.put((num, speed, block))
|
||||
self.finished.wait()
|
||||
|
||||
def home(self):
|
||||
if self.home_pin is None:
|
||||
raise ValueError("No homing switch defined")
|
||||
|
||||
while GPIO.input(self.home_pin):
|
||||
for i in range(len(self.pattern)):
|
||||
for pin, out in zip(self.pins, self.pattern[i]):
|
||||
GPIO.output(pin, out)
|
||||
time.sleep(1. / 150.)
|
||||
|
||||
self.phase = 0
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
step, speed, block = self.queue.get()
|
||||
|
@ -202,7 +216,8 @@ class Regulator(threading.Thread):
|
|||
|
||||
def off(self, block=True):
|
||||
logger.info("Shutting off gas")
|
||||
self.stepper.step(-self.current, self.speed, block=block)
|
||||
#self.stepper.step(-self.current, self.speed, block=block)
|
||||
self.stepper.home()
|
||||
self.current = 0
|
||||
|
||||
def set(self, value, block=False):
|
||||
|
|
|
@ -40,11 +40,42 @@ module zipties() {
|
|||
}
|
||||
|
||||
module holder() {
|
||||
difference() {
|
||||
intersection() {
|
||||
translate([0,0,-3.3-thick]) scale([1,1.4]) cylinder(r=36+thick, h=16, $fn=128);
|
||||
translate([36+thick-20,-zip_pos-3-thick, -10]) cube([20, 2*zip_pos+6+2*thick,20]);
|
||||
width = 2*zip_pos+6+2*thick;
|
||||
|
||||
module slot(length) {
|
||||
hull() {
|
||||
cylinder(r=1, h=6);
|
||||
translate([length,0]) cylinder(r=1, h=6);
|
||||
}
|
||||
}
|
||||
|
||||
//translate([18,-width/2, -3.3-thick+16+32-6]) cube([12, 20, 6]);
|
||||
difference() {
|
||||
union() {
|
||||
//main body
|
||||
intersection() {
|
||||
translate([0,0,-3.3-thick]) scale([1,1.4]) cylinder(r=36+thick, h=16, $fn=128);
|
||||
translate([36+thick-20,-width/2, -10]) cube([20, width,20]);
|
||||
}
|
||||
|
||||
//switch tab
|
||||
intersection() {
|
||||
translate([0,0,-3.3-thick]) scale([1, 1.4]) difference() {
|
||||
cylinder(r=36+thick, h=16+34+3, $fn=128);
|
||||
translate([0,0,-1]) cylinder(r=36, h=16+32+3-2,$fn=128);
|
||||
}
|
||||
translate([36+thick-20, -width/2, -3.3-thick]) cube([50, 20, 16+32+4]);
|
||||
}
|
||||
}
|
||||
//Screw slots for switch
|
||||
translate([20,-width/2+10-9.5/2, -3.3-thick+16+32-1]) {
|
||||
translate([3,0]) slot(5);
|
||||
translate([3,9.5]) slot(5);
|
||||
}
|
||||
|
||||
//Slot for wire to ensure no gear tangling
|
||||
translate([20, -width/2+8.5,-3.3-thick+16+32-3]) cube([50, 3, 3]);
|
||||
|
||||
regulator();
|
||||
zipties();
|
||||
}
|
||||
|
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue