Skip to content

Commit

Permalink
fixed a bunch of string issues and made the output a bit prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
pwntr committed Oct 30, 2018
1 parent 3d71465 commit 67e8feb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 16 deletions.
2 changes: 1 addition & 1 deletion default_reflow_profile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ reflow_temp = 217
duration = 90
max_temp = 250
peak_start = 245
duration_at_peak = 30
duration_at_peak = 15
maxkpersec = 3

[cooldown]
Expand Down
53 changes: 53 additions & 0 deletions logtemps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# just a quick script to log current temps from the thermocouple

import requests, time
from configparser import ConfigParser

# read in config file
parser = ConfigParser()
parser.read('settings.conf')

thermocouple_ip = parser.get('basics', 'thermocouple_ip')
unit = parser.get('basics', 'unit')

# set timestamp baseline for data gathering / graph plotting
time_base = time.time()


def getTemp():
r = requests.get('http://' + thermocouple_ip + '/' + unit)
temp = r.json()[unit]
timestamp = round(time.time() - time_base, 2)
# TODO: create graph ouput from gathered data after the run. Maybe just a CSV file for starters

runtime = int(time.time() - time_base)
minutes = int(runtime / 60)
seconds = runtime % 60
if seconds < 10:
seconds = '0' + str(seconds)

print('Time: ' + str(minutes) + ':' + str(seconds))
print('>>>>>>>>>>>>>>>>> ' + str(temp))

return temp


try:
thermocouple_status = requests.get('http://' + thermocouple_ip + '/' + unit).status_code

if thermocouple_status == 200:
print('Succesfully connected to the thermocouple')
except:
print('Error connecting to the thermocouple. Please check your settings and network status.')
exit(1)


temp = getTemp()
previous_temp = temp

while True:
temp = getTemp()
kpersec = temp - previous_temp
print('>>> K/s: ' + str(kpersec))
previous_temp = temp
time.sleep(1)
34 changes: 21 additions & 13 deletions reflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# No need to ever touch or fiddle with mains power!
#
# @author: Peter Winter <code@limelabs.io>
# @version: 1.0.0
# @date: 10/29/2018
# @version: 1.0.1
# @release: 10/30/2018

import requests, time
import tplink_smartplug as plug
Expand Down Expand Up @@ -53,13 +53,24 @@
exit(1)

# functions
def getTimeString():
runtime = int(time.time() - time_base)
minutes = int(runtime / 60)
seconds = runtime % 60
if seconds < 10:
seconds = '0' + str(seconds)

return str(minutes) + ':' + str(seconds)

def getTemp():
r = requests.get('http://' + thermocouple_ip + '/' + unit)
temp = r.json()[unit]
timestamp = round(time.time() - time_base, 2)
# TODO: create graph ouput from gathered data after the run. Maybe just a CSV file for starters
print(temp)
print(str(timestamp))

print('Time: ' + getTimeString())
print('>>>>>>>>>>>>>>>>> ' + str(temp))

return temp

def getPlugRelayState():
Expand Down Expand Up @@ -100,7 +111,7 @@ def rampUp(phase, maxKpersec, target, duration = -1, reflow_temp = 0.0, peak_sta
if not peak_reset:
duration = duration_at_peak
peak_reset = True
print('Peak zone of ' + str(peak_start) + ' - ' + target + ' degrees reached). ' + str(duration) + ' seconds remaining in peak zone.')
print('Peak zone of ' + str(peak_start) + ' - ' + str(target) + ' degrees reached). ' + str(duration) + ' seconds remaining in peak zone.')

if kpersec > maxKpersec:
print('Max K/s reached, waiting before continuing to ramp up...')
Expand All @@ -119,7 +130,7 @@ def rampUp(phase, maxKpersec, target, duration = -1, reflow_temp = 0.0, peak_sta

# in case there's time left on the optional duration timer, hold the temp for the remainder of seconds
if duration > 0:
print('Target temp of ' + str(target) + ' reached, but ' + duration + ' seconds left on timer. Holding temp...')
print('Target temp of ' + str(target) + ' reached, but ' + str(duration) + ' seconds left on timer. Holding temp...')
while duration > 0:
temp = getTemp()

Expand Down Expand Up @@ -153,16 +164,16 @@ def coolDown(maxKpersec, target):

# if cooldown happens to fast
if kpersec < maxKpersec:
print('>>>>>> WARNING! Cooldown rate exceeds ' + maxKpersec + ' K/s at currently ' + kpersec + ' K/s.')
print('>>>>>> WARNING! Cooldown rate exceeds ' + str(maxKpersec) + ' K/s at currently ' + str(kpersec) + ' K/s.')
print('>>>>>> Consider less aggressive cooling to reduce stress on the components!')
else:
print('K/s ' + str(kpersec))
print('K/s: ' + str(kpersec))

previous_temp = temp
time.sleep(1)

# TODO: play sound here
print('Congrats! Your PCB is ready. Be careful, it might still be a little warm at ' + target + ' degrees.')
print('Congrats! Your PCB is ready. Be careful, it might still be a little warm at ' + str(target) + ' degrees.')


# let's roll
Expand Down Expand Up @@ -196,9 +207,6 @@ def coolDown(maxKpersec, target):

coolDown(maxkpersec, target)

runtime = int(time.time() - time_base)
minutes = int(runtime / 60)
seconds = runtime % 60
print('The entire reflow process took ' + str(minutes) + ':' + str(seconds) + ' minutes.')
print('The entire reflow process took ' + getTimeString() + ' minutes.')

exit(0)
4 changes: 2 additions & 2 deletions settings.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[basics]
plug_ip = 192.168.1.236
thermocouple_ip = 192.168.1.231
plug_ip = 10.0.0.173
thermocouple_ip = 10.0.0.134
unit = celsius
profile = default_reflow_profile.conf

0 comments on commit 67e8feb

Please sign in to comment.