Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
af9a6aaa
Commit
af9a6aaa
authored
Dec 03, 2011
by
Nathan Zadoks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Greatly improved calibrateextruder.py
parent
bdb9eae0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
36 deletions
+66
-36
calibrateextruder.py
calibrateextruder.py
+66
-36
No files found.
calibrateextruder.py
View file @
af9a6aaa
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#Interactive RepRap e axis calibration program
#Interactive RepRap e axis calibration program
#(C) Nathan Zadoks 2011
#(C) Nathan Zadoks 2011
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
#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
n
=
100
#Default length to extrude
m
=
0
#User-entered measured extrusion length
m
=
0
#User-entered measured extrusion length
k
=
300
#Default amount of steps per mm
k
=
300
#Default amount of steps per mm
...
@@ -11,6 +11,8 @@ temp=210 #Default extrusion temperature
...
@@ -11,6 +11,8 @@ temp=210 #Default extrusion temperature
tempmax
=
250
#Maximum extrusion temperature
tempmax
=
250
#Maximum extrusion temperature
t
=
int
(
n
*
60
)
/
s
#Time to wait for extrusion
try
:
try
:
from
printdummy
import
printcore
from
printdummy
import
printcore
except
ImportError
:
except
ImportError
:
...
@@ -42,6 +44,37 @@ def w(s):
...
@@ -42,6 +44,37 @@ def w(s):
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
def
heatup
(
p
,
temp
,
s
=
0
):
curtemp
=
gettemp
(
p
)
p
.
send_now
(
'M109 S
%03
d'
%
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"
\r
Heating extruder up..
%3
d
\xb0
C"
%
curtemp
)
if
s
:
print
else
:
print
"
\n
Ready."
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
):
if
not
os
.
path
.
exists
(
port
):
port
=
0
port
=
0
...
@@ -83,39 +116,36 @@ print "Length extruded: %3d mm"%n
...
@@ -83,39 +116,36 @@ print "Length extruded: %3d mm"%n
print
print
print
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
print
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
#Connect to printer
p
=
None
w
(
"Connecting to printer.."
)
try
:
try
:
p
=
printcore
(
port
,
115200
)
#Connect to printer
except
:
w
(
"Connecting to printer.."
)
print
'Error.'
try
:
raise
p
=
printcore
(
port
,
115200
)
while
not
p
.
online
:
except
:
time
.
sleep
(
1
)
print
'Error.'
w
(
'.'
)
raise
print
" connected."
while
not
p
.
online
:
time
.
sleep
(
1
)
def
sendcb
(
self
,
l
):
w
(
'.'
)
if
l
==
'G92 E0'
:
print
" connected."
self
.
hot
=
True
w
(
"Heating extruder up.."
)
heatup
(
p
,
temp
)
setattr
(
p
,
'hot'
,
False
)
p
.
sendcb
=
sendcb
#Calibration loop
p
.
send_now
(
'M109 S
%03
d'
%
temp
)
while
n
!=
m
:
while
not
p
.
hot
:
heatup
(
p
,
temp
,
True
)
time
.
sleep
(
1
)
p
.
send_now
(
"G92 E0"
)
#Reset e axis
w
(
'.'
)
p
.
send_now
(
"G1 E
%
d F
%
d"
%
(
n
,
s
))
#Extrude length of filament
print
" ready."
wait
(
t
,
'Extruding.. '
)
m
=
float_input
(
"How many millimeters of filament were extruded? "
)
#Calibration loop
if
m
==
0
:
continue
while
n
!=
m
:
if
n
!=
m
:
p
.
send_now
(
"G92 E0"
)
#Reset e axis
k
=
(
n
/
m
)
*
k
p
.
send_now
(
"G1 E
%
d F100"
%
int
(
n
))
#Extrude length of filament
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
wait
(
t
,
'Extruding.. '
)
print
"Steps per mm:
%3
d steps"
%
k
#Tell user
m
=
float_input
(
"How many millimeters of filament were extruded? "
)
print
'Calibration completed.'
#Yay!
if
n
!=
m
:
except
KeyboardInterrupt
:
k
=
(
n
/
m
)
*
k
pass
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
finally
:
print
"Steps per mm:
%3
d steps"
%
k
#Tell user
if
p
:
p
.
disconnect
()
print
'Calibration completed.'
#Yay!
p
.
disconnect
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment