Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output pin inversion, update docs. #186

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

**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.

![Image](https://github.com/jbruce12000/kiln-controller/blob/main/public/assets/images/schematic.png)

*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.*
Expand Down
11 changes: 6 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@

try:
import board
spi_sclk = board.D17 #spi clock
spi_miso = board.D27 #spi Microcomputer In Serial Out
spi_cs = board.D22 #spi Chip Select
spi_mosi = board.D10 #spi Microcomputer Out Serial In (not connected)
gpio_heat = board.D23 #output that controls relay
spi_sclk = board.D17 #spi clock
spi_miso = board.D27 #spi Microcomputer In Serial Out
spi_cs = board.D22 #spi Chip Select
spi_mosi = board.D10 #spi Microcomputer Out Serial In (not connected)
gpio_heat = board.D23 #output that controls relay
gpio_heat_invert = False #invert the output state
except (NotImplementedError,AttributeError):
print("not running on blinka recognized board, probably a simulation")

Expand Down
1 change: 1 addition & 0 deletions docs/old-to-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pip install -r ./requirements.txt
spi_miso = board.D17
spi_mosi = board.D10 #this one is not actually used, so set it or not
gpio_heat = board.D23
gpio_heat_invert = False
```

5. test the thermocouple board and thermocouple
Expand Down
22 changes: 13 additions & 9 deletions gpioreadall.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,21 @@ def pin_state(g):
else:
D[p] = v

if(D['fsel'] < 2): # i.e. IN or OUT
name = 'GPIO{}'.format(g)
if('fsel' in D):
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:
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'
mode = ''

return name, mode, D['level']

Expand Down
7 changes: 5 additions & 2 deletions lib/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,22 @@ class Output(object):
state relay to turn the kiln elements on and off.
inputs
config.gpio_heat
config.gpio_heat_invert
'''
def __init__(self):
self.active = False
self.heater = digitalio.DigitalInOut(config.gpio_heat)
self.heater.direction = digitalio.Direction.OUTPUT
self.off = config.gpio_heat_invert
self.on = not self.off

def heat(self,sleepfor):
self.heater.value = True
self.heater.value = self.on
time.sleep(sleepfor)

def cool(self,sleepfor):
'''no active cooling, so sleep'''
self.heater.value = False
self.heater.value = self.off
time.sleep(sleepfor)

# wrapper for blinka board
Expand Down
9 changes: 6 additions & 3 deletions test-output.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# To test your gpio output to control a relay...
#
# 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...
#
Expand All @@ -31,14 +31,17 @@

heater = digitalio.DigitalInOut(config.gpio_heat)
heater.direction = digitalio.Direction.OUTPUT
off = config.gpio_heat_invert
on = not off

print("\nboard: %s" % (board.board_id))
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:
heater.value = True
heater.value = on
print("%s heater on" % datetime.datetime.now())
time.sleep(5)
heater.value = False
heater.value = off
print("%s heater off" % datetime.datetime.now())
time.sleep(5)