Add output pin inversion, update docs.
This commit is contained in:
parent
42d391ce4e
commit
d3b10d29b0
@ -54,6 +54,8 @@ My controller plugs into the wall, and the kiln plugs into the controller.
|
|||||||
|
|
||||||
**WARNING** This project involves high voltages and high currents. Please make sure that anything you build conforms to local electrical codes and aligns with industry best practices.
|
**WARNING** This project involves high voltages and high currents. Please make sure that anything you build conforms to local electrical codes and aligns with industry best practices.
|
||||||
|
|
||||||
|
**Note:** The GPIO configuration in this schematic does not match the defaults, check [config](https://github.com/jbruce12000/kiln-controller/blob/main/config.py) and make sure the gpio pin configuration aligns with your actual connections.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
*Note: I tried to power my ssr directly using a gpio pin, but it did not work. My ssr required 25ma to switch and rpi's gpio could only provide 16ma. YMMV.*
|
*Note: I tried to power my ssr directly using a gpio pin, but it did not work. My ssr required 25ma to switch and rpi's gpio could only provide 16ma. YMMV.*
|
||||||
|
|||||||
11
config.py
11
config.py
@ -84,11 +84,12 @@ currency_type = "$" # Currency Symbol to show when calculating cost to run j
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import board
|
import board
|
||||||
spi_sclk = board.D17 #spi clock
|
spi_sclk = board.D17 #spi clock
|
||||||
spi_miso = board.D27 #spi Microcomputer In Serial Out
|
spi_miso = board.D27 #spi Microcomputer In Serial Out
|
||||||
spi_cs = board.D22 #spi Chip Select
|
spi_cs = board.D22 #spi Chip Select
|
||||||
spi_mosi = board.D10 #spi Microcomputer Out Serial In (not connected)
|
spi_mosi = board.D10 #spi Microcomputer Out Serial In (not connected)
|
||||||
gpio_heat = board.D23 #output that controls relay
|
gpio_heat = board.D23 #output that controls relay
|
||||||
|
gpio_heat_invert = False #invert the output state
|
||||||
except (NotImplementedError,AttributeError):
|
except (NotImplementedError,AttributeError):
|
||||||
print("not running on blinka recognized board, probably a simulation")
|
print("not running on blinka recognized board, probably a simulation")
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,7 @@ pip install -r ./requirements.txt
|
|||||||
spi_miso = board.D17
|
spi_miso = board.D17
|
||||||
spi_mosi = board.D10 #this one is not actually used, so set it or not
|
spi_mosi = board.D10 #this one is not actually used, so set it or not
|
||||||
gpio_heat = board.D23
|
gpio_heat = board.D23
|
||||||
|
gpio_heat_invert = False
|
||||||
```
|
```
|
||||||
|
|
||||||
5. test the thermocouple board and thermocouple
|
5. test the thermocouple board and thermocouple
|
||||||
|
|||||||
@ -67,17 +67,21 @@ def pin_state(g):
|
|||||||
else:
|
else:
|
||||||
D[p] = v
|
D[p] = v
|
||||||
|
|
||||||
if(D['fsel'] < 2): # i.e. IN or OUT
|
if('fsel' in D):
|
||||||
name = 'GPIO{}'.format(g)
|
if(D['fsel'] < 2): # i.e. IN or OUT
|
||||||
|
name = 'GPIO{}'.format(g)
|
||||||
|
else:
|
||||||
|
name = D['func']
|
||||||
|
|
||||||
|
mode = MODES[D['fsel']]
|
||||||
|
if(D['fsel'] == 0 and 'pull' in D):
|
||||||
|
if(D['pull'] == 'UP'):
|
||||||
|
mode = 'IN ^'
|
||||||
|
if(D['pull'] == 'DOWN'):
|
||||||
|
mode = 'IN v'
|
||||||
else:
|
else:
|
||||||
name = D['func']
|
name = D['func']
|
||||||
|
mode = ''
|
||||||
mode = MODES[D['fsel']]
|
|
||||||
if(D['fsel'] == 0 and 'pull' in D):
|
|
||||||
if(D['pull'] == 'UP'):
|
|
||||||
mode = 'IN ^'
|
|
||||||
if(D['pull'] == 'DOWN'):
|
|
||||||
mode = 'IN v'
|
|
||||||
|
|
||||||
return name, mode, D['level']
|
return name, mode, D['level']
|
||||||
|
|
||||||
|
|||||||
@ -36,19 +36,22 @@ class Output(object):
|
|||||||
state relay to turn the kiln elements on and off.
|
state relay to turn the kiln elements on and off.
|
||||||
inputs
|
inputs
|
||||||
config.gpio_heat
|
config.gpio_heat
|
||||||
|
config.gpio_heat_invert
|
||||||
'''
|
'''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.active = False
|
self.active = False
|
||||||
self.heater = digitalio.DigitalInOut(config.gpio_heat)
|
self.heater = digitalio.DigitalInOut(config.gpio_heat)
|
||||||
self.heater.direction = digitalio.Direction.OUTPUT
|
self.heater.direction = digitalio.Direction.OUTPUT
|
||||||
|
self.off = config.gpio_heat_invert
|
||||||
|
self.on = not self.off
|
||||||
|
|
||||||
def heat(self,sleepfor):
|
def heat(self,sleepfor):
|
||||||
self.heater.value = True
|
self.heater.value = self.on
|
||||||
time.sleep(sleepfor)
|
time.sleep(sleepfor)
|
||||||
|
|
||||||
def cool(self,sleepfor):
|
def cool(self,sleepfor):
|
||||||
'''no active cooling, so sleep'''
|
'''no active cooling, so sleep'''
|
||||||
self.heater.value = False
|
self.heater.value = self.off
|
||||||
time.sleep(sleepfor)
|
time.sleep(sleepfor)
|
||||||
|
|
||||||
# wrapper for blinka board
|
# wrapper for blinka board
|
||||||
|
|||||||
@ -17,7 +17,7 @@ except NotImplementedError:
|
|||||||
# To test your gpio output to control a relay...
|
# To test your gpio output to control a relay...
|
||||||
#
|
#
|
||||||
# Edit config.py and set the following in that file to match your
|
# Edit config.py and set the following in that file to match your
|
||||||
# hardware setup: GPIO_HEAT
|
# hardware setup: gpio_heat, gpio_heat_invert
|
||||||
#
|
#
|
||||||
# then run this script...
|
# then run this script...
|
||||||
#
|
#
|
||||||
@ -31,14 +31,17 @@ except NotImplementedError:
|
|||||||
|
|
||||||
heater = digitalio.DigitalInOut(config.gpio_heat)
|
heater = digitalio.DigitalInOut(config.gpio_heat)
|
||||||
heater.direction = digitalio.Direction.OUTPUT
|
heater.direction = digitalio.Direction.OUTPUT
|
||||||
|
off = config.gpio_heat_invert
|
||||||
|
on = not off
|
||||||
|
|
||||||
print("\nboard: %s" % (board.board_id))
|
print("\nboard: %s" % (board.board_id))
|
||||||
print("heater configured as config.gpio_heat = %s BCM pin\n" % (config.gpio_heat))
|
print("heater configured as config.gpio_heat = %s BCM pin\n" % (config.gpio_heat))
|
||||||
|
print("heater output pin configured as invert = %r\n" % (config.gpio_heat_invert))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
heater.value = True
|
heater.value = on
|
||||||
print("%s heater on" % datetime.datetime.now())
|
print("%s heater on" % datetime.datetime.now())
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
heater.value = False
|
heater.value = off
|
||||||
print("%s heater off" % datetime.datetime.now())
|
print("%s heater off" % datetime.datetime.now())
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user