Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ulrichard/Printrun
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichard committed Dec 30, 2011
2 parents a5e024e + e67a595 commit 101f280
Show file tree
Hide file tree
Showing 12 changed files with 1,222 additions and 870 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Download the following, and install in this order:
1. http://python.org/ftp/python/2.7.2/python-2.7.2.msi
2. http://pypi.python.org/packages/any/p/pyserial/pyserial-2.5.win32.exe
3. http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.12.0-py27.exe
4. http://launchpad.net/pyreadline/1.7/1.7/+download/pyreadline-1.7.zip
4. http://launchpad.net/pyreadline/1.7/1.7/+download/pyreadline-1.7.win32.exe

## Ubuntu/Debian
`sudo apt-get install python-serial python-wxgtk2.8`

Expand All @@ -22,7 +23,9 @@ Download the following, and install in this order:
## Mac OS X Lion

1. Ensure that the active Python is the system version. (`brew uninstall python` or other appropriate incantations)
2. Download an install [wxPython version 2.9-Carbon](http://wxpython.org/download.php#unstable) (the Cocoa version doesn't work)
2. Download an install [wxPython2.8-osx-unicode] matching to your python version (most likely 2.7 on Lion,
check with: python --version) from: http://wxpython.org/download.php#stable
Known to work PythonWX: http://superb-sea2.dl.sourceforge.net/project/wxpython/wxPython/2.8.12.1/wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg
3. Download and unpack pyserial from http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz
4. In a terminal, change to the folder you unzipped to, then type in: `sudo python setup.py install`

Expand Down
41 changes: 0 additions & 41 deletions blupload.py

This file was deleted.

102 changes: 66 additions & 36 deletions calibrateextruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#Interactive RepRap e axis calibration program
#(C) Nathan Zadoks 2011
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
t= 60 #Time to wait for extrusion
s=300 #Extrusion speed (mm/min)
n=100 #Default length to extrude
m= 0 #User-entered measured extrusion length
k=300 #Default amount of steps per mm
Expand All @@ -11,6 +11,8 @@

tempmax=250 #Maximum extrusion temperature

t=int(n*60)/s #Time to wait for extrusion

try:
from printdummy import printcore
except ImportError:
Expand Down Expand Up @@ -42,6 +44,37 @@ def w(s):
sys.stdout.write(s)
sys.stdout.flush()


def heatup(p,temp,s=0):
curtemp=gettemp(p)
p.send_now('M109 S%03d'%temp)
p.temp=0
if not s: w("Heating extruder up..")
f=False
while curtemp<=(temp-1):
p.send_now('M105')
time.sleep(0.5)
if not f:
time.sleep(1.5)
f=True
curtemp=gettemp(p)
if curtemp: w(u"\rHeating extruder up.. %3d \xb0C"%curtemp)
if s: print
else: print "\nReady."

def gettemp(p):
try: p.logl
except: setattr(p,'logl',0)
try: p.temp
except: setattr(p,'temp',0)
for n in range(p.logl,len(p.log)):
line=p.log[n]
if 'T:' in line:
try:
setattr(p,'temp',int(line.split('T:')[1].split()[0]))
except: print line
p.logl=len(p.log)
return p.temp
if not os.path.exists(port):
port=0

Expand Down Expand Up @@ -83,39 +116,36 @@ def w(s):
print
print "Serial port: %s"%(port if port else 'auto')

#Connect to printer
w("Connecting to printer..")
p=None
try:
p=printcore(port,115200)
except:
print 'Error.'
raise
while not p.online:
time.sleep(1)
w('.')
print " connected."

def sendcb(self,l):
if l=='G92 E0':
self.hot=True
w("Heating extruder up..")
setattr(p,'hot',False)
p.sendcb=sendcb
p.send_now('M109 S%03d'%temp)
while not p.hot:
time.sleep(1)
w('.')
print " ready."

#Calibration loop
while n!=m:
p.send_now("G92 E0") #Reset e axis
p.send_now("G1 E%d F100"%int(n)) #Extrude length of filament
wait(t,'Extruding.. ')
m=float_input("How many millimeters of filament were extruded? ")
if n!=m:
k=(n/m)*k
p.send_now("M92 E%d"%int(round(k))) #Set new step count
print "Steps per mm: %3d steps"%k #Tell user
print 'Calibration completed.' #Yay!
p.disconnect()
#Connect to printer
w("Connecting to printer..")
try:
p=printcore(port,115200)
except:
print 'Error.'
raise
while not p.online:
time.sleep(1)
w('.')
print " connected."

heatup(p,temp)

#Calibration loop
while n!=m:
heatup(p,temp,True)
p.send_now("G92 E0") #Reset e axis
p.send_now("G1 E%d F%d"%(n,s)) #Extrude length of filament
wait(t,'Extruding.. ')
m=float_input("How many millimeters of filament were extruded? ")
if m==0: continue
if n!=m:
k=(n/m)*k
p.send_now("M92 E%d"%int(round(k))) #Set new step count
print "Steps per mm: %3d steps"%k #Tell user
print 'Calibration completed.' #Yay!
except KeyboardInterrupt:
pass
finally:
if p: p.disconnect()
4 changes: 2 additions & 2 deletions gviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _y(y):
self.pens[ target[2] ] += [self.mainpen if target[3] != self.lastpos[3] else self.travelpen]
self.lastpos = target
else:
self.hilight += line
self.hilight += [line]
self.hilightpos = target
self.dirty = 1

Expand All @@ -266,7 +266,7 @@ def _y(y):
self.arcpens[ target[2] ] += [self.arcpen]
self.lastpos = target
else:
self.hilightarcs += arc
self.hilightarcs += [arc]
self.hilightpos = target
self.dirty = 1

Expand Down
Loading

0 comments on commit 101f280

Please sign in to comment.